Skip to content

Commit

Permalink
Enable narrowing errors for more directories
Browse files Browse the repository at this point in the history
Moves -Wno-narrowing down to only run on suites with
many narrowing errors.

Includes some quick fixes for one-off errors this caused.

Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 committed Apr 28, 2021
1 parent 60125f6 commit 69bbd20
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 26 deletions.
4 changes: 0 additions & 4 deletions test_conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Remember current source directory (`test_conformance').
set( CLConf_Install_Base_Dir "${CMAKE_CURRENT_SOURCE_DIR}" )

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set(HARNESS_LIB harness)

add_subdirectory( allocations )
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/api/test_queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int sampler_param_test(cl_sampler sampler, cl_sampler_info param_name,
return 0;
}

static cl_int normalized_coord_values[] = { CL_TRUE, CL_FALSE };
static cl_bool normalized_coord_values[] = { CL_TRUE, CL_FALSE };
static cl_addressing_mode addressing_mode_values[] = {
CL_ADDRESS_NONE, CL_ADDRESS_CLAMP_TO_EDGE, CL_ADDRESS_CLAMP,
CL_ADDRESS_REPEAT, CL_ADDRESS_MIRRORED_REPEAT
Expand Down
11 changes: 9 additions & 2 deletions test_conformance/atomics/test_atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,15 @@ cl_long test_atomic_and_result_long( size_t size, cl_long *startRefValues, size_

int test_atomic_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
TestFns set = { 0xffffffff, 0xffffffffffffffffLL, test_bitwise_num_results,
test_atomic_and_result_int, NULL, NULL, test_atomic_and_result_long, NULL, NULL };
TestFns set = { (int)0xffffffff,
(long long)0xffffffffffffffffLL,
test_bitwise_num_results,
test_atomic_and_result_int,
NULL,
NULL,
test_atomic_and_result_long,
NULL,
NULL };

if( test_atomic_function_set( deviceID, context, queue, num_elements, atom_and_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false ) != 0 )
return -1;
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(MODULE_NAME BASIC)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set(${MODULE_NAME}_SOURCES
main.cpp
test_fpmath_float.cpp test_fpmath_float2.cpp test_fpmath_float4.cpp
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(MODULE_NAME COMPILER)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set(${MODULE_NAME}_SOURCES
main.cpp
test_build_helpers.cpp
Expand Down
10 changes: 5 additions & 5 deletions test_conformance/computeinfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ typedef struct
} device_info;

device_info device_infos[] = {
{ CL_DEVICE_TYPE_DEFAULT, "CL_DEVICE_TYPE_DEFAULT", -1, NULL },
{ CL_DEVICE_TYPE_CPU, "CL_DEVICE_TYPE_CPU", -1, NULL },
{ CL_DEVICE_TYPE_GPU, "CL_DEVICE_TYPE_GPU", -1, NULL },
{ CL_DEVICE_TYPE_ACCELERATOR, "CL_DEVICE_TYPE_ACCELERATOR", -1, NULL },
{ CL_DEVICE_TYPE_ALL, "CL_DEVICE_TYPE_ALL", -1, NULL },
{ CL_DEVICE_TYPE_DEFAULT, "CL_DEVICE_TYPE_DEFAULT", 0, NULL },
{ CL_DEVICE_TYPE_CPU, "CL_DEVICE_TYPE_CPU", 0, NULL },
{ CL_DEVICE_TYPE_GPU, "CL_DEVICE_TYPE_GPU", 0, NULL },
{ CL_DEVICE_TYPE_ACCELERATOR, "CL_DEVICE_TYPE_ACCELERATOR", 0, NULL },
{ CL_DEVICE_TYPE_ALL, "CL_DEVICE_TYPE_ALL", 0, NULL },
};

// config types
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/conversions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(MODULE_NAME CONVERSIONS)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set (${MODULE_NAME}_SOURCES
Sleep.cpp test_conversions.cpp basic_test_conversions.cpp
)
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/device_execution/execute_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ int test_execute_block(cl_device_id device, cl_context context, cl_command_queue
size_t ret_len;
cl_int n, err_ret, res = 0;
clCommandQueueWrapper dev_queue;
cl_int kernel_results[MAX_GWS] = {0xDEADBEEF};
cl_int kernel_results[MAX_GWS] = { (cl_int)0xDEADBEEF };

size_t max_local_size = 1;
err_ret = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(max_local_size), &max_local_size, &ret_len);
Expand Down
26 changes: 17 additions & 9 deletions test_conformance/device_partition/test_device_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices
}


int init_device_partition_test(cl_device_id parentDevice, cl_uint &maxComputeUnits, cl_uint &maxSubDevices)
int init_device_partition_test(cl_device_id parentDevice,
cl_uint &maxComputeUnits, cl_uint &maxSubDevices)
{
int err = clGetDeviceInfo(parentDevice, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(maxComputeUnits), &maxComputeUnits, NULL);
test_error( err, "Unable to get maximal number of compute units" );
Expand Down Expand Up @@ -451,14 +452,21 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma

#define PROPERTY_TYPES 8
cl_device_partition_property partitionProp[PROPERTY_TYPES][5] = {
{ CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_COUNTS, 1, maxComputeUnits - 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE, 0, 0, 0 } ,
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 }
{ CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1,
CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE, 0, 0, 0 },
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 }
};

// loop thru each type, creating sub-devices for each type
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/integer_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(MODULE_NAME INTEGER_OPS)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set(${MODULE_NAME}_SOURCES
main.cpp
test_int_basic_ops.cpp
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/non_uniform_work_group/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(MODULE_NAME NON_UNIFORM_WORK_GROUP)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

set(${MODULE_NAME}_SOURCES
main.cpp
test_advanced_2d.cpp
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/profiling/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static int kernelFilter( cl_device_id device, cl_context context, cl_command_que

// read output image
size_t origin[3] = { 0, 0, 0 };
size_t region[3] = { w, h, 1 };
size_t region[3] = { (size_t)w, (size_t)h, 1 };
err = clEnqueueReadImage( queue, memobjs[1], true, origin, region, 0, 0, outptr, 0, NULL, NULL);
if( err != CL_SUCCESS ){
print_error( err, "clReadImage failed\n" );
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/profiling/readImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ int read_image( cl_device_id device, cl_context context, cl_command_queue queue,
}

size_t origin[3] = { 0, 0, 0 };
size_t region[3] = { w, h, 1 };
size_t region[3] = { (size_t)w, (size_t)h, 1 };
err = clEnqueueReadImage( queue, memobjs[0], false, origin, region, 0, 0, dst, 0, NULL, &readEvent );
if( err != CL_SUCCESS ){
print_error( err, "clReadImage2D failed" );
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/profiling/writeImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ int write_image( cl_device_id device, cl_context context, cl_command_queue queue
}

size_t origin[3] = { 0, 0, 0 };
size_t region[3] = { w, h, 1 };
size_t region[3] = { (size_t)w, (size_t)h, 1 };
err = clEnqueueWriteImage( queue, memobjs[0], false, origin, region, 0, 0, inptr, 0, NULL, &writeEvent );
if( err != CL_SUCCESS ){
clReleaseMemObject(memobjs[0]);
Expand Down
3 changes: 2 additions & 1 deletion test_conformance/spir/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ static void get_spir_version(cl_device_id device,
{
auto major = v[v.find('.') - 1];
auto minor = v[v.find('.') + 1];
versions.push_back(Version{ major - '0', minor - '0' });
versions.push_back(
Version{ (cl_uint)(major - '0'), (cl_uint)(minor - '0') });
}
}

Expand Down
4 changes: 4 additions & 0 deletions test_conformance/spirv_new/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
set(MODULE_NAME SPIRV_NEW)
set(CMAKE_CXX_STANDARD 11)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

file(GLOB SPIRV_NEW_SOURCES "*.cpp")

set(TEST_HARNESS_SOURCES
Expand Down

0 comments on commit 69bbd20

Please sign in to comment.