diff --git a/test_conformance/api/test_native_kernel.cpp b/test_conformance/api/test_native_kernel.cpp index 54979bd287..14d7887df6 100644 --- a/test_conformance/api/test_native_kernel.cpp +++ b/test_conformance/api/test_native_kernel.cpp @@ -46,13 +46,7 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue } clMemWrapper streams[ 2 ]; -#if !(defined(_WIN32) && defined(_MSC_VER)) - cl_int *inBuffer = new cl_int[n_elems * sizeof(cl_int)]; - cl_int *outBuffer = new cl_int[n_elems * sizeof(cl_int)]; -#else - cl_int* inBuffer = (cl_int *)_malloca( n_elems * sizeof(cl_int) ); - cl_int* outBuffer = (cl_int *)_malloca( n_elems * sizeof(cl_int) ); -#endif + std::vector inBuffer(n_elems * sizeof(cl_int)), outBuffer(n_elems * sizeof(cl_int)); clEventWrapper finishEvent; struct arg_struct @@ -64,11 +58,11 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue // Create some input values - generate_random_data( kInt, n_elems, seed, inBuffer ); + generate_random_data( kInt, n_elems, seed, inBuffer.data() ); // Create I/O streams - streams[ 0 ] = clCreateBuffer( context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int), inBuffer, &error ); + streams[ 0 ] = clCreateBuffer( context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int), inBuffer.data(), &error ); test_error( error, "Unable to create I/O stream" ); streams[ 1 ] = clCreateBuffer( context, 0, n_elems * sizeof(cl_int), NULL, &error ); test_error( error, "Unable to create I/O stream" ); @@ -98,22 +92,19 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue test_error(error, "clWaitForEvents failed"); // Now read the results and verify - error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, n_elems * sizeof(cl_int), outBuffer, 0, NULL, NULL ); + error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, n_elems * sizeof(cl_int), outBuffer.data(), 0, NULL, NULL ); test_error( error, "Unable to read results" ); for( int i = 0; i < n_elems; i++ ) { - if( inBuffer[ i ] != outBuffer[ i ] ) + if( inBuffer[ i * sizeof(cl_int) ] != outBuffer[ i * sizeof(cl_int) ] ) { log_error( "ERROR: Data sample %d for native kernel did not validate (expected %d, got %d)\n", - i, (int)inBuffer[ i ], (int)outBuffer[ i ] ); + i, (int)inBuffer[ i * sizeof(cl_int) ], (int)outBuffer[ i * sizeof(cl_int) ] ); return 1; } } -#if !(defined(_WIN32) && defined(_MSC_VER)) - delete[] inBuffer; - delete[] outBuffer; -#endif + return 0; } diff --git a/test_conformance/buffers/test_sub_buffers.cpp b/test_conformance/buffers/test_sub_buffers.cpp index 1b1f2b92d4..6feae5e1e1 100644 --- a/test_conformance/buffers/test_sub_buffers.cpp +++ b/test_conformance/buffers/test_sub_buffers.cpp @@ -16,6 +16,7 @@ #include "procs.h" #include +#include // Design: // To test sub buffers, we first create one main buffer. We then create several sub-buffers and @@ -413,16 +414,12 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context size_t param_size; error = clGetDeviceInfo(otherDevice, CL_DEVICE_NAME, 0, NULL, ¶m_size ); test_error( error, "Error obtaining device name" ); + std::vector device_name(param_size); -#if !(defined(_WIN32) && defined(_MSC_VER)) - char *device_name = new char[param_size]; -#else - char* device_name = (char*)_malloca(param_size); -#endif error = clGetDeviceInfo(otherDevice, CL_DEVICE_NAME, param_size, &device_name[0], NULL ); test_error( error, "Error obtaining device name" ); - log_info( "\tOther device obtained for dual device test is type %s\n", device_name ); + log_info( "\tOther device obtained for dual device test is type %s\n", device_name.data() ); // Create a shared context for these two devices cl_device_id devices[ 2 ] = { deviceID, otherDevice }; @@ -453,9 +450,6 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context test_error( error, "Unable to get secondary device's address alignment" ); cl_uint addressAlign1 = std::max(addressAlign1Bits, addressAlign2Bits) / 8; -#if !(defined(_WIN32) && defined(_MSC_VER)) - delete[] device_name; -#endif // Finally time to run! return test_sub_buffers_read_write_core( testingContext, queue1, queue2, maxBuffer1, addressAlign1 ); } diff --git a/test_conformance/gl/test_buffers.cpp b/test_conformance/gl/test_buffers.cpp index eec75de2f7..96f712bf51 100644 --- a/test_conformance/gl/test_buffers.cpp +++ b/test_conformance/gl/test_buffers.cpp @@ -127,15 +127,8 @@ int test_buffer_kernel(cl_context context, cl_command_queue queue, clKernelWrapper kernel; clMemWrapper streams[3]; size_t dataSize = numElements * 16 * sizeof(cl_long); -#if !(defined(_WIN32) && defined(_MSC_VER)) - cl_long *inData = (cl_long *)malloc(dataSize); - cl_long *outDataCL = (cl_long *)malloc(dataSize); - cl_long *outDataGL = (cl_long *)malloc(dataSize); -#else - cl_long *inData = (cl_long *)_malloca(dataSize); - cl_long *outDataCL = (cl_long *)_malloca(dataSize); - cl_long *outDataGL = (cl_long *)_malloca(dataSize); -#endif + std::vector inData(dataSize), outDataCL(dataSize), outDataGL(dataSize); + glBufferWrapper inGLBuffer, outGLBuffer; int i; size_t bufferSize; @@ -169,21 +162,21 @@ int test_buffer_kernel(cl_context context, cl_command_queue queue, bufferSize = numElements * vecSize * get_explicit_type_size(vecType); /* Generate some almost-random input data */ - gen_input_data(vecType, vecSize * numElements, d, inData); - memset(outDataCL, 0, dataSize); - memset(outDataGL, 0, dataSize); + gen_input_data(vecType, vecSize * numElements, d, inData.data()); + outDataCL.clear(); + outDataGL.clear(); /* Generate some GL buffers to go against */ glGenBuffers(1, &inGLBuffer); glGenBuffers(1, &outGLBuffer); glBindBuffer(GL_ARRAY_BUFFER, inGLBuffer); - glBufferData(GL_ARRAY_BUFFER, bufferSize, inData, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, bufferSize, inData.data(), GL_STATIC_DRAW); // Note: we need to bind the output buffer, even though we don't care about // its values yet, because CL needs it to get the buffer size glBindBuffer(GL_ARRAY_BUFFER, outGLBuffer); - glBufferData(GL_ARRAY_BUFFER, bufferSize, outDataGL, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, bufferSize, outDataGL.data(), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glFinish(); @@ -258,16 +251,16 @@ int test_buffer_kernel(cl_context context, cl_command_queue queue, // Get the results from both CL and GL and make sure everything looks // correct error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0, bufferSize, - outDataCL, 0, NULL, NULL); + outDataCL.data(), 0, NULL, NULL); test_error(error, "Unable to read output CL array!"); glBindBuffer(GL_ARRAY_BUFFER, outGLBuffer); void *glMem = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY); - memcpy(outDataGL, glMem, bufferSize); + memcpy(outDataGL.data(), glMem, bufferSize); glUnmapBuffer(GL_ARRAY_BUFFER); - char *inP = (char *)inData, *glP = (char *)outDataGL, - *clP = (char *)outDataCL; + char *inP = (char *)inData.data(), *glP = (char *)outDataGL.data(), + *clP = (char *)outDataCL.data(); error = 0; for (size_t i = 0; i < numElements * vecSize; i++) { diff --git a/test_conformance/relationals/test_shuffles.cpp b/test_conformance/relationals/test_shuffles.cpp index 6a711556a4..d888725466 100644 --- a/test_conformance/relationals/test_shuffles.cpp +++ b/test_conformance/relationals/test_shuffles.cpp @@ -15,7 +15,7 @@ // #include - +#include #include "testBase.h" #include "harness/conversions.h" #include "harness/typeWrappers.h" @@ -619,32 +619,23 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue, return error; typeSize = get_explicit_type_size( vecType ); + std::vector inData(inVecSize * numOrders * sizeof(cl_long)); + std::vector inSecondData(inVecSize * numOrders * sizeof(cl_long)); + std::vector outData(outRealVecSize * numOrders * sizeof(cl_long)); -#if !(defined(_WIN32) && defined (_MSC_VER)) - cl_long *inData = new cl_long[inVecSize * numOrders * sizeof(cl_long)]; - cl_long *inSecondData = - new cl_long[inVecSize * numOrders * sizeof(cl_long)]; - cl_long *outData = - new cl_long[outRealVecSize * numOrders * sizeof(cl_long)]; -#else - cl_long* inData = (cl_long*)_malloca(inVecSize * numOrders * sizeof(cl_long)); - cl_long* inSecondData = (cl_long*)_malloca(inVecSize * numOrders * sizeof(cl_long)); - cl_long* outData = (cl_long*)_malloca(outRealVecSize * numOrders * sizeof(cl_long)); -#endif - memset(outData, 0, outRealVecSize * numOrders * sizeof(cl_long) ); - - generate_random_data( vecType, (unsigned int)( numOrders * inVecSize ), d, inData ); + outData.clear(); + generate_random_data( vecType, (unsigned int)( numOrders * inVecSize ), d, inData.data() ); if( shuffleMode == kBuiltInDualInputFnMode ) - generate_random_data( vecType, (unsigned int)( numOrders * inVecSize ), d, inSecondData ); + generate_random_data( vecType, (unsigned int)( numOrders * inVecSize ), d, inSecondData.data() ); streams[0] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, - typeSize * inVecSize * numOrders, inData, &error); + typeSize * inVecSize * numOrders, inData.data(), &error); test_error( error, "Unable to create input stream" ); streams[1] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, - typeSize * outRealVecSize * numOrders, outData, &error); + typeSize * outRealVecSize * numOrders, outData.data(), &error); test_error( error, "Unable to create output stream" ); int argIndex = 0; @@ -652,7 +643,7 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue, { streams[2] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, typeSize * inVecSize * numOrders, - inSecondData, &error); + inSecondData.data(), &error); test_error( error, "Unable to create second input stream" ); error = clSetKernelArg( kernel, argIndex++, sizeof( streams[ 2 ] ), &streams[ 2 ] ); @@ -677,12 +668,12 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue, // Read the results back - error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, typeSize * numOrders * outRealVecSize, outData, 0, NULL, NULL ); + error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, typeSize * numOrders * outRealVecSize, outData.data(), 0, NULL, NULL ); test_error( error, "Unable to read results" ); - unsigned char *inDataPtr = (unsigned char *)inData; - unsigned char *inSecondDataPtr = (unsigned char *)inSecondData; - unsigned char *outDataPtr = (unsigned char *)outData; + unsigned char *inDataPtr = (unsigned char *)inData.data(); + unsigned char *inSecondDataPtr = (unsigned char *)inSecondData.data(); + unsigned char *outDataPtr = (unsigned char *)outData.data(); int ret = 0; int errors_printed = 0; for( size_t i = 0; i < numOrders; i++ ) @@ -728,11 +719,15 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue, inSecondDataPtr += inVecSize * typeSize; outDataPtr += outRealVecSize * typeSize; } +<<<<<<< HEAD #if !(defined(_WIN32) && defined(_MSC_VER)) delete[] inData; delete[] inSecondData; delete[] outData; #endif +======= + +>>>>>>> d6d7693 (Fix build errors related with variable defined array length and gl tests logged error) return ret; }