mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-20 14:39:01 +00:00
Use clMemWrapper in math_brute_force (#1476)
Simplify code by avoiding manual resource management. Original patch by Marco Antognini. Signed-off-by: Marco Antognini <marco.antognini@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com> Signed-off-by: Marco Antognini <marco.antognini@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
8f5a2f0ae8
commit
f94c135755
@@ -124,9 +124,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -793,10 +795,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -122,9 +122,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -950,10 +952,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -123,9 +123,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -715,10 +717,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -121,9 +121,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -708,10 +710,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -123,9 +123,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -760,10 +762,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -121,9 +121,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double
|
||||
maxErrorValue; // position of the max error value (param 1). Init to 0.
|
||||
@@ -887,10 +889,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -28,6 +28,9 @@ using KernelMatrix = std::array<std::vector<cl_kernel>, VECTOR_SIZE_COUNT>;
|
||||
// Array of programs for each vector size.
|
||||
using Programs = std::array<clProgramWrapper, VECTOR_SIZE_COUNT>;
|
||||
|
||||
// Array of buffers for each vector size.
|
||||
using Buffers = std::array<clMemWrapper, VECTOR_SIZE_COUNT>;
|
||||
|
||||
// Information to generate OpenCL kernels.
|
||||
struct BuildKernelInfo
|
||||
{
|
||||
|
||||
@@ -122,9 +122,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
MTdata d;
|
||||
|
||||
// Per thread command queue to improve performance
|
||||
@@ -705,10 +707,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -120,9 +120,11 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem inBuf2; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
clMemWrapper inBuf2;
|
||||
Buffers outBuf;
|
||||
|
||||
MTdata d;
|
||||
|
||||
// Per thread command queue to improve performance
|
||||
@@ -694,10 +696,6 @@ exit:
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
free_mtdata(threadInfo.d);
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
clReleaseMemObject(threadInfo.inBuf2);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -116,8 +116,9 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
Buffers outBuf;
|
||||
|
||||
// Per thread command queue to improve performance
|
||||
clCommandQueueWrapper tQueue;
|
||||
@@ -475,12 +476,5 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -115,8 +115,9 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
Buffers outBuf;
|
||||
|
||||
// Per thread command queue to improve performance
|
||||
clCommandQueueWrapper tQueue;
|
||||
@@ -489,12 +490,5 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,10 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double maxErrorValue; // position of the max error value. Init to 0.
|
||||
|
||||
@@ -513,12 +515,5 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,10 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
// Thread specific data for a worker thread
|
||||
struct ThreadInfo
|
||||
{
|
||||
cl_mem inBuf; // input buffer for the thread
|
||||
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
|
||||
// Input and output buffers for the thread
|
||||
clMemWrapper inBuf;
|
||||
Buffers outBuf;
|
||||
|
||||
float maxError; // max error value. Init to 0.
|
||||
double maxErrorValue; // position of the max error value. Init to 0.
|
||||
|
||||
@@ -690,12 +692,5 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &threadInfo : test_info.tinfo)
|
||||
{
|
||||
clReleaseMemObject(threadInfo.inBuf);
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
clReleaseMemObject(threadInfo.outBuf[j]);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user