Commit 6c76931e authored by Palani Johnson's avatar Palani Johnson
Browse files

ran formatter

parent 4648cb20
Loading
Loading
Loading
Loading
+3697 −3819

File changed.

Preview size limit exceeded, changes collapsed.

+133 −128
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
#include "tp_defines.h"
#endif


extern "C" __global__ void convert_direct(  // called with a single block, single thread
                                            //		struct CltExtra ** gpu_kernel_offsets, // [NUM_CAMS], // changed for jcuda to avoid struct parameters
    int num_cams,                           // actual number of cameras
@@ -133,8 +132,7 @@ extern "C" __global__ void textures_nonoverlap(
    float* gpu_diff_rgb_combo,  //); // diff[NUM_CAMS], R[NUM_CAMS], B[NUM_CAMS],G[NUM_CAMS] // may be 0 if not needed
    int num_tilesx);

extern "C"
__global__ void imclt_rbg_all(
extern "C" __global__ void imclt_rbg_all(
    int num_cams,
    float** gpu_clt,          // [NUM_CAMS][TILES-Y][TILES-X][NUM_COLORS][DTT_SIZE*DTT_SIZE]
    float** gpu_corr_images,  // [NUM_CAMS][WIDTH, 3 * HEIGHT]
@@ -185,3 +183,10 @@ extern "C" __global__ void generate_RBGA(
    const size_t texture_rbga_stride,  // in floats
    float* gpu_texture_tiles);         // (number of colors +1 + ?)*16*16 rgba texture tiles

extern "C" __global__ void accumulate_correlations(
    int tilesY,
    int tilesX,
    int pairs,
    float* num_acc,        // number of accumulated tiles [tilesY][tilesX][pair]
    float* fcorr_td,       // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
    float* fcorr_td_acc);  // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
+980 −1019
Original line number Diff line number Diff line
@@ -84,27 +84,25 @@ __constant__ float idct_signs[4][4][4] ={
     {1, -1, -1, -1},
     {-1, 1, 1, 1},
     {-1, 1, 1, 1},
				{-1, 1, 1, 1}
		},{ // quadrant 1, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {-1, 1, 1, 1}},
    {// quadrant 1, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {1, 1, 1, -1},
     {-1, -1, -1, 1},
     {-1, -1, -1, 1},
				{-1,-1,-1, 1}
		},{ // quadrant 2, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {-1, -1, -1, 1}},
    {// quadrant 2, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {1, -1, -1, -1},
     {1, -1, -1, -1},
     {1, -1, -1, -1},
				{-1, 1, 1, 1}
		},{ // quadrant 3, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {-1, 1, 1, 1}},
    {// quadrant 3, each elements corresponds to 4x4 pixel output, covering altogether 16x16
     {1, 1, 1, -1},
     {1, 1, 1, -1},
     {1, 1, 1, -1},
				{-1,-1,-1, 1}
		}};
     {-1, -1, -1, 1}}};
__constant__ float HWINDOW2[] = {0.049009f, 0.145142f, 0.235698f, 0.317197f,
                                 0.386505f, 0.440961f, 0.478470f, 0.497592f};


inline __device__ void dttii_shared_mem_nonortho(float *x0, int inc, int dst_not_dct);  // does not scale by y[0] (y[7]) by 1/sqrt[0]
inline __device__ void dttii_shared_mem(float *x0, int inc, int dst_not_dct);           // used in GPU_DTT24_DRV
inline __device__ void dttiv_shared_mem(float *x0, int inc, int dst_not_dct);           // used in GPU_DTT24_DRV
@@ -118,7 +116,6 @@ inline __device__ void dst_iv8 ( float x[8], float y[8]); // x,y point t
inline __device__ void _dctii_nrecurs8(float x[8], float y[8]);  // x,y point to 8-element arrays each // not used
inline __device__ void _dctiv_nrecurs8(float x[8], float y[8]);  // x,y point to 8-element arrays each // not used


/**
**************************************************************************
*  Converts 2D image (in the GPU memory) using 8x8 DTT 8x8 tiles.
@@ -140,9 +137,7 @@ inline __device__ void _dctiv_nrecurs8 ( float x[8], float y[8]); // x,y point t
* \return None
*/
#ifdef BBBB
extern "C"
__global__ void GPU_DTT24_DRV(float *dst, float *src, int src_stride, int dtt_mode)
{
extern "C" __global__ void GPU_DTT24_DRV(float *dst, float *src, int src_stride, int dtt_mode) {
    int dtt_mode0 = dtt_mode & 1;
    int dtt_mode1 = (dtt_mode >> 1) & 1;

@@ -180,8 +175,6 @@ __global__ void GPU_DTT24_DRV(float *dst, float *src, int src_stride, int dtt_mo
}
#endif  //#ifdef BBBB



inline __device__ void _dctiv_nrecurs8(float x[8], float y[8])  // x,y point to 8-element arrays each
{
    float u00 = (COSN2[0] * x[0] + SINN2[0] * x[7]);
@@ -224,7 +217,6 @@ inline __device__ void _dctiv_nrecurs8( float x[8], float y[8]) // x,y point to
    float vb10 = COSPI_1_8_SQRT2 * ub10 + COSPI_3_8_SQRT2 * ub11;
    float vb11 = COSPI_3_8_SQRT2 * ub10 - COSPI_1_8_SQRT2 * ub11;


    y[0] = SQRT_2 * v00;  // w0[0];
    y[1] = v01 - vb11;    // w1[0];
    // j == 1
@@ -239,8 +231,7 @@ inline __device__ void _dctiv_nrecurs8( float x[8], float y[8]) // x,y point to
}

__device__ void _dttiv(float x0, float x1, float x2, float x3, float x4, float x5, float x6, float x7,
		float *y0, float *y1, float *y2, float *y3, float *y4, float *y5, float *y6, float *y7, int dst_not_dct)
{
                       float *y0, float *y1, float *y2, float *y3, float *y4, float *y5, float *y6, float *y7, int dst_not_dct) {
    float u00, u01, u02, u03, u10, u11, u12, u13;
    if (dst_not_dct) {  // DSTIV
        u00 = (COSN2[0] * x7 + SINN2[0] * x0);
@@ -316,8 +307,7 @@ __device__ void _dttiv(float x0, float x1,float x2, float x3,float x4, float x5,
    }
}

inline __device__ void dttii_shared_mem(float * x0,  int inc, int dst_not_dct)
{
inline __device__ void dttii_shared_mem(float *x0, int inc, int dst_not_dct) {
    float *x1 = x0 + inc;
    float *x2 = x1 + inc;
    float *x3 = x2 + inc;
@@ -399,8 +389,7 @@ inline __device__ void dttii_shared_mem(float * x0, int inc, int dst_not_dct)
    }
}

inline __device__ void dttii_shared_mem_nonortho(float * x0,  int inc, int dst_not_dct)
{
inline __device__ void dttii_shared_mem_nonortho(float *x0, int inc, int dst_not_dct) {
    float *x1 = x0 + inc;
    float *x2 = x1 + inc;
    float *x3 = x2 + inc;
@@ -482,8 +471,7 @@ inline __device__ void dttii_shared_mem_nonortho(float * x0, int inc, int dst_n
    }
}

inline __device__ void dttiv_shared_mem(float * x0,  int inc, int dst_not_dct)
{
inline __device__ void dttiv_shared_mem(float *x0, int inc, int dst_not_dct) {
    float *x1 = x0 + inc;
    float *x2 = x1 + inc;
    float *x3 = x2 + inc;
@@ -546,7 +534,6 @@ inline __device__ void dttiv_shared_mem(float * x0, int inc, int dst_not_dct)
    float vb10 = COSPI_1_8_SQRT2 * ub10 + COSPI_3_8_SQRT2 * ub11;
    float vb11 = COSPI_3_8_SQRT2 * ub10 - COSPI_1_8_SQRT2 * ub11;


    *x0 = v00 * 0.5f;                   // w0[0];
    *x2 = (v01 + vb11) * SQRT1_8;       // w0[1];
    *x4 = (v02 - vb01) * SQRT1_8;       // w0[2];
@@ -564,8 +551,7 @@ inline __device__ void dttiv_shared_mem(float * x0, int inc, int dst_not_dct)
    }
}

inline __device__ void dttiv_nodiverg(float * x,  int inc, int dst_not_dct)
{
inline __device__ void dttiv_nodiverg(float *x, int inc, int dst_not_dct) {
    float sgn = 1 - 2 * dst_not_dct;
    float *y0 = x;
    float *y1 = y0 + inc;
@@ -627,7 +613,6 @@ inline __device__ void dttiv_nodiverg(float * x, int inc, int dst_not_dct)
    float vb10 = COSPI_1_8_SQRT2 * ub10 + COSPI_3_8_SQRT2 * ub11;
    float vb11 = COSPI_3_8_SQRT2 * ub10 - COSPI_1_8_SQRT2 * ub11;


    *y0 = v00 * 0.5f;                    // w0[0];
    *y2 = (v01 + vb11) * SQRT1_8;        // w0[1];
    *y4 = (v02 - vb01) * SQRT1_8;        // w0[2];
@@ -638,8 +623,7 @@ inline __device__ void dttiv_nodiverg(float * x, int inc, int dst_not_dct)
    *y7 = sgn * vb00 * 0.5f;             // w1[3];
}

inline __device__ void dctiv_nodiverg(float * x0,  int inc)
{
inline __device__ void dctiv_nodiverg(float *x0, int inc) {
    float *x1 = x0 + inc;
    float *x2 = x1 + inc;
    float *x3 = x2 + inc;
@@ -688,7 +672,6 @@ inline __device__ void dctiv_nodiverg(float * x0, int inc)
    float vb10 = COSPI_1_8_SQRT2 * ub10 + COSPI_3_8_SQRT2 * ub11;
    float vb11 = COSPI_3_8_SQRT2 * ub10 - COSPI_1_8_SQRT2 * ub11;


    *x0 = v00 * 0.5f;              // w0[0];
    *x2 = (v01 + vb11) * SQRT1_8;  // w0[1];
    *x4 = (v02 - vb01) * SQRT1_8;  // w0[2];
@@ -699,8 +682,7 @@ inline __device__ void dctiv_nodiverg(float * x0, int inc)
    *x7 = vb00 * 0.5f;             // w1[3];
}

inline __device__ void dstiv_nodiverg(float * x,  int inc)
{
inline __device__ void dstiv_nodiverg(float *x, int inc) {
    float *x0 = x + 7 * inc;
    // negate inc, replace
    inc = -inc;
@@ -752,7 +734,6 @@ inline __device__ void dstiv_nodiverg(float * x, int inc)
    float vb10 = COSPI_1_8_SQRT2 * ub10 + COSPI_3_8_SQRT2 * ub11;
    float vb11 = COSPI_3_8_SQRT2 * ub10 - COSPI_1_8_SQRT2 * ub11;


    *x7 = v00 * 0.5f;              // w0[0];
    *x5 = (v01 + vb11) * SQRT1_8;  // w0[1];
    *x3 = (v02 - vb01) * SQRT1_8;  // w0[2];
@@ -764,8 +745,6 @@ inline __device__ void dstiv_nodiverg(float * x, int inc)
    *x0 = -vb00 * 0.5f;             // w1[3];
}



inline __device__ void _dctii_nrecurs8(float x[8], float y[8])  // x,y point to 8-element arrays each
{
    float u00 = (x[0] + x[7]);
@@ -836,7 +815,6 @@ inline __device__ void dct_ii8( float x[8], float y[8]) // x,y point to 8-eleme
    }
}


__device__ void dct_iv8(float x[8], float y[8])  // x,y point to 8-element arrays each
{
    _dctiv_nrecurs8(x, y);
@@ -844,7 +822,6 @@ __device__ void dct_iv8( float x[8], float y[8]) // x,y point to 8-element array
    for (int i = 0; i < 8; i++) {
        y[i] *= SQRT1_8;
    }

}

inline __device__ void dst_iv8(float x[8], float y[8])  // x,y point to 8-element arrays each
@@ -862,7 +839,6 @@ inline __device__ void dst_iv8( float x[8], float y[8]) // x,y point to 8-elemen
    }
}


//=========================== 2D functions ===============
__device__ void corrUnfoldTile(
    int corr_radius,
@@ -895,11 +871,9 @@ __device__ void corrUnfoldTile(
    for (int j = 1; j <= corr_radius; j++) {
        int rslt_base_index_pp = rslt_base_index_p + j;
        int rslt_base_index_pm = rslt_base_index_p - j;
		rslt[rslt_base_index_pp] = corr_pixscale * (
				 qdata0[i_transform_size + j] +
        rslt[rslt_base_index_pp] = corr_pixscale * (qdata0[i_transform_size + j] +
                                                    qdata1[i_transform_size + j - 1]);  // incomplete, will only be used for thread i=0
		rslt[rslt_base_index_pm] = corr_pixscale * (
				 qdata0[i_transform_size + j] +
        rslt[rslt_base_index_pm] = corr_pixscale * (qdata0[i_transform_size + j] +
                                                    -qdata1[i_transform_size + j - 1]);  // incomplete, will only be used for thread i=0
    }
    if (i == 0) {
@@ -941,13 +915,11 @@ __device__ void dttii_2d(
        dttii_shared_mem_nonortho(clt_corr + (q * DTT_SIZE + threadIdx.x) * DTT_SIZE1, 1, is_sin);  // horizontal pass, tread is row
    }
    __syncthreads();

}

__device__ void dttiv_color_2d(
    float *clt_tile,
		int color)
{
    int color) {
    dctiv_nodiverg(                            // all colors
        clt_tile + (DTT_SIZE1 * threadIdx.x),  // [0][threadIdx.x], // pointer to start of row
        1);                                    // int inc);
@@ -956,7 +928,6 @@ __device__ void dttiv_color_2d(
        dstiv_nodiverg(                                                 // all colors
            clt_tile + DTT_SIZE1 * threadIdx.x + DTT_SIZE1 * DTT_SIZE,  // clt_tile[1][threadIdx.x], // pointer to start of row
            1);                                                         // int inc);

    }
    __syncthreads();  // __syncwarp();

@@ -980,8 +951,7 @@ __device__ void dttiv_color_2d(
}

__device__ void dttiv_mono_2d(
		float * clt_tile)
{
    float *clt_tile) {
    // Copy 0-> 1

    dctiv_nodiverg(
@@ -1021,8 +991,6 @@ __device__ void dttiv_mono_2d(
    __syncthreads();                                          // __syncwarp();
}



//
// Uses 16 threads, gets 4*8*8 clt tiles, performs idtt-iv (swapping 1 and 2 quadrants) and then unfolds with window,
// adding to the output 16x16 tile (to use Read-modify-write with 4 passes over the frame. Should be zeroed before the
@@ -1077,7 +1045,6 @@ __device__ void imclt(
    __syncthreads();  // __syncwarp();
#endif


    float hw = HWINDOW2[wcolumn];
    int clt_offset = imclt_indx9[column];  // index in each of the 4 iclt quadrants, accounting for stride=9
    float *rslt = mclt_tile + column;
@@ -1161,7 +1128,6 @@ __device__ void imclt(
#endif
}


// Uses 8 threads, gets 4*8*8 clt tiles, performs idtt-iv (swapping 1 and 2 quadrants) and then unfolds to the 16x16
// adding to the output 16x16 tile (to use Read-modify-write with 4 passes over the frame. Should be zeroed before the
// first pass
@@ -1171,8 +1137,7 @@ __device__ void imclt8threads(
    int do_acc,        // 1 - add to previous value, 0 - overwrite
    float *clt_tile,   //        [4][DTT_SIZE][DTT_SIZE1], // +1 to alternate column ports [4][8][9]
    float *mclt_tile,  //           [2* DTT_SIZE][DTT_SIZE1+ DTT_SIZE], // +1 to alternate column ports[16][17]
		int debug)
{
    int debug) {
    //	int thr3 =    threadIdx.x >> 3;
    //	int column =  threadIdx.x; // modify to use 2*8 threads, if needed.
    //	int thr012 =  threadIdx.x & 7;
@@ -1339,8 +1304,4 @@ __device__ void imclt8threads(
#endif
}




//#endif
+29 −30
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@
// extern __constant__ int imclt_indx9[16];
// extern __constant__ float HWINDOW2[];


// kernels (not used so far)
#if 0
extern "C" __global__ void GPU_DTT24_DRV(float *dst, float *src, int src_stride, int dtt_mode);
+825 −812
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@
#define get_task_size(x) (sizeof(struct tp_task) / sizeof(float) - 6 * (NUM_CAMS - x))
#endif


// Using NUM_CAMS threads per tile
#define THREADS_PER_BLOCK_GEOM (TILES_PER_BLOCK_GEOM * NUM_CAMS)
///#define CYCLES_COPY_GC   ((sizeof(struct gc)/sizeof(float) + THREADS_PER_BLOCK_GEOM - 1) / THREADS_PER_BLOCK_GEOM)
@@ -60,7 +59,6 @@
__device__ void printGeometryCorrection(struct gc *g, int num_cams);
__device__ void printExtrinsicCorrection(corr_vector *cv, int num_cams);


/**
 * Calculate non-distorted radius from distorted using table approximation
 * @param rDist distorted radius
@@ -69,41 +67,51 @@ __device__ void printExtrinsicCorrection(corr_vector * cv, int num_cams);
inline __device__ float getRByRDist(float rDist,
                                    float rByRDist[RBYRDIST_LEN]);  // shared memory



__constant__ float ROTS_TEMPLATE[7][3][3][3] = {  //  ...{cos,sin,const}...
		{ // azimuth
    {
        // azimuth
        {{1, 0, 0}, {0, 0, 0}, {0, -1, 0}},
        {{0, 0, 0}, {0, 0, 1}, {0, 0, 0}},
        {{0, 1, 0}, {0, 0, 0}, {1, 0, 0}},

		},{ // tilt
    },
    {
        // tilt
        {{0, 0, 1}, {0, 0, 0}, {0, 0, 0}},
        {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}},
        {{0, 0, 0}, {0, -1, 0}, {1, 0, 0}},
		},{ // roll*zoom
    },
    {
        // roll*zoom
        {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}},
        {{0, -1, 0}, {1, 0, 0}, {0, 0, 0}},
        {{0, 0, 0}, {0, 0, 0}, {0, 0, 1}},

		},{ // d_azimuth
    },
    {
        // d_azimuth
        {{0, -1, 0}, {0, 0, 0}, {-1, 0, 0}},
        {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
        {{1, 0, 0}, {0, 0, 0}, {0, -1, 0}},
		},{ // d_tilt
    },
    {
        // d_tilt
        {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
        {{0, 0, 0}, {0, -1, 0}, {1, 0, 0}},
        {{0, 0, 0}, {-1, 0, 0}, {0, -1, 0}},
		},{ // d_roll
    },
    {
        // d_roll
        {{0, -1, 0}, {1, 0, 0}, {0, 0, 0}},
        {{-1, 0, 0}, {0, -1, 0}, {0, 0, 0}},
        {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
		},{ // d_zoom
    },
    {
        // d_zoom
        {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}},
        {{0, -1, 0}, {1, 0, 0}, {0, 0, 0}},
        {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
		}
};
    }};

__constant__ int angles_offsets[4] = {
    offsetof(corr_vector, azimuth) / sizeof(float),
@@ -115,11 +123,13 @@ __constant__ int mm_seq [3][3][3]={
        {6, 5, 12},  // a_t * a_z -> tmp0
        {7, 6, 13},  // a_r * a_t -> tmp1
        {7, 9, 14},  // a_r * a_dt -> tmp2
		}, {
    },
    {
        {7, 12, 0},  // a_r * tmp0 -> rot          - bad
        {13, 8, 1},  // tmp1 * a_daz -> deriv0     - good
        {14, 5, 2},  // tmp2 * a_az  -> deriv1     - good
		}, {
    },
    {
        {10, 12, 3},  // a_dr * tmp0 -> deriv2     - good
        {11, 12, 4},  // a_dzoom * tnmp0 -> deriv3 - good
        {-1, -1, -1}  // do nothing
@@ -145,7 +155,6 @@ inline __device__ int get_task_txy_gc(int num_tile, float * gpu_ftasks, int num_
    return *(int *)(gpu_ftasks + get_task_size(num_cams) * num_tile + 1);
}


/**
 * Calculate rotation matrices and derivatives by az, tilt, roll, zoom
 * NUM_CAMS blocks of 3,3,3 tiles
@@ -153,8 +162,7 @@ inline __device__ int get_task_txy_gc(int num_tile, float * gpu_ftasks, int num_
extern "C" __global__ void calc_rot_deriv(
    int num_cams,
    struct corr_vector *gpu_correction_vector,
		trot_deriv   * gpu_rot_deriv)
{
    trot_deriv *gpu_rot_deriv) {
    __shared__ float sincos[4][2];  // {az,tilt,roll, d_az, d_tilt, d_roll, d_az}{cos,sin}
    __shared__ float matrices[5 + 7 + 4][3][3];
    float angle;
@@ -203,8 +211,6 @@ extern "C" __global__ void calc_rot_deriv(
    __syncthreads();  // __syncwarp();
#endif                // DEBUG20



    // Create 3 3x3 matrices for az, tilt, roll/zoom:
    int axis = offset_matrices + threadIdx.z;  // 0..2
    int const_index = threadIdx.z;             // 0..2
@@ -225,7 +231,6 @@ extern "C" __global__ void calc_rot_deriv(
            ROTS_TEMPLATE[const_index][threadIdx.y][threadIdx.x][0] * sincos[3][0] +  // cos
            ROTS_TEMPLATE[const_index][threadIdx.y][threadIdx.x][1] * sincos[3][1] +  // sin
            ROTS_TEMPLATE[const_index][threadIdx.y][threadIdx.x][2];                  // const

    }
    __syncthreads();

@@ -241,7 +246,6 @@ extern "C" __global__ void calc_rot_deriv(
                }
                printf("\n");
            }

        }
    }
    __syncthreads();  // __syncwarp();
@@ -302,10 +306,8 @@ extern "C" __global__ void calc_rot_deriv(
#endif                // DEBUG20

    // All done - read/verify all arrays

}


extern "C" __global__ void calculate_tiles_offsets(
    int uniform_grid,  //==0: use provided centers (as for interscene) , !=0 calculate uniform grid
    int num_cams,
@@ -315,8 +317,7 @@ extern "C" __global__ void calculate_tiles_offsets(
    struct gc *gpu_geometry_correction,
    struct corr_vector *gpu_correction_vector,
    float *gpu_rByRDist,  // length should match RBYRDIST_LEN
		trot_deriv   * gpu_rot_deriv)
{
    trot_deriv *gpu_rot_deriv) {
    ///	dim3 threads_geom(NUM_CAMS,TILES_PER_BLOCK_GEOM, 1);
    ///	dim3 grid_geom   ((num_tiles+TILES_PER_BLOCK_GEOM-1)/TILES_PER_BLOCK_GEOM, 1, 1);
    int tiles_per_block_geom = NUM_THREADS / num_cams;
@@ -335,14 +336,12 @@ extern "C" __global__ void calculate_tiles_offsets(
            gpu_correction_vector,    //	struct corr_vector * gpu_correction_vector,
            gpu_rByRDist,             //	float *              gpu_rByRDist)      // length should match RBYRDIST_LEN
            gpu_rot_deriv);           // union trot_deriv   * gpu_rot_deriv);

    }
    //	__syncthreads();// __syncwarp();
    //	cudaDeviceSynchronize();
    //	cudaDeviceSynchronize();
}


/*
 * blockDim.x = NUM_CAMS
 * blockDim.y = TILES_PER_BLOCK_GEOM
@@ -357,8 +356,7 @@ extern "C" __global__ void get_tiles_offsets(
    struct gc *gpu_geometry_correction,
    struct corr_vector *gpu_correction_vector,
    float *gpu_rByRDist,  // length should match RBYRDIST_LEN
		trot_deriv *         gpu_rot_deriv)
{
    trot_deriv *gpu_rot_deriv) {
    int task_size = get_task_size(num_cams);
    int task_num = blockIdx.x * blockDim.y + threadIdx.y;  //  blockIdx.x * TILES_PER_BLOCK_GEOM + threadIdx.y
    int thread_xy = blockDim.x * threadIdx.y + threadIdx.x;
@@ -445,8 +443,6 @@ extern "C" __global__ void get_tiles_offsets(
    __syncthreads();  // __syncwarp();
#endif                // DEBUG21



    //		String dbg_s = corr_vector.toString();
    /* Starting with required tile center X, Y and nominal distortion, for each sensor port:
     * 1) unapply common distortion (maybe for different - master camera)
@@ -507,7 +503,6 @@ extern "C" __global__ void get_tiles_offsets(
    float fl_pix = geometry_correction.focalLength / (0.001 * geometry_correction.pixelSize);  // focal length in pixels - this camera
    float ri_scale = 0.001 * geometry_correction.pixelSize / geometry_correction.distortionRadius;


#ifdef DEBUG21
    if ((ncam == DBG_CAM) && (task_num == DBG_TILE)) {
        printf("\nuniform_grid=%d\n", uniform_grid);
@@ -526,7 +521,6 @@ extern "C" __global__ void get_tiles_offsets(
    __syncthreads();  // __syncwarp();
#endif                // DEBUG21


    // above is common code, below - per camera (was cycle in Java, here individual threads //for (int ncam = 0; ncam < NUM_CAMS; ncam++){
    // non-distorted XY of the shifted location of the individual sensor

@@ -760,7 +754,6 @@ extern "C" __global__ void get_tiles_offsets(
            }
            __syncthreads();  // __syncwarp();
#endif                        // DEBUG21

        }
    }
    // copy results to global memory pXY,  disp_dist (already copied)
@@ -775,8 +768,7 @@ extern "C" __global__ void get_tiles_offsets(

extern "C" __global__ void calcReverseDistortionTable(
    struct gc *geometry_correction,
		float * rByRDist)
{
    float *rByRDist) {
    // int num_threads = NUM_CAMS *  blockDim.z  *  blockDim.y * blockDim.x; // 36
    int indx = ((blockIdx.x * blockDim.z + threadIdx.z) * blockDim.y + threadIdx.y) * blockDim.x + threadIdx.x;
    //	double delta=1E-20; // 12; // 10; // -8; 215.983994 ms
@@ -785,14 +777,7 @@ extern "C" __global__ void calcReverseDistortionTable(
    double minDerivative = 0.01;
    int numIterations = 1000;
    double drDistDr = 1.0;
	double d=1.0
			-geometry_correction -> distortionA8
			-geometry_correction -> distortionA7
			-geometry_correction -> distortionA6
			-geometry_correction -> distortionA5
			-geometry_correction -> distortionA
			-geometry_correction -> distortionB
			-geometry_correction -> distortionC;
    double d = 1.0 - geometry_correction->distortionA8 - geometry_correction->distortionA7 - geometry_correction->distortionA6 - geometry_correction->distortionA5 - geometry_correction->distortionA - geometry_correction->distortionB - geometry_correction->distortionC;
    double rPrev = 0.0;
    int num_points = (RBYRDIST_LEN + CALC_REVERSE_TABLE_BLOCK_THREADS - 1) / CALC_REVERSE_TABLE_BLOCK_THREADS;
    for (int p = 0; p < num_points; p++) {
@@ -808,21 +793,37 @@ extern "C" __global__ void calcReverseDistortionTable(
        double r = (p == 0) ? rDist : rPrev;
        for (int iteration = 0; iteration < numIterations; iteration++) {
            double k = (((((((
					geometry_correction -> distortionA8) * r +
					geometry_correction -> distortionA7) * r +
					geometry_correction -> distortionA6) * r +
					geometry_correction -> distortionA5) * r +
					geometry_correction -> distortionA) * r +
					geometry_correction -> distortionB) * r +
					geometry_correction -> distortionC) * r + d;
                                 geometry_correction->distortionA8) *
                                 r +
                             geometry_correction->distortionA7) *
                                r +
                            geometry_correction->distortionA6) *
                               r +
                           geometry_correction->distortionA5) *
                              r +
                          geometry_correction->distortionA) *
                             r +
                         geometry_correction->distortionB) *
                            r +
                        geometry_correction->distortionC) *
                           r +
                       d;
            drDistDr = (((((((
					8 * geometry_correction -> distortionA8) * r +
					7 * geometry_correction -> distortionA7) * r +
					6 * geometry_correction -> distortionA6) * r +
					5 * geometry_correction -> distortionA5) * r +
					4 * geometry_correction -> distortionA) * r +
					3 * geometry_correction -> distortionB) * r+
					2 * geometry_correction -> distortionC) * r+d;
                                 8 * geometry_correction->distortionA8) *
                                 r +
                             7 * geometry_correction->distortionA7) *
                                r +
                            6 * geometry_correction->distortionA6) *
                               r +
                           5 * geometry_correction->distortionA5) *
                              r +
                          4 * geometry_correction->distortionA) *
                             r +
                         3 * geometry_correction->distortionB) *
                            r +
                        2 * geometry_correction->distortionC) *
                           r +
                       d;
            if (drDistDr < minDerivative) {  // folds backwards !
                return;                      // too high distortion
            }
@@ -898,10 +899,18 @@ __device__ void printGeometryCorrection(struct gc * g, int num_cams){
    //	printf("%22s: %f, %f \n",        "pXY0[1]", g->pXY0[1][0], g->pXY0[1][1]);
    //	printf("%22s: %f, %f \n",        "pXY0[2]", g->pXY0[2][0], g->pXY0[2][1]);
    //	printf("%22s: %f, %f \n",        "pXY0[3]", g->pXY0[3][0], g->pXY0[3][1]);
	printf("%22s:","forward"); for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->forward[ncam]); printf("\n");
	printf("%22s:","right");   for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->right  [ncam]); printf("\n");
	printf("%22s:","height");  for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->height [ncam]); printf("\n");
	printf("%22s:","roll");    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->roll   [ncam]); printf("\n");
    printf("%22s:", "forward");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->forward[ncam]);
    printf("\n");
    printf("%22s:", "right");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->right[ncam]);
    printf("\n");
    printf("%22s:", "height");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->height[ncam]);
    printf("\n");
    printf("%22s:", "roll");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->roll[ncam]);
    printf("\n");
    for (int ncam = 0; ncam < num_cams; ncam++) {
        printf("%19s%2d]: %f, %f \n", "pXY0[", ncam, g->pXY0[ncam][0], g->pXY0[ncam][1]);
    }
@@ -922,13 +931,14 @@ __device__ void printGeometryCorrection(struct gc * g, int num_cams){
    printf("%22s: %f\n", "disparityRadius", g->disparityRadius);

    //	printf("%22s: %f, %f, %f, %f \n","woi_tops", g->woi_tops[0], g->woi_tops[1], g->woi_tops[2], g->woi_tops[3]);
	printf("%22s:","woi_tops");    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->woi_tops[ncam]); printf("\n");
    printf("%22s:", "woi_tops");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", g->woi_tops[ncam]);
    printf("\n");

#endif  // ifndef JCUDA
}

__device__ void printExtrinsicCorrection(corr_vector * cv, int num_cams)
{
__device__ void printExtrinsicCorrection(corr_vector *cv, int num_cams) {
#ifndef JCUDA
    printf("\nExtrinsic Correction Vector\n---------------------------\n");
    //	printf("%22s: %f, %f, %f\n",     "tilt",    cv->tilt[0],    cv->tilt[1],    cv->tilt[2]);
@@ -936,17 +946,20 @@ __device__ void printExtrinsicCorrection(corr_vector * cv, int num_cams)
    //	printf("%22s: %f, %f, %f, %f\n", "roll",    cv->roll[0],    cv->roll[1],    cv->roll[2],      cv->roll[3]);
    //	printf("%22s: %f, %f, %f\n",     "zoom",    cv->zoom[0],    cv->zoom[1],    cv->zoom[2]);

	printf("%22s:","tilt");    for (int ncam = 0; ncam < (num_cams-1); ncam++) printf(" %f,", cv->tilt[ncam]);    printf("\n");
	printf("%22s:","azimuth"); for (int ncam = 0; ncam < (num_cams-1); ncam++) printf(" %f,", cv->azimuth[ncam]); printf("\n");
	printf("%22s:","roll");    for (int ncam = 0; ncam <  num_cams;    ncam++) printf(" %f,", cv->roll[ncam]);    printf("\n");
	printf("%22s:","zoom");    for (int ncam = 0; ncam < (num_cams-1); ncam++) printf(" %f,", cv->zoom[ncam]);    printf("\n");


    printf("%22s:", "tilt");
    for (int ncam = 0; ncam < (num_cams - 1); ncam++) printf(" %f,", cv->tilt[ncam]);
    printf("\n");
    printf("%22s:", "azimuth");
    for (int ncam = 0; ncam < (num_cams - 1); ncam++) printf(" %f,", cv->azimuth[ncam]);
    printf("\n");
    printf("%22s:", "roll");
    for (int ncam = 0; ncam < num_cams; ncam++) printf(" %f,", cv->roll[ncam]);
    printf("\n");
    printf("%22s:", "zoom");
    for (int ncam = 0; ncam < (num_cams - 1); ncam++) printf(" %f,", cv->zoom[ncam]);
    printf("\n");

    printf("%22s: %f(t), %f(a), %f(r)\n", "imu_rot", cv->imu_rot[0], cv->imu_rot[1], cv->imu_rot[2]);
    printf("%22s: %f(x), %f(y), %f(z)\n", "imu_move", cv->imu_move[0], cv->imu_move[1], cv->imu_move[2]);
#endif  // ifndef JCUDA
}


Loading