Skip to content

Commit

Permalink
Compiler warning fixes in opencl warper
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.osgeo.org/gdal/trunk@35426 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
rouault committed Sep 13, 2016
1 parent de2dc39 commit 515e358
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gdal/alg/gdalwarpkernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4272,9 +4272,9 @@ static CPLErr GWKOpenCLCase( GDALWarpKernel *poWK )
/* Setup points to transform to source image space. */
/* ---------------------------------------------------------------- */
memcpy( padfX, padfX + nDstXSize, sizeof(double) * nDstXSize );
const double dfY = iDstY + 0.5 + poWK->nDstYOff;
const double dfYConst = iDstY + 0.5 + poWK->nDstYOff;
for( iDstX = 0; iDstX < nDstXSize; iDstX++ )
padfY[iDstX] = dfY;
padfY[iDstX] = dfYConst;
memset( padfZ, 0, sizeof(double) * nDstXSize );

/* ---------------------------------------------------------------- */
Expand Down
56 changes: 42 additions & 14 deletions gdal/alg/gdalwarpkernel_opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static const char* getCLDataTypeString( cl_channel_type dataType )
from the kernel. If debugging is on, we can print the name and stats about the
device we're using.
*/
cl_device_id get_device(OCLVendor *peVendor)
static cl_device_id get_device(OCLVendor *peVendor)
{
cl_int err = 0;
cl_device_id device = NULL;
Expand Down Expand Up @@ -302,16 +302,16 @@ cl_device_id get_device(OCLVendor *peVendor)
make do with what we have. This leads to wasted space, but as OpenCL matures
I hope it'll get better.
*/
cl_int set_supported_formats(struct oclWarper *warper,
static cl_int set_supported_formats(struct oclWarper *warper,
cl_channel_order minOrderSize,
cl_channel_order *chosenOrder,
unsigned int *chosenSize,
cl_channel_type dataType )
{
cl_image_format *fmtBuf = (cl_image_format *)calloc(256, sizeof(cl_image_format));
cl_uint numRet;
int i;
int extraSpace = 9999;
cl_uint i;
cl_uint extraSpace = 9999;
cl_int err;
int bFound = FALSE;

Expand All @@ -321,7 +321,7 @@ cl_int set_supported_formats(struct oclWarper *warper,
CL_MEM_OBJECT_IMAGE2D,
256, fmtBuf, &numRet));
for (i = 0; i < numRet; ++i) {
int thisOrderSize = 0;
cl_channel_order thisOrderSize = 0;
switch (fmtBuf[i].image_channel_order)
{
//Only support formats which use the channels in order (x,y,z,w)
Expand Down Expand Up @@ -377,6 +377,7 @@ cl_int set_supported_formats(struct oclWarper *warper,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int alloc_pinned_mem(struct oclWarper *warper, int imgNum, size_t dataSz,
void **wrkPtr, cl_mem *wrkCL)
{
Expand Down Expand Up @@ -415,8 +416,9 @@ cl_int alloc_pinned_mem(struct oclWarper *warper, int imgNum, size_t dataSz,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int alloc_working_arr(struct oclWarper *warper,
size_t ptrSz, size_t dataSz, size_t *fmtSz)
size_t ptrSz, size_t dataSz, CPL_UNUSED size_t *fmtSz)
{
cl_int err = CL_SUCCESS;
int i, b;
Expand Down Expand Up @@ -519,6 +521,7 @@ cl_int alloc_working_arr(struct oclWarper *warper,
Returns CL_SUCCESS on success and other CL_* errors in the error buffer when
something goes wrong.
*/
static
cl_kernel get_kernel(struct oclWarper *warper, char useVec,
double dfXScale, double dfYScale, double dfXFilter, double dfYFilter,
int nXRadius, int nYRadius, int nFiltInitX, int nFiltInitY,
Expand All @@ -527,10 +530,10 @@ cl_kernel get_kernel(struct oclWarper *warper, char useVec,
cl_program program;
cl_kernel kernel;
cl_int err = CL_SUCCESS;
char *buffer = (char *)CPLCalloc(128000, sizeof(char));
#define PROGBUF_SIZE 128000
char *buffer = (char *)CPLCalloc(PROGBUF_SIZE, sizeof(char));
char *progBuf = (char *)CPLCalloc(PROGBUF_SIZE, sizeof(char));
float dstMinVal, dstMaxVal;
float dstMinVal = 0.f, dstMaxVal = 0.0;

const char *outType;
const char *dUseVec = "";
Expand Down Expand Up @@ -1239,7 +1242,8 @@ cl_kernel get_kernel(struct oclWarper *warper, char useVec,
handleErrGoto(err, error_final);

//Assemble the compiler arg string for speed. All invariants should be defined here.
sprintf(buffer, "-cl-fast-relaxed-math -Werror -D FALSE=0 -D TRUE=1 "
snprintf(buffer, PROGBUF_SIZE,
"-cl-fast-relaxed-math -Werror -D FALSE=0 -D TRUE=1 "
"%s"
"-D iSrcWidth=%d -D iSrcHeight=%d -D iDstWidth=%d -D iDstHeight=%d "
"-D useUnifiedSrcDensity=%d -D useUnifiedSrcValid=%d "
Expand Down Expand Up @@ -1316,6 +1320,7 @@ cl_kernel get_kernel(struct oclWarper *warper, char useVec,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_coord_data (struct oclWarper *warper, cl_mem *xy)
{
cl_int err = CL_SUCCESS;
Expand All @@ -1324,12 +1329,20 @@ cl_int set_coord_data (struct oclWarper *warper, cl_mem *xy)
//Copy coord data to the device
imgFmt.image_channel_order = warper->xyChOrder;
imgFmt.image_channel_data_type = CL_FLOAT;

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
(*xy) = clCreateImage2D(warper->context,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &imgFmt,
(size_t) warper->xyWidth,
(size_t) warper->xyHeight,
(size_t) sizeof(float) * warper->xyChSize * warper->xyWidth,
warper->xyWork, &err);
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
handleErr(err);

//Free the source memory, now that it's copied we don't need it
Expand Down Expand Up @@ -1357,6 +1370,7 @@ cl_int set_coord_data (struct oclWarper *warper, cl_mem *xy)
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_unified_data(struct oclWarper *warper,
cl_mem *unifiedSrcDensityCL, cl_mem *unifiedSrcValidCL,
float *unifiedSrcDensity, unsigned int *unifiedSrcValid,
Expand Down Expand Up @@ -1454,6 +1468,7 @@ cl_int set_unified_data(struct oclWarper *warper,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_src_rast_data (struct oclWarper *warper, int iNum, size_t sz,
cl_channel_order chOrder, cl_mem *srcReal, cl_mem *srcImag)
{
Expand All @@ -1466,6 +1481,11 @@ cl_int set_src_rast_data (struct oclWarper *warper, int iNum, size_t sz,
imgFmt.image_channel_data_type = warper->imageFormat;

//Create & copy the source image
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

(*srcReal) = clCreateImage2D(warper->context,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &imgFmt,
(size_t) warper->srcWidth, (size_t) warper->srcHeight,
Expand All @@ -1488,6 +1508,9 @@ cl_int set_src_rast_data (struct oclWarper *warper, int iNum, size_t sz,

handleErr(err);
}
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif

//Free the source memory, now that it's copied we don't need it
freeCLMem(warper->realWorkCL[iNum], warper->realWork.v[iNum]);
Expand Down Expand Up @@ -1516,6 +1539,7 @@ cl_int set_src_rast_data (struct oclWarper *warper, int iNum, size_t sz,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_dst_rast_data(struct oclWarper *warper, int iImg, size_t sz,
cl_mem *dstReal, cl_mem *dstImag)
{
Expand Down Expand Up @@ -1557,6 +1581,7 @@ cl_int set_dst_rast_data(struct oclWarper *warper, int iImg, size_t sz,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int get_dst_rast_data(struct oclWarper *warper, int iImg, size_t wordSz,
cl_mem dstReal, cl_mem dstImag)
{
Expand Down Expand Up @@ -1589,6 +1614,7 @@ cl_int get_dst_rast_data(struct oclWarper *warper, int iImg, size_t wordSz,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_dst_data(struct oclWarper *warper,
cl_mem *dstDensityCL, cl_mem *dstValidCL, cl_mem *dstNoDataRealCL,
float *dstDensity, unsigned int *dstValid, float *dstNoDataReal)
Expand Down Expand Up @@ -1651,6 +1677,7 @@ cl_int set_dst_data(struct oclWarper *warper,
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int execute_kern(struct oclWarper *warper, cl_kernel kern, size_t loc_size)
{
cl_int err = CL_SUCCESS;
Expand Down Expand Up @@ -1722,6 +1749,7 @@ cl_int execute_kern(struct oclWarper *warper, cl_kernel kern, size_t loc_size)
Returns CL_SUCCESS on success and other CL_* errors when something goes wrong.
*/
static
cl_int set_img_data(struct oclWarper *warper, void *srcImgData,
unsigned int width, unsigned int height, int isSrc,
unsigned int bandNum, void **dstRealImgs, void **dstImagImgs)
Expand All @@ -1734,7 +1762,7 @@ cl_int set_img_data(struct oclWarper *warper, void *srcImgData,
void *dstImag = NULL;

// Handle vector if needed
if (warper->useVec && bandNum < warper->numBands - warper->numBands % 4) {
if (warper->useVec && (int)bandNum < warper->numBands - warper->numBands % 4) {
imgChSize = warper->imgChSize4;
vecOff = bandNum % 4;
imgNum = bandNum / 4;
Expand Down Expand Up @@ -1928,7 +1956,7 @@ struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
cl_channel_type imageFormat,
int numBands, int coordMult,
int useImag, int useBandSrcValid,
float *fDstDensity,
CPL_UNUSED float *fDstDensity,
double *dfDstNoDataReal,
OCLResampAlg resampAlg, cl_int *clErr)
{
Expand Down Expand Up @@ -1998,7 +2026,7 @@ struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
handleErrGoto(err, error_label);
err = clGetDeviceInfo(warper->dev, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), &maxHeight, &sz);
handleErrGoto(err, error_label);
if (maxWidth < srcWidth || maxHeight < srcHeight) {
if (maxWidth < (size_t)srcWidth || maxHeight < (size_t)srcHeight) {
err = CL_INVALID_IMAGE_SIZE;
handleErrGoto(err, error_label);
}
Expand Down Expand Up @@ -2027,7 +2055,7 @@ struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
//Make space for the per-band BandSrcValid data (if exists)
if (useBandSrcValid) {
//32 bits in the mask
size_t sz = warper->numBands * ((31 + warper->srcWidth * warper->srcHeight) >> 5);
sz = warper->numBands * ((31 + warper->srcWidth * warper->srcHeight) >> 5);

//Allocate some space for the validity of the validity mask
err = alloc_pinned_mem(warper, 0, warper->numBands*sizeof(char),
Expand Down Expand Up @@ -2292,7 +2320,7 @@ cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper,
cl_mem xy, unifiedSrcDensityCL, unifiedSrcValidCL;
cl_mem dstDensityCL, dstValidCL, dstNoDataRealCL;
cl_mem useBandSrcValidCL, nBandSrcValidCL;
size_t groupSize, wordSize;
size_t groupSize, wordSize = 0;
cl_kernel kern = NULL;
cl_channel_order chOrder;

Expand Down

0 comments on commit 515e358

Please sign in to comment.