Loading src/TileProcessor.cuh +167 −122 Original line number Original line Diff line number Diff line Loading @@ -1010,7 +1010,7 @@ extern "C" __global__ void correlate2D( /** /** * Calculate 2D phase correlation pairs from CLT representation. This is an outer kernel that calls other * Calculate 2D phase correlation pairs from CLT representation. This is an outer kernel that calls other * ones with CDP, this one should be configured as correlate2D<<<1,1>>> * ones with CDP, this one should be configured as correlate2D<<<1,1>>> * * gpu_corr_indices will include sums * @param num_cams number of cameras <= NUM_CAMS * @param num_cams number of cameras <= NUM_CAMS * @param sel_pairs array of length to accommodate all pairs (4 for 16 cameras, 120 pairs). * @param sel_pairs array of length to accommodate all pairs (4 for 16 cameras, 120 pairs). * @param gpu_clt array of num_cams pointers to the CLT (frequency domain) data [TILES-Y][TILES-X][NUM_COLORS][DTT_SIZE*DTT_SIZE] * @param gpu_clt array of num_cams pointers to the CLT (frequency domain) data [TILES-Y][TILES-X][NUM_COLORS][DTT_SIZE*DTT_SIZE] Loading Loading @@ -2660,7 +2660,7 @@ __global__ void index_correlate( * Helper kernel for correlateInter2D() - generates dense list of correlation tasks. * Helper kernel for correlateInter2D() - generates dense list of correlation tasks. * For interscene correlation. One correlation output for each selected sensor * For interscene correlation. One correlation output for each selected sensor * plus a sum of them all. So for all 16 sensors selected ooutput will have 17 * plus a sum of them all. So for all 16 sensors selected ooutput will have 17 * 2D correlations (with some being the l;ast one) * 2D correlations (with sum being the last one) * All pairs for the same tile will always be in the same order: increasing sensor numbers * All pairs for the same tile will always be in the same order: increasing sensor numbers * with sum being the last. Sum will be marked by 0xff in the LSB. * with sum being the last. Sum will be marked by 0xff in the LSB. * With the quad camera each tile may generate up to 6 pairs (int array elements) * With the quad camera each tile may generate up to 6 pairs (int array elements) Loading Loading @@ -2770,8 +2770,8 @@ extern "C" __global__ void convert_direct( // called with a single block, singl convert_correct_tiles<<<grid_tp,threads_tp>>>( convert_correct_tiles<<<grid_tp,threads_tp>>>( num_cams, // int num_cams, // actual number of cameras num_cams, // int num_cams, // actual number of cameras num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono gpu_kernel_offsets, // float ** gpu_kernel_offsets, // [num_cams], ((kernels_hor>0)?gpu_kernel_offsets:0), // float ** gpu_kernel_offsets, // [num_cams], gpu_kernels, // float ** gpu_kernels, // [num_cams], ((kernels_hor>0)?gpu_kernels:0), // float ** gpu_kernels, // [num_cams], gpu_images, // float ** gpu_images, // [num_cams], gpu_images, // float ** gpu_images, // [num_cams], gpu_ftasks, // float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 gpu_ftasks, // float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 gpu_active_tiles, // int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles gpu_active_tiles, // int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles Loading Loading @@ -2862,8 +2862,8 @@ extern "C" __global__ void erase_clt_tiles_inner( __global__ void convert_correct_tiles( __global__ void convert_correct_tiles( int num_cams, // actual number of cameras int num_cams, // actual number of cameras int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono float ** gpu_kernel_offsets, // [num_cams], float ** gpu_kernel_offsets, // [num_cams], ### float ** gpu_kernels, // [num_cams], float ** gpu_kernels, // [num_cams], ### float ** gpu_images, // [num_cams], float ** gpu_images, // [num_cams], float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles Loading Loading @@ -2929,6 +2929,7 @@ __global__ void convert_correct_tiles( // process each camera,l each color in series (to reduce shared memory) // process each camera,l each color in series (to reduce shared memory) for (int ncam = 0; ncam < num_cams; ncam++){ for (int ncam = 0; ncam < num_cams; ncam++){ for (int color = 0; color < num_colors; color++){ for (int color = 0; color < num_colors; color++){ if (gpu_kernels) { convertCorrectTile( convertCorrectTile( // TODO: remove debug when done // TODO: remove debug when done #ifdef DBG_TILE #ifdef DBG_TILE Loading @@ -2936,8 +2937,8 @@ __global__ void convert_correct_tiles( #else #else num_colors, // int num_colors, //* num_colors, // int num_colors, //* #endif #endif (struct CltExtra*)(gpu_kernel_offsets[ncam]), // struct CltExtra* gpu_kernel_offsets, (struct CltExtra*)(gpu_kernel_offsets[ncam]), // struct CltExtra* gpu_kernel_offsets, #### gpu_kernels[ncam], // float * gpu_kernels, gpu_kernels[ncam], // float * gpu_kernels, #### gpu_images[ncam], // float * gpu_images, gpu_images[ncam], // float * gpu_images, gpu_clt[ncam], // float * gpu_clt, gpu_clt[ncam], // float * gpu_clt, color, // const int color, color, // const int color, Loading @@ -2960,6 +2961,39 @@ __global__ void convert_correct_tiles( kernels_hor, // int kernels_hor, kernels_hor, // int kernels_hor, kernels_vert, //int kernels_vert) kernels_vert, //int kernels_vert) tilesx); // int tilesx); tilesx); // int tilesx); } else { convertCorrectTile( // TODO: remove debug when done #ifdef DBG_TILE num_colors + (((task_num == DBG_TILE)&& (ncam == 0)) ? 16:0), // int num_colors, //* #else num_colors, // int num_colors, //* #endif (struct CltExtra*) 0, // struct CltExtra* gpu_kernel_offsets, #### (float*) 0, // float * gpu_kernels, #### gpu_images[ncam], // float * gpu_images, gpu_clt[ncam], // float * gpu_clt, color, // const int color, lpf_mask, // const int lpf_mask, tt[tile_in_block].xy[ncam][0], // const float centerX, tt[tile_in_block].xy[ncam][1], // const float centerY, tt[tile_in_block].txy, // const int txy, tt[tile_in_block].scale, // const float tscale, dstride, // size_t dstride, // in floats (pixels) (float * )(clt_tile [tile_in_block]), // float clt_tile [TILES_PER_BLOCK][NUM_CAMS][num_colors][4][DTT_SIZE][DTT_SIZE]) (float * )(clt_kernels[tile_in_block]), // float clt_tile [num_colors][4][DTT_SIZE][DTT_SIZE], int_topleft[tile_in_block], // int int_topleft [num_colors][2], residual_shift[tile_in_block], // float frac_topleft [num_colors][2], window_hor_cos[tile_in_block], // float window_hor_cos [num_colors][2*DTT_SIZE], window_hor_sin[tile_in_block], // float window_hor_sin [num_colors][2*DTT_SIZE], window_vert_cos[tile_in_block], // float window_vert_cos [num_colors][2*DTT_SIZE]); window_vert_sin[tile_in_block], // float window_vert_sin [num_colors][2*DTT_SIZE]); woi_width, // int woi_width, woi_height, // int woi_height, 0, // kernels_hor, // int kernels_hor, 0, // kernels_vert, //int kernels_vert) tilesx); // int tilesx); } __syncthreads(); __syncthreads(); } } } } Loading Loading @@ -4394,8 +4428,8 @@ __device__ void normalizeTileAmplitude( */ */ __device__ void convertCorrectTile( __device__ void convertCorrectTile( int num_colors, //* int num_colors, //* struct CltExtra * gpu_kernel_offsets, // [tileY][tileX][color] struct CltExtra * gpu_kernel_offsets, // [tileY][tileX][color] if null, will not calculate kernel-related offsets float * gpu_kernels, // [tileY][tileX][color] float * gpu_kernels, // [tileY][tileX][color] // null w/o kernels float * gpu_images, float * gpu_images, float * gpu_clt, float * gpu_clt, const int color, const int color, Loading @@ -4406,7 +4440,7 @@ __device__ void convertCorrectTile( const float tscale, const float tscale, const size_t dstride, // in floats (pixels) const size_t dstride, // in floats (pixels) float * clt_tile, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_tile, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_kernels, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_kernels, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports // null w/o kernels int int_topleft [2], int int_topleft [2], float residual_shift [2], float residual_shift [2], float window_hor_cos [2*DTT_SIZE], float window_hor_cos [2*DTT_SIZE], Loading @@ -4430,12 +4464,12 @@ __device__ void convertCorrectTile( int max_py = woi_height - 1; // IMG-HEIGHT - 1; // odd int max_py = woi_height - 1; // IMG-HEIGHT - 1; // odd int max_pxm1 = max_px - 1; // even int max_pxm1 = max_px - 1; // even int max_pym1 = max_py - 1; // even int max_pym1 = max_py - 1; // even int max_kernel_hor = kernels_hor - 1; // KERNELS_HOR -1; int max_kernel_vert = kernels_vert - 1; // KERNELS_VERT-1; int ktileX, ktileY; int kernel_index; // common for all coors int kernel_index; // common for all coors float kdx, kdy; float kdx, kdy; if (gpu_kernels) { int ktileX, ktileY; int max_kernel_hor = kernels_hor - 1; // KERNELS_HOR -1; int max_kernel_vert = kernels_vert - 1; // KERNELS_VERT-1; if (threadIdx.x == 0){ if (threadIdx.x == 0){ // ktileX = min(max_kernel_hor, max(0, ((int) lrintf(centerX * (1.0/KERNELS_STEP)+1)))); // ktileX = min(max_kernel_hor, max(0, ((int) lrintf(centerX * (1.0/KERNELS_STEP)+1)))); // ktileY = min(max_kernel_vert, max(0, ((int) lrintf(centerY * (1.0/KERNELS_STEP)+1)))); // ktileY = min(max_kernel_vert, max(0, ((int) lrintf(centerY * (1.0/KERNELS_STEP)+1)))); Loading Loading @@ -4480,14 +4514,15 @@ __device__ void convertCorrectTile( kdy, // T var, kdy, // T var, 0, // int srcLane, 0, // int srcLane, THREADS_PER_TILE); // int width=warpSize); THREADS_PER_TILE); // int width=warpSize); __syncthreads();// __syncwarp(); // is it needed? __syncthreads();// __syncwarp(); // is it needed? } float px, py; float px, py; int kernel_full_index; if (gpu_kernels) { // only copy kernels if they exist // copy kernel // copy kernel int kernel_full_index = kernel_index + color; kernel_full_index = kernel_index + color; float * kernel_src = gpu_kernels + kernel_full_index* (DTT_SIZE * DTT_SIZE * 4); float * kernel_src = gpu_kernels + kernel_full_index* (DTT_SIZE * DTT_SIZE * 4); float * kernelp = clt_kernels; float * kernelp = clt_kernels; kernel_src += threadIdx.x; // lsb; kernel_src += threadIdx.x; // lsb; kernelp += threadIdx.x; // lsb; kernelp += threadIdx.x; // lsb; #pragma unroll #pragma unroll Loading @@ -4497,11 +4532,17 @@ __device__ void convertCorrectTile( kernelp+=DTT_SIZE1; kernelp+=DTT_SIZE1; kernel_src+=THREADSX; kernel_src+=THREADSX; } } } // Calculate offsets and prepare windows (all colors): px = centerX - DTT_SIZE; // fractional left corner (w/o kernel) py = centerY - DTT_SIZE; // fractional top corner (w/o kernel) if (gpu_kernel_offsets){ // adding no-kernel version with rectilinear images struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; px -= clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy ; px = centerX - DTT_SIZE - (clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy) ; // fractional left corner py -= clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy ; } // Calculate offsets and prepare windows (all colors): // struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; // px = centerX - DTT_SIZE - (clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy) ; // fractional left corner int itlx = (int) floorf(px +0.5f); int itlx = (int) floorf(px +0.5f); int_topleft [0] = itlx; int_topleft [0] = itlx; float shift_hor = itlx - px; float shift_hor = itlx - px; Loading Loading @@ -4536,7 +4577,7 @@ __device__ void convertCorrectTile( i1++; i1++; } } py = centerY - DTT_SIZE - (clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy) ; // fractional top corner // py = centerY - DTT_SIZE - (clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy) ; // fractional top corner int itly = (int) floorf(py +0.5f); int itly = (int) floorf(py +0.5f); int_topleft[1] = itly; int_topleft[1] = itly; Loading Loading @@ -4591,7 +4632,7 @@ __device__ void convertCorrectTile( if (dbg_tile && (threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x) == 0){ printf("COLOR=%d\n",color); printf("COLOR=%d\n",color); printf("centerX=%f, centerY=%f\n",centerX, centerY); printf("centerX=%f, centerY=%f\n",centerX, centerY); printf("ktileX=%d, ktileY=%d\n", ktileX, ktileY); // printf("ktileX=%d, ktileY=%d\n", ktileX, ktileY); printf("kdx=%f, kdy=%f\n", kdx, kdy); printf("kdx=%f, kdy=%f\n", kdx, kdy); printf("int_topleft[%d][0]=%d, int_topleft[%d][1]=%d\n",i,int_topleft[0],i,int_topleft[1]); printf("int_topleft[%d][0]=%d, int_topleft[%d][1]=%d\n",i,int_topleft[0],i,int_topleft[1]); printf("residual_shift[%d][0]=%f, residual_shift[%d][1]=%f\n",i,residual_shift[0],i,residual_shift[1]); printf("residual_shift[%d][0]=%f, residual_shift[%d][1]=%f\n",i,residual_shift[0],i,residual_shift[1]); Loading Loading @@ -4896,27 +4937,31 @@ __device__ void convertCorrectTile( } // else { // if (is_mono) { } // else { // if (is_mono) { #ifdef DEBUG30 #ifdef DEBUG30 if (dbg_tile && (threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after before convolving, color = %d\n",color); printf("\nDTT Tiles after before convolving, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); debug_print_clt1(clt_tile, color, 0xf); } } __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #endif #endif if (gpu_kernels) { // convolve first, then rotate to match Java and make it easier to verify // convolve first, then rotate to match Java and make it easier to verify // verify it works w/o kernels convolveTiles( convolveTiles( clt_tile, // float clt_tile [4][DTT_SIZE][DTT_SIZE1], // 4 quadrants of the clt data, rows extended to optimize shared ports clt_tile, // float clt_tile [4][DTT_SIZE][DTT_SIZE1], // 4 quadrants of the clt data, rows extended to optimize shared ports clt_kernels); // float kernel [4][DTT_SIZE][DTT_SIZE1]); // 4 quadrants of the CLT kernel (DTT3 converted) clt_kernels); // float kernel [4][DTT_SIZE][DTT_SIZE1]); // 4 quadrants of the CLT kernel (DTT3 converted) __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #ifdef DEBUG2 #ifdef DEBUG30 if ((threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after convolution, color = %d\n",color); printf("\nDTT Tiles after convolution, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); // all colors, all quadrants debug_print_clt1(clt_tile, color, 0xf); // all colors, all quadrants } } __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #endif #endif } // rotate phases: first horizontal, then vertical // rotate phases: first horizontal, then vertical shiftTileHor( shiftTileHor( Loading Loading @@ -4947,8 +4992,8 @@ __device__ void convertCorrectTile( #ifdef DBG_TILE #ifdef DBG_TILE #ifdef DEBUG3 #ifdef DEBUG30 if ((threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after vertical shift, color = %d\n",color); printf("\nDTT Tiles after vertical shift, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); // only 1 quadrant for R,B and 2 - for G debug_print_clt1(clt_tile, color, 0xf); // only 1 quadrant for R,B and 2 - for G printf("\nDTT All done\n"); printf("\nDTT All done\n"); Loading src/test_tp.cu +10 −6 Original line number Original line Diff line number Diff line Loading @@ -30,13 +30,17 @@ ** -----------------------------------------------------------------------------** ** -----------------------------------------------------------------------------** */ */ // #define NOCORR // all of the next 5 were disabled // #define NOCORR_TD #define NOCORR // #define NOTEXTURES #define NOCORR_TD // #define NOTEXTURE_RGBA #define NOTEXTURES #define NOTEXTURE_RGBA #define NOTEXTURE_RGBAXXX #define SAVE_CLT #define SAVE_CLT #define NO_DP #define NO_DP #define CORR_INTER_SELF 1 /// #define CORR_INTER_SELF 1 #include <stdio.h> #include <stdio.h> Loading Loading @@ -1442,7 +1446,7 @@ int main(int argc, char **argv) 0, // int lpf_mask) // apply lpf to colors : bit 0 - red, bit 1 - blue, bit2 - green 0, // int lpf_mask) // apply lpf to colors : bit 0 - red, bit 1 - blue, bit2 - green IMG_WIDTH, // int woi_width, IMG_WIDTH, // int woi_width, IMG_HEIGHT, // int woi_height, IMG_HEIGHT, // int woi_height, KERNELS_HOR, // int kernels_hor, 0, // KERNELS_HOR, // int kernels_hor, KERNELS_VERT, // int kernels_vert); KERNELS_VERT, // int kernels_vert); gpu_active_tiles, // int * gpu_active_tiles, // pointer to the calculated number of non-zero tiles gpu_active_tiles, // int * gpu_active_tiles, // pointer to the calculated number of non-zero tiles gpu_num_active, //); // int * pnum_active_tiles); // indices to gpu_tasks gpu_num_active, //); // int * pnum_active_tiles); // indices to gpu_tasks Loading src/tp_defines.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -147,7 +147,7 @@ //#define DEBUG20 1 // Geometry Correction //#define DEBUG20 1 // Geometry Correction //#define DEBUG21 1 // Geometry Correction //#define DEBUG21 1 // Geometry Correction //#define DEBUG210 1 //#define DEBUG210 1 ////#define DEBUG30 1 #define DEBUG30 1 //#define DEBUG22 1 //#define DEBUG22 1 //#define DEBUG23 1 //#define DEBUG23 1 Loading Loading
src/TileProcessor.cuh +167 −122 Original line number Original line Diff line number Diff line Loading @@ -1010,7 +1010,7 @@ extern "C" __global__ void correlate2D( /** /** * Calculate 2D phase correlation pairs from CLT representation. This is an outer kernel that calls other * Calculate 2D phase correlation pairs from CLT representation. This is an outer kernel that calls other * ones with CDP, this one should be configured as correlate2D<<<1,1>>> * ones with CDP, this one should be configured as correlate2D<<<1,1>>> * * gpu_corr_indices will include sums * @param num_cams number of cameras <= NUM_CAMS * @param num_cams number of cameras <= NUM_CAMS * @param sel_pairs array of length to accommodate all pairs (4 for 16 cameras, 120 pairs). * @param sel_pairs array of length to accommodate all pairs (4 for 16 cameras, 120 pairs). * @param gpu_clt array of num_cams pointers to the CLT (frequency domain) data [TILES-Y][TILES-X][NUM_COLORS][DTT_SIZE*DTT_SIZE] * @param gpu_clt array of num_cams pointers to the CLT (frequency domain) data [TILES-Y][TILES-X][NUM_COLORS][DTT_SIZE*DTT_SIZE] Loading Loading @@ -2660,7 +2660,7 @@ __global__ void index_correlate( * Helper kernel for correlateInter2D() - generates dense list of correlation tasks. * Helper kernel for correlateInter2D() - generates dense list of correlation tasks. * For interscene correlation. One correlation output for each selected sensor * For interscene correlation. One correlation output for each selected sensor * plus a sum of them all. So for all 16 sensors selected ooutput will have 17 * plus a sum of them all. So for all 16 sensors selected ooutput will have 17 * 2D correlations (with some being the l;ast one) * 2D correlations (with sum being the last one) * All pairs for the same tile will always be in the same order: increasing sensor numbers * All pairs for the same tile will always be in the same order: increasing sensor numbers * with sum being the last. Sum will be marked by 0xff in the LSB. * with sum being the last. Sum will be marked by 0xff in the LSB. * With the quad camera each tile may generate up to 6 pairs (int array elements) * With the quad camera each tile may generate up to 6 pairs (int array elements) Loading Loading @@ -2770,8 +2770,8 @@ extern "C" __global__ void convert_direct( // called with a single block, singl convert_correct_tiles<<<grid_tp,threads_tp>>>( convert_correct_tiles<<<grid_tp,threads_tp>>>( num_cams, // int num_cams, // actual number of cameras num_cams, // int num_cams, // actual number of cameras num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono gpu_kernel_offsets, // float ** gpu_kernel_offsets, // [num_cams], ((kernels_hor>0)?gpu_kernel_offsets:0), // float ** gpu_kernel_offsets, // [num_cams], gpu_kernels, // float ** gpu_kernels, // [num_cams], ((kernels_hor>0)?gpu_kernels:0), // float ** gpu_kernels, // [num_cams], gpu_images, // float ** gpu_images, // [num_cams], gpu_images, // float ** gpu_images, // [num_cams], gpu_ftasks, // float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 gpu_ftasks, // float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 gpu_active_tiles, // int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles gpu_active_tiles, // int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles Loading Loading @@ -2862,8 +2862,8 @@ extern "C" __global__ void erase_clt_tiles_inner( __global__ void convert_correct_tiles( __global__ void convert_correct_tiles( int num_cams, // actual number of cameras int num_cams, // actual number of cameras int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono float ** gpu_kernel_offsets, // [num_cams], float ** gpu_kernel_offsets, // [num_cams], ### float ** gpu_kernels, // [num_cams], float ** gpu_kernels, // [num_cams], ### float ** gpu_images, // [num_cams], float ** gpu_images, // [num_cams], float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16 int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles int * gpu_active_tiles, // indices in gpu_tasks to non-zero tiles Loading Loading @@ -2929,6 +2929,7 @@ __global__ void convert_correct_tiles( // process each camera,l each color in series (to reduce shared memory) // process each camera,l each color in series (to reduce shared memory) for (int ncam = 0; ncam < num_cams; ncam++){ for (int ncam = 0; ncam < num_cams; ncam++){ for (int color = 0; color < num_colors; color++){ for (int color = 0; color < num_colors; color++){ if (gpu_kernels) { convertCorrectTile( convertCorrectTile( // TODO: remove debug when done // TODO: remove debug when done #ifdef DBG_TILE #ifdef DBG_TILE Loading @@ -2936,8 +2937,8 @@ __global__ void convert_correct_tiles( #else #else num_colors, // int num_colors, //* num_colors, // int num_colors, //* #endif #endif (struct CltExtra*)(gpu_kernel_offsets[ncam]), // struct CltExtra* gpu_kernel_offsets, (struct CltExtra*)(gpu_kernel_offsets[ncam]), // struct CltExtra* gpu_kernel_offsets, #### gpu_kernels[ncam], // float * gpu_kernels, gpu_kernels[ncam], // float * gpu_kernels, #### gpu_images[ncam], // float * gpu_images, gpu_images[ncam], // float * gpu_images, gpu_clt[ncam], // float * gpu_clt, gpu_clt[ncam], // float * gpu_clt, color, // const int color, color, // const int color, Loading @@ -2960,6 +2961,39 @@ __global__ void convert_correct_tiles( kernels_hor, // int kernels_hor, kernels_hor, // int kernels_hor, kernels_vert, //int kernels_vert) kernels_vert, //int kernels_vert) tilesx); // int tilesx); tilesx); // int tilesx); } else { convertCorrectTile( // TODO: remove debug when done #ifdef DBG_TILE num_colors + (((task_num == DBG_TILE)&& (ncam == 0)) ? 16:0), // int num_colors, //* #else num_colors, // int num_colors, //* #endif (struct CltExtra*) 0, // struct CltExtra* gpu_kernel_offsets, #### (float*) 0, // float * gpu_kernels, #### gpu_images[ncam], // float * gpu_images, gpu_clt[ncam], // float * gpu_clt, color, // const int color, lpf_mask, // const int lpf_mask, tt[tile_in_block].xy[ncam][0], // const float centerX, tt[tile_in_block].xy[ncam][1], // const float centerY, tt[tile_in_block].txy, // const int txy, tt[tile_in_block].scale, // const float tscale, dstride, // size_t dstride, // in floats (pixels) (float * )(clt_tile [tile_in_block]), // float clt_tile [TILES_PER_BLOCK][NUM_CAMS][num_colors][4][DTT_SIZE][DTT_SIZE]) (float * )(clt_kernels[tile_in_block]), // float clt_tile [num_colors][4][DTT_SIZE][DTT_SIZE], int_topleft[tile_in_block], // int int_topleft [num_colors][2], residual_shift[tile_in_block], // float frac_topleft [num_colors][2], window_hor_cos[tile_in_block], // float window_hor_cos [num_colors][2*DTT_SIZE], window_hor_sin[tile_in_block], // float window_hor_sin [num_colors][2*DTT_SIZE], window_vert_cos[tile_in_block], // float window_vert_cos [num_colors][2*DTT_SIZE]); window_vert_sin[tile_in_block], // float window_vert_sin [num_colors][2*DTT_SIZE]); woi_width, // int woi_width, woi_height, // int woi_height, 0, // kernels_hor, // int kernels_hor, 0, // kernels_vert, //int kernels_vert) tilesx); // int tilesx); } __syncthreads(); __syncthreads(); } } } } Loading Loading @@ -4394,8 +4428,8 @@ __device__ void normalizeTileAmplitude( */ */ __device__ void convertCorrectTile( __device__ void convertCorrectTile( int num_colors, //* int num_colors, //* struct CltExtra * gpu_kernel_offsets, // [tileY][tileX][color] struct CltExtra * gpu_kernel_offsets, // [tileY][tileX][color] if null, will not calculate kernel-related offsets float * gpu_kernels, // [tileY][tileX][color] float * gpu_kernels, // [tileY][tileX][color] // null w/o kernels float * gpu_images, float * gpu_images, float * gpu_clt, float * gpu_clt, const int color, const int color, Loading @@ -4406,7 +4440,7 @@ __device__ void convertCorrectTile( const float tscale, const float tscale, const size_t dstride, // in floats (pixels) const size_t dstride, // in floats (pixels) float * clt_tile, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_tile, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_kernels, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports float * clt_kernels, // [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports // null w/o kernels int int_topleft [2], int int_topleft [2], float residual_shift [2], float residual_shift [2], float window_hor_cos [2*DTT_SIZE], float window_hor_cos [2*DTT_SIZE], Loading @@ -4430,12 +4464,12 @@ __device__ void convertCorrectTile( int max_py = woi_height - 1; // IMG-HEIGHT - 1; // odd int max_py = woi_height - 1; // IMG-HEIGHT - 1; // odd int max_pxm1 = max_px - 1; // even int max_pxm1 = max_px - 1; // even int max_pym1 = max_py - 1; // even int max_pym1 = max_py - 1; // even int max_kernel_hor = kernels_hor - 1; // KERNELS_HOR -1; int max_kernel_vert = kernels_vert - 1; // KERNELS_VERT-1; int ktileX, ktileY; int kernel_index; // common for all coors int kernel_index; // common for all coors float kdx, kdy; float kdx, kdy; if (gpu_kernels) { int ktileX, ktileY; int max_kernel_hor = kernels_hor - 1; // KERNELS_HOR -1; int max_kernel_vert = kernels_vert - 1; // KERNELS_VERT-1; if (threadIdx.x == 0){ if (threadIdx.x == 0){ // ktileX = min(max_kernel_hor, max(0, ((int) lrintf(centerX * (1.0/KERNELS_STEP)+1)))); // ktileX = min(max_kernel_hor, max(0, ((int) lrintf(centerX * (1.0/KERNELS_STEP)+1)))); // ktileY = min(max_kernel_vert, max(0, ((int) lrintf(centerY * (1.0/KERNELS_STEP)+1)))); // ktileY = min(max_kernel_vert, max(0, ((int) lrintf(centerY * (1.0/KERNELS_STEP)+1)))); Loading Loading @@ -4480,14 +4514,15 @@ __device__ void convertCorrectTile( kdy, // T var, kdy, // T var, 0, // int srcLane, 0, // int srcLane, THREADS_PER_TILE); // int width=warpSize); THREADS_PER_TILE); // int width=warpSize); __syncthreads();// __syncwarp(); // is it needed? __syncthreads();// __syncwarp(); // is it needed? } float px, py; float px, py; int kernel_full_index; if (gpu_kernels) { // only copy kernels if they exist // copy kernel // copy kernel int kernel_full_index = kernel_index + color; kernel_full_index = kernel_index + color; float * kernel_src = gpu_kernels + kernel_full_index* (DTT_SIZE * DTT_SIZE * 4); float * kernel_src = gpu_kernels + kernel_full_index* (DTT_SIZE * DTT_SIZE * 4); float * kernelp = clt_kernels; float * kernelp = clt_kernels; kernel_src += threadIdx.x; // lsb; kernel_src += threadIdx.x; // lsb; kernelp += threadIdx.x; // lsb; kernelp += threadIdx.x; // lsb; #pragma unroll #pragma unroll Loading @@ -4497,11 +4532,17 @@ __device__ void convertCorrectTile( kernelp+=DTT_SIZE1; kernelp+=DTT_SIZE1; kernel_src+=THREADSX; kernel_src+=THREADSX; } } } // Calculate offsets and prepare windows (all colors): px = centerX - DTT_SIZE; // fractional left corner (w/o kernel) py = centerY - DTT_SIZE; // fractional top corner (w/o kernel) if (gpu_kernel_offsets){ // adding no-kernel version with rectilinear images struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; px -= clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy ; px = centerX - DTT_SIZE - (clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy) ; // fractional left corner py -= clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy ; } // Calculate offsets and prepare windows (all colors): // struct CltExtra * clt_extra = &gpu_kernel_offsets[kernel_full_index]; // px = centerX - DTT_SIZE - (clt_extra->data_x + clt_extra->dxc_dx * kdx + clt_extra->dxc_dy * kdy) ; // fractional left corner int itlx = (int) floorf(px +0.5f); int itlx = (int) floorf(px +0.5f); int_topleft [0] = itlx; int_topleft [0] = itlx; float shift_hor = itlx - px; float shift_hor = itlx - px; Loading Loading @@ -4536,7 +4577,7 @@ __device__ void convertCorrectTile( i1++; i1++; } } py = centerY - DTT_SIZE - (clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy) ; // fractional top corner // py = centerY - DTT_SIZE - (clt_extra->data_y + clt_extra->dyc_dx * kdx + clt_extra->dyc_dy * kdy) ; // fractional top corner int itly = (int) floorf(py +0.5f); int itly = (int) floorf(py +0.5f); int_topleft[1] = itly; int_topleft[1] = itly; Loading Loading @@ -4591,7 +4632,7 @@ __device__ void convertCorrectTile( if (dbg_tile && (threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x) == 0){ printf("COLOR=%d\n",color); printf("COLOR=%d\n",color); printf("centerX=%f, centerY=%f\n",centerX, centerY); printf("centerX=%f, centerY=%f\n",centerX, centerY); printf("ktileX=%d, ktileY=%d\n", ktileX, ktileY); // printf("ktileX=%d, ktileY=%d\n", ktileX, ktileY); printf("kdx=%f, kdy=%f\n", kdx, kdy); printf("kdx=%f, kdy=%f\n", kdx, kdy); printf("int_topleft[%d][0]=%d, int_topleft[%d][1]=%d\n",i,int_topleft[0],i,int_topleft[1]); printf("int_topleft[%d][0]=%d, int_topleft[%d][1]=%d\n",i,int_topleft[0],i,int_topleft[1]); printf("residual_shift[%d][0]=%f, residual_shift[%d][1]=%f\n",i,residual_shift[0],i,residual_shift[1]); printf("residual_shift[%d][0]=%f, residual_shift[%d][1]=%f\n",i,residual_shift[0],i,residual_shift[1]); Loading Loading @@ -4896,27 +4937,31 @@ __device__ void convertCorrectTile( } // else { // if (is_mono) { } // else { // if (is_mono) { #ifdef DEBUG30 #ifdef DEBUG30 if (dbg_tile && (threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after before convolving, color = %d\n",color); printf("\nDTT Tiles after before convolving, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); debug_print_clt1(clt_tile, color, 0xf); } } __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #endif #endif if (gpu_kernels) { // convolve first, then rotate to match Java and make it easier to verify // convolve first, then rotate to match Java and make it easier to verify // verify it works w/o kernels convolveTiles( convolveTiles( clt_tile, // float clt_tile [4][DTT_SIZE][DTT_SIZE1], // 4 quadrants of the clt data, rows extended to optimize shared ports clt_tile, // float clt_tile [4][DTT_SIZE][DTT_SIZE1], // 4 quadrants of the clt data, rows extended to optimize shared ports clt_kernels); // float kernel [4][DTT_SIZE][DTT_SIZE1]); // 4 quadrants of the CLT kernel (DTT3 converted) clt_kernels); // float kernel [4][DTT_SIZE][DTT_SIZE1]); // 4 quadrants of the CLT kernel (DTT3 converted) __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #ifdef DEBUG2 #ifdef DEBUG30 if ((threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after convolution, color = %d\n",color); printf("\nDTT Tiles after convolution, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); // all colors, all quadrants debug_print_clt1(clt_tile, color, 0xf); // all colors, all quadrants } } __syncthreads();// __syncwarp(); __syncthreads();// __syncwarp(); #endif #endif } // rotate phases: first horizontal, then vertical // rotate phases: first horizontal, then vertical shiftTileHor( shiftTileHor( Loading Loading @@ -4947,8 +4992,8 @@ __device__ void convertCorrectTile( #ifdef DBG_TILE #ifdef DBG_TILE #ifdef DEBUG3 #ifdef DEBUG30 if ((threadIdx.x) == 0){ if (dbg_tile && (threadIdx.x == 0)){ printf("\nDTT Tiles after vertical shift, color = %d\n",color); printf("\nDTT Tiles after vertical shift, color = %d\n",color); debug_print_clt1(clt_tile, color, 0xf); // only 1 quadrant for R,B and 2 - for G debug_print_clt1(clt_tile, color, 0xf); // only 1 quadrant for R,B and 2 - for G printf("\nDTT All done\n"); printf("\nDTT All done\n"); Loading
src/test_tp.cu +10 −6 Original line number Original line Diff line number Diff line Loading @@ -30,13 +30,17 @@ ** -----------------------------------------------------------------------------** ** -----------------------------------------------------------------------------** */ */ // #define NOCORR // all of the next 5 were disabled // #define NOCORR_TD #define NOCORR // #define NOTEXTURES #define NOCORR_TD // #define NOTEXTURE_RGBA #define NOTEXTURES #define NOTEXTURE_RGBA #define NOTEXTURE_RGBAXXX #define SAVE_CLT #define SAVE_CLT #define NO_DP #define NO_DP #define CORR_INTER_SELF 1 /// #define CORR_INTER_SELF 1 #include <stdio.h> #include <stdio.h> Loading Loading @@ -1442,7 +1446,7 @@ int main(int argc, char **argv) 0, // int lpf_mask) // apply lpf to colors : bit 0 - red, bit 1 - blue, bit2 - green 0, // int lpf_mask) // apply lpf to colors : bit 0 - red, bit 1 - blue, bit2 - green IMG_WIDTH, // int woi_width, IMG_WIDTH, // int woi_width, IMG_HEIGHT, // int woi_height, IMG_HEIGHT, // int woi_height, KERNELS_HOR, // int kernels_hor, 0, // KERNELS_HOR, // int kernels_hor, KERNELS_VERT, // int kernels_vert); KERNELS_VERT, // int kernels_vert); gpu_active_tiles, // int * gpu_active_tiles, // pointer to the calculated number of non-zero tiles gpu_active_tiles, // int * gpu_active_tiles, // pointer to the calculated number of non-zero tiles gpu_num_active, //); // int * pnum_active_tiles); // indices to gpu_tasks gpu_num_active, //); // int * pnum_active_tiles); // indices to gpu_tasks Loading
src/tp_defines.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -147,7 +147,7 @@ //#define DEBUG20 1 // Geometry Correction //#define DEBUG20 1 // Geometry Correction //#define DEBUG21 1 // Geometry Correction //#define DEBUG21 1 // Geometry Correction //#define DEBUG210 1 //#define DEBUG210 1 ////#define DEBUG30 1 #define DEBUG30 1 //#define DEBUG22 1 //#define DEBUG22 1 //#define DEBUG23 1 //#define DEBUG23 1 Loading