Skip to content

Commit 65f1a96

Browse files
author
James R. Barlow
committed
Fix various clang compilation errors
Also fixed a writable strings warning/error. warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] Several were of this form and fixed as the compiler suggested: openclwrapper.cpp:2411:33: error: non-constant-expression cannot be narrowed from type 'int' to 'size_t' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] size_t local_work_size[] = {block_size}; ^~~~~~~~~~ openclwrapper.cpp:2411:33: note: insert an explicit cast to silence this issue size_t local_work_size[] = {block_size}; ^~~~~~~~~~ static_cast<size_t>( ) Should have low impact on other platforms/compilers. The change makes the code more correct.
1 parent 8476d0b commit 65f1a96

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

opencl/openclwrapper.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ KernelEnv rEnv;
6060
// substitute invalid characters in device name with _
6161
void legalizeFileName( char *fileName) {
6262
//printf("fileName: %s\n", fileName);
63-
char *invalidChars = "/\?:*\"><| "; // space is valid but can cause headaches
63+
const char* invalidChars = "/\?:*\"><| "; // space is valid but can cause headaches
6464
// for each invalid char
6565
for (int i = 0; i < strlen(invalidChars); i++) {
6666
char invalidStr[4];
@@ -2408,9 +2408,9 @@ PERF_COUNT_START("HistogramRectOCL")
24082408
int requestedOccupancy = 10;
24092409
int numWorkGroups = numCUs * requestedOccupancy;
24102410
int numThreads = block_size*numWorkGroups;
2411-
size_t local_work_size[] = {block_size};
2412-
size_t global_work_size[] = {numThreads};
2413-
size_t red_global_work_size[] = {block_size*kHistogramSize*bytes_per_pixel};
2411+
size_t local_work_size[] = {static_cast<size_t>(block_size)};
2412+
size_t global_work_size[] = {static_cast<size_t>(numThreads)};
2413+
size_t red_global_work_size[] = {static_cast<size_t>(block_size*kHistogramSize*bytes_per_pixel)};
24142414

24152415
/* map histogramAllChannels as write only */
24162416
int numBins = kHistogramSize*bytes_per_pixel*numWorkGroups;
@@ -3398,8 +3398,8 @@ PERF_COUNT_SUB("pix setup")
33983398
int block_size = 256;
33993399
int numWorkGroups = ((h*w+block_size-1) / block_size );
34003400
int numThreads = block_size*numWorkGroups;
3401-
size_t local_work_size[] = {block_size};
3402-
size_t global_work_size[] = {numThreads};
3401+
size_t local_work_size[] = {static_cast<size_t>(block_size)};
3402+
size_t global_work_size[] = {static_cast<size_t>(numThreads)};
34033403
//printf("Enqueueing %i threads for %i output pixels\n", numThreads, w*h);
34043404

34053405
/* compile kernel */

0 commit comments

Comments
 (0)