Skip to content

Commit

Permalink
Fix more 32-bit Wformat warnings (#2185)
Browse files Browse the repository at this point in the history
This fixes occurrences where the previous wrong specifier appears to
work in a typical 64-bit build, but causes a Wformat warning in 32-bit
builds.

Signed-off-by: Sven van Haastregt <[email protected]>
  • Loading branch information
svenvh authored Dec 17, 2024
1 parent be1278d commit 7693ffe
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "testBase.h"
#include <limits.h>
#include <ctype.h>
#include <cinttypes>
#ifndef _WIN32
#include <unistd.h>
#endif
Expand Down Expand Up @@ -216,7 +217,9 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
char *extension = (char *)malloc((extension_length + 1) * sizeof(char));
if (extension == NULL)
{
log_error( "Error: unable to allocate memory to hold extension name: %ld chars\n", extension_length );
log_error("Error: unable to allocate memory to hold extension "
"name: %" PRIdPTR " chars\n",
extension_length);
return -1;
}
extensions_supported[num_of_supported_extensions] = extension;
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/computeinfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void dumpConfigInfo(config_info* info)
}
break;
case type_cl_device_id:
log_info("\t%s == %ld\n", info->opcode_name,
log_info("\t%s == %" PRIdPTR "\n", info->opcode_name,
(intptr_t)info->config.device_id);
break;
case type_cl_device_affinity_domain:
Expand Down
31 changes: 23 additions & 8 deletions test_conformance/device_timer/test_device_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
//
#include <stdio.h>
#include <cinttypes>
#include <CL/cl.h>
#include "harness/errorHelpers.h"
#include "harness/compat.h"
Expand Down Expand Up @@ -74,13 +75,16 @@ REGISTER_TEST(device_and_host_timers)

if (deviceEndTime <= deviceStartTime) {
log_error("Device timer is not monotonically increasing.\n");
log_error(" deviceStartTime: %lu, deviceEndTime: %lu\n", deviceStartTime, deviceEndTime);
log_error(" deviceStartTime: %" PRIu64 ", deviceEndTime: %" PRIu64
"\n",
deviceStartTime, deviceEndTime);
errors++;
}

if (hostEndTime <= hostStartTime) {
log_error("Error: Host timer is not monotonically increasing.\n");
log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostStartTime, hostEndTime);
log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n",
hostStartTime, hostEndTime);
errors++;
}

Expand All @@ -95,29 +99,36 @@ REGISTER_TEST(device_and_host_timers)

if (observedDiff > allowedDiff) {
log_error("Error: Device and host timers did not increase by same amount\n");
log_error(" Observed difference between timers %lu (max allowed %lu).\n", observedDiff, allowedDiff);
log_error(" Observed difference between timers %" PRIu64
" (max allowed %" PRIu64 ").\n",
observedDiff, allowedDiff);
errors++;
}

log_info("Cross-checking results with clGetHostTimer ...\n");

if (hostOnlyEndTime <= hostOnlyStartTime) {
log_error("Error: Host timer is not monotonically increasing.\n");
log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostOnlyStartTime, hostOnlyEndTime);
log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n",
hostOnlyStartTime, hostOnlyEndTime);
errors++;
}

if (hostOnlyStartTime < hostStartTime) {
log_error("Error: Host start times do not correlate.\n");
log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n");
log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostStartTime, hostOnlyStartTime);
log_error(" clGetDeviceAndHostTimer: %" PRIu64
", clGetHostTimer: %" PRIu64 "\n",
hostStartTime, hostOnlyStartTime);
errors++;
}

if (hostOnlyEndTime < hostEndTime) {
log_error("Error: Host end times do not correlate.\n");
log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n");
log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostEndTime, hostOnlyEndTime);
log_error(" clGetDeviceAndHostTimer: %" PRIu64
", clGetHostTimer: %" PRIu64 "\n",
hostEndTime, hostOnlyEndTime);
errors++;
}

Expand Down Expand Up @@ -148,7 +159,9 @@ REGISTER_TEST(timer_resolution_queries)
errors++;
}
else {
log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %lu nanoseconds\n", deviceTimerResolution);
log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %" PRIu64
" nanoseconds\n",
deviceTimerResolution);
}

if (platform) {
Expand All @@ -158,7 +171,9 @@ REGISTER_TEST(timer_resolution_queries)
errors++;
}
else {
log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %lu nanoseconds\n", hostTimerResolution);
log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %" PRIu64
" nanoseconds\n",
hostTimerResolution);
}
}
else {
Expand Down
9 changes: 6 additions & 3 deletions test_conformance/generic_address_space/advanced_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ class CAdvancedTest : public CTest {
size_t passCount = std::count(results.begin(), results.end(), 1);
if (passCount != results.size()) {
std::vector<cl_uint>::iterator iter = std::find(results.begin(), results.end(), 0);
log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter));
log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size());
log_error("Verification on device failed at index %td\n",
std::distance(results.begin(), iter));
log_error("%zu out of %zu failed\n", (results.size() - passCount),
results.size());
return -1;
}

Expand All @@ -276,7 +278,8 @@ class CAdvancedTest : public CTest {
cl_int result = CL_SUCCESS;

for (std::vector<std::string>::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) {
log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size());
log_info("Executing subcase #%zu out of %zu\n",
(it - _kernels.begin() + 1), _kernels.size());

result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it);
}
Expand Down
9 changes: 6 additions & 3 deletions test_conformance/generic_address_space/basic_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ class CBasicTest : CTest {
size_t passCount = std::count(results.begin(), results.end(), 1);
if (passCount != results.size()) {
std::vector<cl_uint>::iterator iter = std::find(results.begin(), results.end(), 0);
log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter));
log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size());
log_error("Verification on device failed at index %td\n",
std::distance(results.begin(), iter));
log_error("%zu out of %zu failed\n", (results.size() - passCount),
results.size());
return -1;
}

Expand All @@ -82,7 +84,8 @@ class CBasicTest : CTest {
cl_int result = CL_SUCCESS;

for (std::vector<std::string>::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) {
log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size());
log_info("Executing subcase #%zu out of %zu\n",
(it - _kernels.begin() + 1), _kernels.size());

result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it);
}
Expand Down
9 changes: 6 additions & 3 deletions test_conformance/generic_address_space/stress_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ class CStressTest : public CTest {
size_t passCount = std::count(results.begin(), results.end(), 1);
if (passCount != results.size()) {
std::vector<cl_uint>::iterator iter = std::find(results.begin(), results.end(), 0);
log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter));
log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size());
log_error("Verification on device failed at index %td\n",
std::distance(results.begin(), iter));
log_error("%zu out of %zu failed\n", (results.size() - passCount),
results.size());
return -1;
}

Expand All @@ -84,7 +86,8 @@ class CStressTest : public CTest {
cl_int result = CL_SUCCESS;

for (std::vector<std::string>::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) {
log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size());
log_info("Executing subcase #%zu out of %zu\n",
(it - _kernels.begin() + 1), _kernels.size());

result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it);
}
Expand Down

0 comments on commit 7693ffe

Please sign in to comment.