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

@@ -14,6 +14,9 @@
// limitations under the License.
//
#include <string.h>
#include <algorithm>
#include "cl_utils.h"
#include "tests.h"
#include "harness/testHarness.h"
@@ -156,7 +159,7 @@ int test_roundTrip( cl_device_id device, cl_context context, cl_command_queue qu
}
// Figure out how many elements are in a work block
size_t elementSize = MAX( sizeof(cl_half), sizeof(cl_float));
size_t elementSize = std::max(sizeof(cl_half), sizeof(cl_float));
size_t blockCount = (size_t)getBufferSize(device) / elementSize; //elementSize is a power of two
uint64_t lastCase = 1ULL << (8*sizeof(cl_half)); // number of cl_half
size_t stride = blockCount;
@@ -168,7 +171,7 @@ int test_roundTrip( cl_device_id device, cl_context context, cl_command_queue qu
for( i = 0; i < (uint64_t)lastCase; i += stride )
{
count = (uint32_t) MIN( blockCount, lastCase - i );
count = (uint32_t)std::min((uint64_t)blockCount, lastCase - i);
//Init the input stream
uint16_t *p = (uint16_t *)gIn_half;

View File

@@ -17,6 +17,9 @@
#include "harness/testHarness.h"
#include <string.h>
#include <algorithm>
#include "cl_utils.h"
#include "tests.h"
@@ -429,7 +432,7 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
}
// Figure out how many elements are in a work block
size_t elementSize = MAX( sizeof(cl_half), sizeof(cl_float));
size_t elementSize = std::max(sizeof(cl_half), sizeof(cl_float));
size_t blockCount = getBufferSize(device) / elementSize; // elementSize is power of 2
uint64_t lastCase = 1ULL << (8*sizeof(cl_half)); // number of things of size cl_half
@@ -447,7 +450,7 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
for( i = 0; i < (uint64_t)lastCase; i += blockCount )
{
count = (uint32_t) MIN( blockCount, lastCase - i );
count = (uint32_t)std::min((uint64_t)blockCount, lastCase - i);
//Init the input stream
uint16_t *p = (uint16_t *)gIn_half;

View File

@@ -18,6 +18,9 @@
#include "harness/testHarness.h"
#include <string.h>
#include <algorithm>
#include "cl_utils.h"
#include "tests.h"
@@ -674,7 +677,7 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
} // end for vector size
// Figure out how many elements are in a work block
size_t elementSize = MAX( sizeof(cl_ushort), sizeof(float));
size_t elementSize = std::max(sizeof(cl_ushort), sizeof(float));
size_t blockCount = BUFFER_SIZE / elementSize; // elementSize is power of 2
uint64_t lastCase = 1ULL << (8*sizeof(float)); // number of floats.
size_t stride = blockCount;
@@ -726,7 +729,7 @@ int Test_vStoreHalf_private( cl_device_id device, f2h referenceFunc, d2h doubleR
for( i = 0; i < lastCase; i += stride )
{
count = (cl_uint) MIN( blockCount, lastCase - i );
count = (cl_uint)std::min((uint64_t)blockCount, lastCase - i);
fref.i = i;
dref.i = i;
@@ -1272,7 +1275,7 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
}
// Figure out how many elements are in a work block
size_t elementSize = MAX( sizeof(cl_ushort), sizeof(float));
size_t elementSize = std::max(sizeof(cl_ushort), sizeof(float));
size_t blockCount = BUFFER_SIZE / elementSize;
uint64_t lastCase = 1ULL << (8*sizeof(float));
size_t stride = blockCount;
@@ -1323,7 +1326,7 @@ int Test_vStoreaHalf_private( cl_device_id device, f2h referenceFunc, d2h double
for( i = 0; i < (uint64_t)lastCase; i += stride )
{
count = (cl_uint) MIN( blockCount, lastCase - i );
count = (cl_uint)std::min((uint64_t)blockCount, lastCase - i);
fref.i = i;
dref.i = i;