gles: Fix compile warnings. (#1070)

* gles: Fix compile warnings.

For 32 and 64-bit Visual Studio and the Android Q NDK.

* Fix formatting violations

Co-authored-by: spauls <spauls@qti.qualcomm.com>
This commit is contained in:
Sreelakshmi Haridas Maruthur
2021-05-18 11:10:24 -06:00
committed by GitHub
parent 17a0d09567
commit 6c8045911a
23 changed files with 136 additions and 210 deletions

View File

@@ -1,6 +1,5 @@
set(HARNESS_SOURCES
harness/threadTesting.cpp
harness/typeWrappers.cpp
harness/mt19937.cpp
harness/conversions.cpp
@@ -23,3 +22,7 @@ set(HARNESS_SOURCES
add_library(harness STATIC ${HARNESS_SOURCES})
if(MSVC)
# Don't warn about using the portable "strdup" function.
target_compile_definitions(harness PRIVATE _CRT_NONSTDC_NO_DEPRECATE)
endif()

View File

@@ -22,7 +22,7 @@
{GLint __error = glGetError(); if(__error) {log_error( "GL ERROR: %s!\n", gluErrorString( err ));}}
#if defined(__linux__) || defined(GL_ES_VERSION_2_0)
// On linux we dont link to GLU library to avoid comaptibility issues with
// On linux we don't link to GLU library to avoid compatibility issues with
// libstdc++
// FIXME: Implement this
const GLubyte* gluErrorString (GLenum error)
@@ -271,8 +271,6 @@ void * ReadGLTexture( GLenum glTarget, GLuint glTexture,
// Read results from the GL texture
glBindTexture(get_base_gl_target(glTarget), glTexture);
GLint realWidth, realHeight;
GLint realInternalFormat;
GLenum readBackFormat = GL_RGBA;
GLenum readBackType = glType;
glFramebufferWrapper glFramebuffer;
@@ -301,7 +299,7 @@ void * ReadGLTexture( GLenum glTarget, GLuint glTexture,
GetGLFormatName(readBackFormat),
GetGLTypeName(readBackType));
DumpGLBuffer(readBackType, realWidth, realHeight, (void*)outBuffer);
DumpGLBuffer(readBackType, outWidth, outHeight, (void *)outBuffer);
#endif

View File

@@ -30,11 +30,10 @@
#if !defined (__APPLE__)
#include <CL/cl.h>
#include "gl_headers.h"
#include <CL/cl_gl.h>
#else
#include "gl_headers.h"
#include <CL/cl_half.h>
#endif
#include "gl_headers.h"
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"

View File

@@ -523,7 +523,7 @@ void ThreadPool_Init(void)
{
// Count the number of bits in ProcessorMask (number of
// logical cores)
ULONG mask = ptr->ProcessorMask;
ULONG_PTR mask = ptr->ProcessorMask;
while (mask)
{
++gThreadCount;
@@ -688,7 +688,10 @@ static BOOL CALLBACK _ThreadPool_Init(_PINIT_ONCE InitOnce, PVOID Parameter,
void ThreadPool_Exit(void)
{
int err, count;
#ifndef _WIN32
int err;
#endif
int count;
gRunCount = CL_INT_MAX;
#if defined(__GNUC__)
@@ -738,7 +741,9 @@ void ThreadPool_Exit(void)
// all available then it would make more sense to use those features.
cl_int ThreadPool_Do(TPFuncPtr func_ptr, cl_uint count, void *userInfo)
{
#ifndef _WIN32
cl_int newErr;
#endif
cl_int err = 0;
// Lazily set up our threads
#if defined(_MSC_VER) && (_WIN32_WINNT >= 0x600)
@@ -913,7 +918,9 @@ cl_int ThreadPool_Do(TPFuncPtr func_ptr, cl_uint count, void *userInfo)
err = jobError;
#ifndef _WIN32
exit:
#endif
// exit critical region
#if defined(_WIN32)
LeaveCriticalSection(gThreadPoolLock);

View File

@@ -18,13 +18,13 @@
#if defined(_WIN32) && defined(_MSC_VER)
#include <Windows.h>
#endif
#else
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#endif
//

View File

@@ -181,8 +181,8 @@ static ULong sUpperLimits[kNumExplicitTypes] = {
0xffffffffLL,
0xffffffffLL,
0x7fffffffffffffffLL,
0xffffffffffffffffLL,
0xffffffffffffffffLL,
0xffffffffffffffffULL,
0xffffffffffffffffULL,
0,
0
}; // Last two values aren't stored here

View File

@@ -564,7 +564,7 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL,
&size_ret);
test_error(error, "Unable to query context's device size");
num_devices = size_ret / sizeof(cl_device_id);
num_devices = static_cast<cl_uint>(size_ret / sizeof(cl_device_id));
device_list = (cl_device_id *)malloc(size_ret);
if (device_list == NULL)
{
@@ -695,7 +695,7 @@ int check_functions_for_offline_compiler(const char *subtestname,
{
if (gCompilationMode != kOnline)
{
int nNotRequiredWithOfflineCompiler =
size_t nNotRequiredWithOfflineCompiler =
sizeof(subtests_to_skip_with_offline_compiler) / sizeof(char *);
size_t i;
for (i = 0; i < nNotRequiredWithOfflineCompiler; ++i)
@@ -707,4 +707,4 @@ int check_functions_for_offline_compiler(const char *subtestname,
}
}
return 0;
}
}

View File

@@ -56,11 +56,6 @@ static int vlog_win32(const char *format, ...);
#define vlog printf
#endif
#define ct_assert(b) ct_assert_i(b, __LINE__)
#define ct_assert_i(b, line) ct_assert_ii(b, line)
#define ct_assert_ii(b, line) \
int _compile_time_assertion_on_line_##line[b ? 1 : -1];
#define test_fail(msg, ...) \
{ \
log_error(msg, ##__VA_ARGS__); \

View File

@@ -30,7 +30,11 @@
// that rounding mode.
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__linux__) \
|| defined(__MINGW32__)
#ifdef _MSC_VER
typedef int FPU_mode_type;
#else
typedef int64_t FPU_mode_type;
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) \
|| defined(__MINGW32__)
#include <xmmintrin.h>
@@ -55,7 +59,7 @@ inline void ForceFTZ(FPU_mode_type *mode)
__asm__ volatile("fmxr fpscr, %0" ::"r"(fpscr | (1U << 24)));
// Add 64 bit support
#elif defined(__aarch64__)
unsigned fpscr;
uint64_t fpscr;
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr | (1U << 24)));
@@ -81,7 +85,7 @@ inline void DisableFTZ(FPU_mode_type *mode)
__asm__ volatile("fmxr fpscr, %0" ::"r"(fpscr & ~(1U << 24)));
// Add 64 bit support
#elif defined(__aarch64__)
unsigned fpscr;
uint64_t fpscr;
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr & ~(1U << 24)));

View File

@@ -554,8 +554,8 @@ struct AddressingTable
{
AddressingTable()
{
ct_assert((CL_ADDRESS_MIRRORED_REPEAT - CL_ADDRESS_NONE < 6));
ct_assert(CL_FILTER_NEAREST - CL_FILTER_LINEAR < 2);
static_assert(CL_ADDRESS_MIRRORED_REPEAT - CL_ADDRESS_NONE < 6, "");
static_assert(CL_FILTER_NEAREST - CL_FILTER_LINEAR < 2, "");
mTable[CL_ADDRESS_NONE - CL_ADDRESS_NONE]
[CL_FILTER_NEAREST - CL_FILTER_NEAREST] = NoAddressFn;
@@ -719,7 +719,7 @@ void get_max_sizes(
if (usingMaxPixelSizeBuffer || raw_pixel_size == 12) raw_pixel_size = 16;
size_t max_pixels = (size_t)maxAllocSize / raw_pixel_size;
log_info("Maximums: [%ld x %ld x %ld], raw pixel size %lu bytes, "
log_info("Maximums: [%zu x %zu x %zu], raw pixel size %zu bytes, "
"per-allocation limit %gMB.\n",
maxWidth, maxHeight, isArray ? maxArraySize : maxDepth,
raw_pixel_size, (maxAllocSize / (1024.0 * 1024.0)));
@@ -760,10 +760,10 @@ void get_max_sizes(
if (image_type == CL_MEM_OBJECT_IMAGE1D)
{
double M = maximum_sizes[0];
size_t M = maximum_sizes[0];
// Store the size
sizes[(*numberOfSizes)][0] = (size_t)M;
sizes[(*numberOfSizes)][0] = M;
sizes[(*numberOfSizes)][1] = 1;
sizes[(*numberOfSizes)][2] = 1;
++(*numberOfSizes);
@@ -777,17 +777,17 @@ void get_max_sizes(
{
// Determine the size of the fixed dimension
double M = maximum_sizes[fixed_dim];
double A = max_pixels;
size_t M = maximum_sizes[fixed_dim];
size_t A = max_pixels;
int x0_dim = !fixed_dim;
double x0 =
size_t x0 = static_cast<size_t>(
fmin(fmin(other_sizes[(other_size++) % num_other_sizes], A / M),
maximum_sizes[x0_dim]);
maximum_sizes[x0_dim]));
// Store the size
sizes[(*numberOfSizes)][fixed_dim] = (size_t)M;
sizes[(*numberOfSizes)][x0_dim] = (size_t)x0;
sizes[(*numberOfSizes)][fixed_dim] = M;
sizes[(*numberOfSizes)][x0_dim] = x0;
sizes[(*numberOfSizes)][2] = 1;
++(*numberOfSizes);
}
@@ -802,16 +802,17 @@ void get_max_sizes(
{
// Determine the size of the fixed dimension
double M = maximum_sizes[fixed_dim];
double A = max_pixels;
size_t M = maximum_sizes[fixed_dim];
size_t A = max_pixels;
// Find two other dimensions, x0 and x1
int x0_dim = (fixed_dim == 0) ? 1 : 0;
int x1_dim = (fixed_dim == 2) ? 1 : 2;
// Choose two other sizes for these dimensions
double x0 = fmin(fmin(A / M, maximum_sizes[x0_dim]),
other_sizes[(other_size++) % num_other_sizes]);
size_t x0 = static_cast<size_t>(
fmin(fmin(A / M, maximum_sizes[x0_dim]),
other_sizes[(other_size++) % num_other_sizes]));
// GPUs have certain restrictions on minimum width (row alignment)
// of images which has given us issues testing small widths in this
// test (say we set width to 3 for testing, and compute size based
@@ -820,8 +821,9 @@ void get_max_sizes(
// width of 16 which doesnt fit in vram). For this purpose we are
// not testing width < 16 for this test.
if (x0_dim == 0 && x0 < 16) x0 = 16;
double x1 = fmin(fmin(A / M / x0, maximum_sizes[x1_dim]),
other_sizes[(other_size++) % num_other_sizes]);
size_t x1 = static_cast<size_t>(
fmin(fmin(A / M / x0, maximum_sizes[x1_dim]),
other_sizes[(other_size++) % num_other_sizes]));
// Valid image sizes cannot be below 1. Due to the workaround for
// the xo_dim where x0 is overidden to 16 there might not be enough
@@ -834,9 +836,9 @@ void get_max_sizes(
assert(x0 > 0 && M > 0);
// Store the size
sizes[(*numberOfSizes)][fixed_dim] = (size_t)M;
sizes[(*numberOfSizes)][x0_dim] = (size_t)x0;
sizes[(*numberOfSizes)][x1_dim] = (size_t)x1;
sizes[(*numberOfSizes)][fixed_dim] = M;
sizes[(*numberOfSizes)][x0_dim] = x0;
sizes[(*numberOfSizes)][x1_dim] = x1;
++(*numberOfSizes);
}
}
@@ -847,20 +849,20 @@ void get_max_sizes(
switch (image_type)
{
case CL_MEM_OBJECT_IMAGE1D:
log_info(" size[%d] = [%ld] (%g MB image)\n", j, sizes[j][0],
log_info(" size[%d] = [%zu] (%g MB image)\n", j, sizes[j][0],
raw_pixel_size * sizes[j][0] * sizes[j][1]
* sizes[j][2] / (1024.0 * 1024.0));
break;
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
case CL_MEM_OBJECT_IMAGE2D:
log_info(" size[%d] = [%ld %ld] (%g MB image)\n", j,
log_info(" size[%d] = [%zu %zu] (%g MB image)\n", j,
sizes[j][0], sizes[j][1],
raw_pixel_size * sizes[j][0] * sizes[j][1]
* sizes[j][2] / (1024.0 * 1024.0));
break;
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
case CL_MEM_OBJECT_IMAGE3D:
log_info(" size[%d] = [%ld %ld %ld] (%g MB image)\n", j,
log_info(" size[%d] = [%zu %zu %zu] (%g MB image)\n", j,
sizes[j][0], sizes[j][1], sizes[j][2],
raw_pixel_size * sizes[j][0] * sizes[j][1]
* sizes[j][2] / (1024.0 * 1024.0));
@@ -1124,12 +1126,13 @@ void escape_inf_nan_values(char *data, size_t allocSize)
char *generate_random_image_data(image_descriptor *imageInfo,
BufferOwningPtr<char> &P, MTdata d)
{
size_t allocSize = get_image_size(imageInfo);
size_t allocSize = static_cast<size_t>(get_image_size(imageInfo));
size_t pixelRowBytes = imageInfo->width * get_pixel_size(imageInfo->format);
size_t i;
if (imageInfo->num_mip_levels > 1)
allocSize = compute_mipmapped_image_size(*imageInfo);
allocSize =
static_cast<size_t>(compute_mipmapped_image_size(*imageInfo));
#if defined(__APPLE__)
char *data = NULL;
@@ -1161,7 +1164,7 @@ char *generate_random_image_data(image_descriptor *imageInfo,
if (data == NULL)
{
log_error("ERROR: Unable to malloc %lu bytes for "
log_error("ERROR: Unable to malloc %zu bytes for "
"generate_random_image_data\n",
allocSize);
return 0;
@@ -1678,24 +1681,26 @@ bool get_integer_coords_offset(float x, float y, float z, float xAddressOffset,
// At this point, we're dealing with non-normalized coordinates.
outX = adFn(floorf(x), width);
outX = adFn(static_cast<int>(floorf(x)), width);
// 1D and 2D arrays require special care for the index coordinate:
switch (imageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
outY = calculate_array_index(y, (float)imageInfo->arraySize - 1.0f);
outZ = 0.0f; /* don't care! */
outY = static_cast<int>(
calculate_array_index(y, (float)imageInfo->arraySize - 1.0f));
outZ = 0; /* don't care! */
break;
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
outY = adFn(floorf(y), height);
outZ = calculate_array_index(z, (float)imageInfo->arraySize - 1.0f);
outY = adFn(static_cast<int>(floorf(y)), height);
outZ = static_cast<int>(
calculate_array_index(z, (float)imageInfo->arraySize - 1.0f));
break;
default:
// legacy path:
if (height != 0) outY = adFn(floorf(y), height);
if (depth != 0) outZ = adFn(floorf(z), depth);
if (height != 0) outY = adFn(static_cast<int>(floorf(y)), height);
if (depth != 0) outZ = adFn(static_cast<int>(floorf(z)), depth);
}
return !((int)refX == outX && (int)refY == outY && (int)refZ == outZ);
@@ -1766,7 +1771,7 @@ static float unnormalize_coordinate(const char *name, float coord, float offset,
switch (addressing_mode)
{
case CL_ADDRESS_REPEAT:
ret = RepeatNormalizedAddressFn(coord, extent);
ret = RepeatNormalizedAddressFn(coord, static_cast<size_t>(extent));
if (verbose)
{
@@ -1790,7 +1795,8 @@ static float unnormalize_coordinate(const char *name, float coord, float offset,
break;
case CL_ADDRESS_MIRRORED_REPEAT:
ret = MirroredRepeatNormalizedAddressFn(coord, extent);
ret = MirroredRepeatNormalizedAddressFn(
coord, static_cast<size_t>(extent));
if (verbose)
{
@@ -1968,13 +1974,13 @@ FloatPixel sample_image_pixel_float_offset(
// coordinates. Note that the array cases again require special
// care, per section 8.4 in the OpenCL 1.2 Specification.
ix = adFn(floorf(x), width_lod);
ix = adFn(static_cast<int>(floorf(x)), width_lod);
switch (imageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
iy =
calculate_array_index(y, (float)(imageInfo->arraySize - 1));
iy = static_cast<int>(calculate_array_index(
y, (float)(imageInfo->arraySize - 1)));
iz = 0;
if (verbose)
{
@@ -1982,18 +1988,18 @@ FloatPixel sample_image_pixel_float_offset(
}
break;
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
iy = adFn(floorf(y), height_lod);
iz =
calculate_array_index(z, (float)(imageInfo->arraySize - 1));
iy = adFn(static_cast<int>(floorf(y)), height_lod);
iz = static_cast<int>(calculate_array_index(
z, (float)(imageInfo->arraySize - 1)));
if (verbose)
{
log_info("\tArray index %f evaluates to %d\n", z, iz);
}
break;
default:
iy = adFn(floorf(y), height_lod);
iy = adFn(static_cast<int>(floorf(y)), height_lod);
if (depth_lod != 0)
iz = adFn(floorf(z), depth_lod);
iz = adFn(static_cast<int>(floorf(z)), depth_lod);
else
iz = 0;
}
@@ -2047,16 +2053,16 @@ FloatPixel sample_image_pixel_float_offset(
height = 1;
}
int x1 = adFn(floorf(x - 0.5f), width);
int x1 = adFn(static_cast<int>(floorf(x - 0.5f)), width);
int y1 = 0;
int x2 = adFn(floorf(x - 0.5f) + 1, width);
int x2 = adFn(static_cast<int>(floorf(x - 0.5f) + 1), width);
int y2 = 0;
if ((imageInfo->type != CL_MEM_OBJECT_IMAGE1D)
&& (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_ARRAY)
&& (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER))
{
y1 = adFn(floorf(y - 0.5f), height);
y2 = adFn(floorf(y - 0.5f) + 1, height);
y1 = adFn(static_cast<int>(floorf(y - 0.5f)), height);
y2 = adFn(static_cast<int>(floorf(y - 0.5f) + 1), height);
}
else
{
@@ -2147,12 +2153,12 @@ FloatPixel sample_image_pixel_float_offset(
else
{
// 3D linear filtering
int x1 = adFn(floorf(x - 0.5f), width_lod);
int y1 = adFn(floorf(y - 0.5f), height_lod);
int z1 = adFn(floorf(z - 0.5f), depth_lod);
int x2 = adFn(floorf(x - 0.5f) + 1, width_lod);
int y2 = adFn(floorf(y - 0.5f) + 1, height_lod);
int z2 = adFn(floorf(z - 0.5f) + 1, depth_lod);
int x1 = adFn(static_cast<int>(floorf(x - 0.5f)), width_lod);
int y1 = adFn(static_cast<int>(floorf(y - 0.5f)), height_lod);
int z1 = adFn(static_cast<int>(floorf(z - 0.5f)), depth_lod);
int x2 = adFn(static_cast<int>(floorf(x - 0.5f) + 1), width_lod);
int y2 = adFn(static_cast<int>(floorf(y - 0.5f) + 1), height_lod);
int z2 = adFn(static_cast<int>(floorf(z - 0.5f) + 1), depth_lod);
if (verbose)
log_info("\tActual integer coords used (i = floor(x-.5)): "
@@ -2899,15 +2905,18 @@ void pack_image_pixel_error(const float *srcVector,
case CL_UNSIGNED_INT8: {
const cl_uchar *ptr = (const cl_uchar *)results;
for (unsigned int i = 0; i < channelCount; i++)
errors[i] = (cl_int)ptr[i]
- (cl_int)CONVERT_UINT(srcVector[i], 255.f, CL_UCHAR_MAX);
errors[i] = static_cast<float>(
(cl_int)ptr[i]
- (cl_int)CONVERT_UINT(srcVector[i], 255.f, CL_UCHAR_MAX));
break;
}
case CL_UNSIGNED_INT16: {
const cl_ushort *ptr = (const cl_ushort *)results;
for (unsigned int i = 0; i < channelCount; i++)
errors[i] = (cl_int)ptr[i]
- (cl_int)CONVERT_UINT(srcVector[i], 32767.f, CL_USHRT_MAX);
errors[i] = static_cast<float>(
(cl_int)ptr[i]
- (cl_int)CONVERT_UINT(srcVector[i], 32767.f,
CL_USHRT_MAX));
break;
}
case CL_UNSIGNED_INT32: {
@@ -3228,7 +3237,7 @@ char *create_random_image_data(ExplicitType dataType,
if (data == NULL)
{
log_error(
"ERROR: Unable to malloc %lu bytes for create_random_image_data\n",
"ERROR: Unable to malloc %zu bytes for create_random_image_data\n",
allocSize);
return NULL;
}
@@ -3988,7 +3997,8 @@ bool is_image_format_required(cl_image_format format, cl_mem_flags flags,
cl_uint compute_max_mip_levels(size_t width, size_t height, size_t depth)
{
cl_uint retMaxMipLevels = 0, max_dim = 0;
cl_uint retMaxMipLevels = 0;
size_t max_dim = 0;
max_dim = width;
max_dim = height > max_dim ? height : max_dim;

View File

@@ -579,7 +579,7 @@ static int create_single_kernel_helper_create_program_offline(
if (error != CL_SUCCESS) return error;
ifs.seekg(0, ifs.end);
int length = ifs.tellg();
size_t length = static_cast<size_t>(ifs.tellg());
ifs.seekg(0, ifs.beg);
// treat modifiedProgram as input for clCreateProgramWithBinary
@@ -1226,7 +1226,7 @@ int is_image_format_supported(cl_context context, cl_mem_flags flags,
list = (cl_image_format *)malloc(count * sizeof(cl_image_format));
if (NULL == list)
{
log_error("Error: unable to allocate %ld byte buffer for image format "
log_error("Error: unable to allocate %zu byte buffer for image format "
"list at %s:%d (err = %d)\n",
count * sizeof(cl_image_format), __FILE__, __LINE__, err);
return 0;

View File

@@ -404,7 +404,8 @@ std::string exe_path()
for (;;)
{
DWORD len = GetModuleFileNameA(NULL, &path.front(), path.size());
DWORD len = GetModuleFileNameA(NULL, &path.front(),
static_cast<DWORD>(path.size()));
if (len == 0)
{

View File

@@ -97,15 +97,16 @@ int compareProperties(const std::vector<cl_properties>& queried,
if (!found)
{
log_error("ERROR: expected property 0x%x not found!\n",
log_error("ERROR: expected property 0x%llx not found!\n",
check_prop);
return TEST_FAIL;
}
else if (check_value != queried_value)
{
log_error("ERROR: mis-matched value for property 0x%x: wanted "
"0x%x, got 0x%x\n",
check_prop, check_value, queried_value);
log_error(
"ERROR: mis-matched value for property 0x%llx: wanted "
"0x%llx, got 0x%llx\n",
check_prop, check_value, queried_value);
return TEST_FAIL;
}
}
@@ -113,7 +114,7 @@ int compareProperties(const std::vector<cl_properties>& queried,
if (queried.size() > check.size())
{
log_error("ERROR: all properties found but there are extra "
"properties: expected %d, got %d.\n",
"properties: expected %zu, got %zu.\n",
check.size(), queried.size());
return TEST_FAIL;
}

View File

@@ -48,7 +48,7 @@ RoundingMode set_round(RoundingMode r, Type outType)
const int *p = int_rounds;
if (outType == kfloat || outType == kdouble) p = flt_rounds;
int fpscr = 0;
int64_t fpscr = 0;
RoundingMode oldRound = get_round();
_FPU_GETCW(fpscr);
@@ -59,7 +59,7 @@ RoundingMode set_round(RoundingMode r, Type outType)
RoundingMode get_round(void)
{
int fpscr;
int64_t fpscr;
int oldRound;
_FPU_GETCW(fpscr);
@@ -203,13 +203,13 @@ void *FlushToZero(void)
#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
int i;
unsigned int i;
void *p;
} u = { _mm_getcsr() };
_mm_setcsr(u.i | 0x8040);
return u.p;
#elif defined(__arm__) || defined(__aarch64__)
int fpscr;
int64_t fpscr;
_FPU_GETCW(fpscr);
_FPU_SETCW(fpscr | FPSCR_FZ);
return NULL;
@@ -239,7 +239,7 @@ void UnFlushToZero(void *p)
} u = { p };
_mm_setcsr(u.i);
#elif defined(__arm__) || defined(__aarch64__)
int fpscr;
int64_t fpscr;
_FPU_GETCW(fpscr);
_FPU_SETCW(fpscr & ~FPSCR_FZ);
#elif defined(__PPC__)

View File

@@ -16,8 +16,6 @@
#ifndef __ROUNDING_MODE_H__
#define __ROUNDING_MODE_H__
#pragma STDC FENV_ACCESS ON
#include "compat.h"
#if (defined(_WIN32) && defined(_MSC_VER))

View File

@@ -1,98 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "compat.h"
#include "threadTesting.h"
#include "errorHelpers.h"
#include <stdio.h>
#include <string.h>
#if !defined(_WIN32)
#include <pthread.h>
#endif
#if 0 // Disabed for now
typedef struct
{
basefn mFunction;
cl_device_id mDevice;
cl_context mContext;
int mNumElements;
} TestFnArgs;
////////////////////////////////////////////////////////////////////////////////
// Thread-based testing. Spawns a new thread to run the given test function,
// then waits for it to complete. The entire idea is that, if the thread crashes,
// we can catch it and report it as a failure instead of crashing the entire suite
////////////////////////////////////////////////////////////////////////////////
void *test_thread_wrapper( void *data )
{
TestFnArgs *args;
int retVal;
cl_context context;
args = (TestFnArgs *)data;
/* Create a new context to use (contexts can't cross threads) */
context = clCreateContext(NULL, args->mDeviceGroup);
if( context == NULL )
{
log_error("clCreateContext failed for new thread\n");
return (void *)(-1);
}
/* Call function */
retVal = args->mFunction( args->mDeviceGroup, args->mDevice, context, args->mNumElements );
clReleaseContext( context );
return (void *)retVal;
}
int test_threaded_function( basefn fnToTest, cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
{
int error;
pthread_t threadHdl;
void *retVal;
TestFnArgs args;
args.mFunction = fnToTest;
args.mDeviceGroup = deviceGroup;
args.mDevice = device;
args.mContext = context;
args.mNumElements = numElements;
error = pthread_create( &threadHdl, NULL, test_thread_wrapper, (void *)&args );
if( error != 0 )
{
log_error( "ERROR: Unable to create thread for testing!\n" );
return -1;
}
/* Thread has been started, now just wait for it to complete (or crash) */
error = pthread_join( threadHdl, &retVal );
if( error != 0 )
{
log_error( "ERROR: Unable to join testing thread!\n" );
return -1;
}
return (int)((intptr_t)retVal);
}
#endif

View File

@@ -24,8 +24,5 @@
typedef int (*basefn)(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_threaded_function(basefn fnToTest, cl_device_id device,
cl_context context, cl_command_queue queue,
int numElements);
#endif // _threadTesting_h
#endif // _threadTesting_h