mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-20 14:39:01 +00:00
Make variables and functions local to translation unit (#1216)
* Make variables and functions local to translation unit Make some global variables local to function, or remove them when actually dead. Signed-off-by: Marco Antognini <marco.antognini@arm.com> * Address comments Remove unused code. Reduce scope of gDoubleCapabilities. Signed-off-by: Marco Antognini <marco.antognini@arm.com>
This commit is contained in:
@@ -51,21 +51,21 @@
|
||||
(CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO \
|
||||
| CL_FP_ROUND_TO_INF | CL_FP_INF_NAN | CL_FP_DENORM)
|
||||
|
||||
const char **gTestNames = NULL;
|
||||
unsigned int gTestNameCount = 0;
|
||||
char appName[MAXPATHLEN] = "";
|
||||
static const char **gTestNames = NULL;
|
||||
static unsigned int gTestNameCount = 0;
|
||||
static char appName[MAXPATHLEN] = "";
|
||||
cl_device_id gDevice = NULL;
|
||||
cl_context gContext = NULL;
|
||||
cl_command_queue gQueue = NULL;
|
||||
static int32_t gStartTestNumber = -1;
|
||||
static int32_t gEndTestNumber = -1;
|
||||
int gSkipCorrectnessTesting = 0;
|
||||
int gStopOnError = 0;
|
||||
static int gStopOnError = 0;
|
||||
static bool gSkipRestOfTests;
|
||||
int gForceFTZ = 0;
|
||||
int gWimpyMode = 0;
|
||||
int gHasDouble = 0;
|
||||
int gTestFloat = 1;
|
||||
static int gHasDouble = 0;
|
||||
static int gTestFloat = 1;
|
||||
// This flag should be 'ON' by default and it can be changed through the command
|
||||
// line arguments.
|
||||
static int gTestFastRelaxed = 1;
|
||||
@@ -78,7 +78,7 @@ static int gTestFastRelaxed = 1;
|
||||
OpenCL 2.0 spec then it has to be changed through a command line argument.
|
||||
*/
|
||||
int gFastRelaxedDerived = 1;
|
||||
int gToggleCorrectlyRoundedDivideSqrt = 0;
|
||||
static int gToggleCorrectlyRoundedDivideSqrt = 0;
|
||||
int gDeviceILogb0 = 1;
|
||||
int gDeviceILogbNaN = 1;
|
||||
int gCheckTininessBeforeRounding = 1;
|
||||
@@ -97,12 +97,8 @@ cl_mem gInBuffer2 = NULL;
|
||||
cl_mem gInBuffer3 = NULL;
|
||||
cl_mem gOutBuffer[VECTOR_SIZE_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
cl_mem gOutBuffer2[VECTOR_SIZE_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
uint32_t gComputeDevices = 0;
|
||||
uint32_t gSimdSize = 1;
|
||||
uint32_t gDeviceFrequency = 0;
|
||||
static MTdata gMTdata;
|
||||
cl_device_fp_config gFloatCapabilities = 0;
|
||||
cl_device_fp_config gDoubleCapabilities = 0;
|
||||
int gWimpyReductionFactor = 32;
|
||||
int gWimpyBufferSize = BUFFER_SIZE;
|
||||
int gVerboseBruteForce = 0;
|
||||
@@ -110,15 +106,14 @@ int gVerboseBruteForce = 0;
|
||||
static int ParseArgs(int argc, const char **argv);
|
||||
static void PrintUsage(void);
|
||||
static void PrintFunctions(void);
|
||||
test_status InitCL(cl_device_id device);
|
||||
static test_status InitCL(cl_device_id device);
|
||||
static void ReleaseCL(void);
|
||||
static int InitILogbConstants(void);
|
||||
static int IsTininessDetectedBeforeRounding(void);
|
||||
static int
|
||||
IsInRTZMode(void); // expensive. Please check gIsInRTZMode global instead.
|
||||
|
||||
|
||||
int doTest(const char *name)
|
||||
static int doTest(const char *name)
|
||||
{
|
||||
if (gSkipRestOfTests)
|
||||
{
|
||||
@@ -747,7 +742,7 @@ int test_not(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
return doTest("not");
|
||||
}
|
||||
|
||||
test_definition test_list[] = {
|
||||
static test_definition test_list[] = {
|
||||
ADD_TEST(acos), ADD_TEST(acosh), ADD_TEST(acospi),
|
||||
ADD_TEST(asin), ADD_TEST(asinh), ADD_TEST(asinpi),
|
||||
ADD_TEST(atan), ADD_TEST(atanh), ADD_TEST(atanpi),
|
||||
@@ -784,7 +779,7 @@ test_definition test_list[] = {
|
||||
ADD_TEST(not),
|
||||
};
|
||||
|
||||
const int test_num = ARRAY_SIZE(test_list);
|
||||
static const int test_num = ARRAY_SIZE(test_list);
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@@ -1080,7 +1075,6 @@ test_status InitCL(cl_device_id device)
|
||||
{
|
||||
int error;
|
||||
uint32_t i;
|
||||
size_t configSize = sizeof(gComputeDevices);
|
||||
cl_device_type device_type;
|
||||
|
||||
error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(device_type),
|
||||
@@ -1092,18 +1086,16 @@ test_status InitCL(cl_device_id device)
|
||||
}
|
||||
|
||||
gDevice = device;
|
||||
if ((error = clGetDeviceInfo(gDevice, CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
configSize, &gComputeDevices, NULL)))
|
||||
gComputeDevices = 1;
|
||||
|
||||
// Check extensions
|
||||
if (is_extension_available(gDevice, "cl_khr_fp64"))
|
||||
{
|
||||
gHasDouble ^= 1;
|
||||
#if defined(CL_DEVICE_DOUBLE_FP_CONFIG)
|
||||
cl_device_fp_config doubleCapabilities = 0;
|
||||
if ((error = clGetDeviceInfo(gDevice, CL_DEVICE_DOUBLE_FP_CONFIG,
|
||||
sizeof(gDoubleCapabilities),
|
||||
&gDoubleCapabilities, NULL)))
|
||||
sizeof(doubleCapabilities),
|
||||
&doubleCapabilities, NULL)))
|
||||
{
|
||||
vlog_error("ERROR: Unable to get device "
|
||||
"CL_DEVICE_DOUBLE_FP_CONFIG. (%d)\n",
|
||||
@@ -1112,19 +1104,19 @@ test_status InitCL(cl_device_id device)
|
||||
}
|
||||
|
||||
if (DOUBLE_REQUIRED_FEATURES
|
||||
!= (gDoubleCapabilities & DOUBLE_REQUIRED_FEATURES))
|
||||
!= (doubleCapabilities & DOUBLE_REQUIRED_FEATURES))
|
||||
{
|
||||
std::string list;
|
||||
if (0 == (gDoubleCapabilities & CL_FP_FMA)) list += "CL_FP_FMA, ";
|
||||
if (0 == (gDoubleCapabilities & CL_FP_ROUND_TO_NEAREST))
|
||||
if (0 == (doubleCapabilities & CL_FP_FMA)) list += "CL_FP_FMA, ";
|
||||
if (0 == (doubleCapabilities & CL_FP_ROUND_TO_NEAREST))
|
||||
list += "CL_FP_ROUND_TO_NEAREST, ";
|
||||
if (0 == (gDoubleCapabilities & CL_FP_ROUND_TO_ZERO))
|
||||
if (0 == (doubleCapabilities & CL_FP_ROUND_TO_ZERO))
|
||||
list += "CL_FP_ROUND_TO_ZERO, ";
|
||||
if (0 == (gDoubleCapabilities & CL_FP_ROUND_TO_INF))
|
||||
if (0 == (doubleCapabilities & CL_FP_ROUND_TO_INF))
|
||||
list += "CL_FP_ROUND_TO_INF, ";
|
||||
if (0 == (gDoubleCapabilities & CL_FP_INF_NAN))
|
||||
if (0 == (doubleCapabilities & CL_FP_INF_NAN))
|
||||
list += "CL_FP_INF_NAN, ";
|
||||
if (0 == (gDoubleCapabilities & CL_FP_DENORM))
|
||||
if (0 == (doubleCapabilities & CL_FP_DENORM))
|
||||
list += "CL_FP_DENORM, ";
|
||||
vlog_error("ERROR: required double features are missing: %s\n",
|
||||
list.c_str());
|
||||
@@ -1138,10 +1130,11 @@ test_status InitCL(cl_device_id device)
|
||||
#endif
|
||||
}
|
||||
|
||||
configSize = sizeof(gDeviceFrequency);
|
||||
uint32_t deviceFrequency = 0;
|
||||
size_t configSize = sizeof(deviceFrequency);
|
||||
if ((error = clGetDeviceInfo(gDevice, CL_DEVICE_MAX_CLOCK_FREQUENCY,
|
||||
configSize, &gDeviceFrequency, NULL)))
|
||||
gDeviceFrequency = 0;
|
||||
configSize, &deviceFrequency, NULL)))
|
||||
deviceFrequency = 0;
|
||||
|
||||
if ((error = clGetDeviceInfo(gDevice, CL_DEVICE_SINGLE_FP_CONFIG,
|
||||
sizeof(gFloatCapabilities),
|
||||
@@ -1288,7 +1281,7 @@ test_status InitCL(cl_device_id device)
|
||||
vlog("\tCL C Version: %s\n", c);
|
||||
clGetDeviceInfo(gDevice, CL_DRIVER_VERSION, sizeof(c), &c, NULL);
|
||||
vlog("\tDriver Version: %s\n", c);
|
||||
vlog("\tDevice Frequency: %d MHz\n", gDeviceFrequency);
|
||||
vlog("\tDevice Frequency: %d MHz\n", deviceFrequency);
|
||||
vlog("\tSubnormal values supported for floats? %s\n",
|
||||
no_yes[0 != (CL_FP_DENORM & gFloatCapabilities)]);
|
||||
vlog("\tCorrectly rounded divide and sqrt supported for floats? %s\n",
|
||||
|
||||
@@ -56,22 +56,17 @@ extern cl_mem gInBuffer2;
|
||||
extern cl_mem gInBuffer3;
|
||||
extern cl_mem gOutBuffer[VECTOR_SIZE_COUNT];
|
||||
extern cl_mem gOutBuffer2[VECTOR_SIZE_COUNT];
|
||||
extern uint32_t gComputeDevices;
|
||||
extern uint32_t gSimdSize;
|
||||
extern int gSkipCorrectnessTesting;
|
||||
extern int gForceFTZ;
|
||||
extern int gFastRelaxedDerived;
|
||||
extern int gWimpyMode;
|
||||
extern int gHasDouble;
|
||||
extern int gIsInRTZMode;
|
||||
extern int gInfNanSupport;
|
||||
extern int gIsEmbedded;
|
||||
extern int gVerboseBruteForce;
|
||||
extern uint32_t gMaxVectorSizeIndex;
|
||||
extern uint32_t gMinVectorSizeIndex;
|
||||
extern uint32_t gDeviceFrequency;
|
||||
extern cl_device_fp_config gFloatCapabilities;
|
||||
extern cl_device_fp_config gDoubleCapabilities;
|
||||
|
||||
#define LOWER_IS_BETTER 0
|
||||
#define HIGHER_IS_BETTER 1
|
||||
|
||||
Reference in New Issue
Block a user