00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 int blockStart;
00027 int nSeg = 16/sizeof(T);
00028 SPEProfile *profile = malloc(sizeof(*profile));
00029 T * pp1 = (T*)memalign( 16, MATRIX_DIM*(queryLen+16)*sizeof(T));
00030
00031 profile->len = queryLen;
00032 profile->addr = (ppu_addr_t)pp1;
00033 profile->min = DBL_MAX;
00034 profile->max = DBL_MIN;
00035
00036
00037
00038
00039
00040 if (TOTAL_MEMORY<maxDbLen*(sizeof(char)+2*sizeof(T))) error("insufficient memory on SPE");
00041 profile->blockSize = (TOTAL_MEMORY-maxDbLen*(sizeof(char)+2*sizeof(T)))/((MATRIX_DIM+3)*sizeof(T)) & -16;
00042 if (profile->blockSize<=50) error("insufficient memory on SPE");
00043 profile->blockSize = ALIGN16( MIN(profile->blockSize,queryLen) );
00044
00045
00046 for(blockStart=0; blockStart<queryLen; blockStart+=profile->blockSize){
00047 T * currentBlock = pp1+blockStart*MATRIX_DIM;
00048
00049 int currentBlockSize = ALIGN16( MIN(profile->blockSize,queryLen-blockStart) );
00050 int segLen = currentBlockSize / nSeg;
00051 int i,j,k;
00052
00053
00054 for( i=0; i<MATRIX_DIM; i++ ){
00055 T * currentProfile = currentBlock+i*currentBlockSize;
00056 for( j=0; nSeg*j < currentBlockSize; j++ ){
00057 T * tmp = currentProfile + j*nSeg;
00058 for( k=0; k<nSeg; k++ )
00059 if( j + k*segLen + blockStart < queryLen ) {
00060 tmp[k] = (T)matrix[ query[j + k*segLen + blockStart] * MATRIX_DIM + i ];
00061 if(profile->min > tmp[k]) profile->min = tmp[k];
00062 if(profile->max < tmp[k]) profile->max = tmp[k];
00063 }
00064 else tmp[k] = 0;
00065 }
00066 }
00067 }
00068
00069 return profile;