remove min max macros (#1310)

* remove the MIN and MAX macros and use the std versions instead

* fix formatting

* fix Arm build

* remove additional MIN and MAX macros from compat.h
This commit is contained in:
Ben Ashbaugh
2021-09-13 05:25:32 -07:00
committed by GitHub
parent 1f26e1d8ba
commit 02bf24d2b1
31 changed files with 241 additions and 202 deletions

View File

@@ -20,6 +20,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <algorithm>
#include "procs.h"
@@ -310,7 +312,7 @@ test_work_group_broadcast_2D(cl_device_id device, cl_context context, cl_command
localsize[0] = localsize[1] = 1;
}
num_workgroups = MAX(n_elems/wg_size[0], 16);
num_workgroups = std::max(n_elems / wg_size[0], (size_t)16);
globalsize[0] = num_workgroups * localsize[0];
globalsize[1] = num_workgroups * localsize[1];
num_elements = globalsize[0] * globalsize[1];
@@ -437,7 +439,7 @@ test_work_group_broadcast_3D(cl_device_id device, cl_context context, cl_command
localsize[0] = localsize[1] = localsize[2] = 1;
}
num_workgroups = MAX(n_elems/wg_size[0], 8);
num_workgroups = std::max(n_elems / wg_size[0], (size_t)8);
globalsize[0] = num_workgroups * localsize[0];
globalsize[1] = num_workgroups * localsize[1];
globalsize[2] = num_workgroups * localsize[2];

View File

@@ -20,8 +20,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#include <algorithm>
#include "procs.h"
const char *wg_scan_exclusive_max_kernel_code_int =
"__kernel void test_wg_scan_exclusive_max_int(global int *input, global int *output)\n"
@@ -79,7 +80,7 @@ verify_wg_scan_exclusive_max_int(int *inptr, int *outptr, size_t n, size_t wg_si
log_info("work_group_scan_exclusive_max int: Error at %u: expected = %d, got = %d\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
}
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
}
}
@@ -103,7 +104,7 @@ verify_wg_scan_exclusive_max_uint(unsigned int *inptr, unsigned int *outptr, siz
log_info("work_group_scan_exclusive_max int: Error at %u: expected = %u, got = %u\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
}
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
}
}
@@ -127,7 +128,7 @@ verify_wg_scan_exclusive_max_long(cl_long *inptr, cl_long *outptr, size_t n, siz
log_info("work_group_scan_exclusive_max long: Error at %u: expected = %lld, got = %lld\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
}
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
}
}
@@ -151,7 +152,7 @@ verify_wg_scan_exclusive_max_ulong(cl_ulong *inptr, cl_ulong *outptr, size_t n,
log_info("work_group_scan_exclusive_max ulong: Error at %u: expected = %llu, got = %llu\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
}
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
}
}

View File

@@ -20,8 +20,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#include <algorithm>
#include "procs.h"
const char *wg_scan_exclusive_min_kernel_code_int =
"__kernel void test_wg_scan_exclusive_min_int(global int *input, global int *output)\n"
@@ -80,7 +81,7 @@ verify_wg_scan_exclusive_min_int(int *inptr, int *outptr, size_t n, size_t wg_si
log_info("work_group_scan_exclusive_min int: Error at %u: expected = %d, got = %d\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
}
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
}
}
@@ -104,7 +105,7 @@ verify_wg_scan_exclusive_min_uint(unsigned int *inptr, unsigned int *outptr, siz
log_info("work_group_scan_exclusive_min int: Error at %u: expected = %u, got = %u\n", j+i, min_, outptr[j+i]);
return -1;
}
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
}
}
@@ -128,7 +129,7 @@ verify_wg_scan_exclusive_min_long(cl_long *inptr, cl_long *outptr, size_t n, siz
log_info("work_group_scan_exclusive_min long: Error at %u: expected = %lld, got = %lld\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
}
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
}
}
@@ -152,7 +153,7 @@ verify_wg_scan_exclusive_min_ulong(cl_ulong *inptr, cl_ulong *outptr, size_t n,
log_info("work_group_scan_exclusive_min ulong: Error at %u: expected = %llu, got = %llu\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
}
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
}
}

View File

@@ -20,6 +20,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <algorithm>
#include "procs.h"
@@ -75,7 +77,7 @@ verify_wg_scan_inclusive_max_int(int *inptr, int *outptr, size_t n, size_t wg_si
m = wg_size;
for (i = 0; i < m; ++i) {
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
if (outptr[j+i] != max_) {
log_info("work_group_scan_inclusive_max int: Error at %u: expected = %d, got = %d\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
@@ -99,7 +101,7 @@ verify_wg_scan_inclusive_max_uint(unsigned int *inptr, unsigned int *outptr, siz
m = wg_size;
for (i = 0; i < m; ++i) {
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
if (outptr[j+i] != max_) {
log_info("work_group_scan_inclusive_max int: Error at %lu: expected = %u, got = %u\n", (unsigned long)(j+i), max_, outptr[j+i]);
return -1;
@@ -123,7 +125,7 @@ verify_wg_scan_inclusive_max_long(cl_long *inptr, cl_long *outptr, size_t n, siz
m = wg_size;
for (i = 0; i < m; ++i) {
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
if (outptr[j+i] != max_) {
log_info("work_group_scan_inclusive_max long: Error at %u: expected = %lld, got = %lld\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;
@@ -147,7 +149,7 @@ verify_wg_scan_inclusive_max_ulong(cl_ulong *inptr, cl_ulong *outptr, size_t n,
m = wg_size;
for (i = 0; i < m; ++i) {
max_ = MAX(inptr[j+i], max_);
max_ = std::max(inptr[j + i], max_);
if (outptr[j+i] != max_) {
log_info("work_group_scan_inclusive_max ulong: Error at %u: expected = %llu, got = %llu\n", (unsigned int)(j+i), max_, outptr[j+i]);
return -1;

View File

@@ -20,6 +20,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <algorithm>
#include "procs.h"
@@ -75,7 +77,7 @@ verify_wg_scan_inclusive_min_int(int *inptr, int *outptr, size_t n, size_t wg_si
m = wg_size;
for (i = 0; i < m; ++i) {
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
if (outptr[j+i] != min_) {
log_info("work_group_scan_inclusive_min int: Error at %u: expected = %d, got = %d\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
@@ -99,7 +101,7 @@ verify_wg_scan_inclusive_min_uint(unsigned int *inptr, unsigned int *outptr, siz
m = wg_size;
for (i = 0; i < m; ++i) {
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
if (outptr[j+i] != min_) {
log_info("work_group_scan_inclusive_min int: Error at %u: expected = %u, got = %u\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
@@ -123,7 +125,7 @@ verify_wg_scan_inclusive_min_long(cl_long *inptr, cl_long *outptr, size_t n, siz
m = wg_size;
for (i = 0; i < m; ++i) {
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
if (outptr[j+i] != min_) {
log_info("work_group_scan_inclusive_min long: Error at %u: expected = %lld, got = %lld\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;
@@ -147,7 +149,7 @@ verify_wg_scan_inclusive_min_ulong(cl_ulong *inptr, cl_ulong *outptr, size_t n,
m = wg_size;
for (i = 0; i < m; ++i) {
min_ = MIN(inptr[j+i], min_);
min_ = std::min(inptr[j + i], min_);
if (outptr[j+i] != min_) {
log_info("work_group_scan_inclusive_min ulong: Error at %u: expected = %llu, got = %llu\n", (unsigned int)(j+i), min_, outptr[j+i]);
return -1;