mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-25 16:29:03 +00:00
[NFC] Reformat code in events test (#1497)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
const cl_uint BufferSizeReductionFactor = 20;
|
const cl_uint BufferSizeReductionFactor = 20;
|
||||||
|
|
||||||
cl_int Action::IGetPreferredImageSize2D( cl_device_id device, size_t &outWidth, size_t &outHeight )
|
cl_int Action::IGetPreferredImageSize2D(cl_device_id device, size_t &outWidth,
|
||||||
|
size_t &outHeight)
|
||||||
{
|
{
|
||||||
cl_ulong maxAllocSize;
|
cl_ulong maxAllocSize;
|
||||||
size_t maxWidth, maxHeight;
|
size_t maxWidth, maxHeight;
|
||||||
@@ -27,23 +28,27 @@ cl_int Action::IGetPreferredImageSize2D( cl_device_id device, size_t &outWidt
|
|||||||
|
|
||||||
|
|
||||||
// Get the largest possible buffer we could allocate
|
// Get the largest possible buffer we could allocate
|
||||||
error = clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
error = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH,
|
||||||
|
sizeof(maxWidth), &maxWidth, NULL);
|
||||||
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
|
||||||
|
sizeof(maxHeight), &maxHeight, NULL);
|
||||||
test_error(error, "Unable to get device config");
|
test_error(error, "Unable to get device config");
|
||||||
|
|
||||||
// Create something of a decent size
|
// Create something of a decent size
|
||||||
if (maxWidth * maxHeight * 4 > maxAllocSize / BufferSizeReductionFactor)
|
if (maxWidth * maxHeight * 4 > maxAllocSize / BufferSizeReductionFactor)
|
||||||
{
|
{
|
||||||
float rootSize = sqrtf( (float)( maxAllocSize / ( BufferSizeReductionFactor * 4 ) ) );
|
float rootSize =
|
||||||
|
sqrtf((float)(maxAllocSize / (BufferSizeReductionFactor * 4)));
|
||||||
|
|
||||||
if ((size_t)rootSize > maxWidth)
|
if ((size_t)rootSize > maxWidth)
|
||||||
outWidth = maxWidth;
|
outWidth = maxWidth;
|
||||||
else
|
else
|
||||||
outWidth = (size_t)rootSize;
|
outWidth = (size_t)rootSize;
|
||||||
outHeight = (size_t)( ( maxAllocSize / ( BufferSizeReductionFactor * 4 ) ) / outWidth );
|
outHeight = (size_t)((maxAllocSize / (BufferSizeReductionFactor * 4))
|
||||||
if( outHeight > maxHeight )
|
/ outWidth);
|
||||||
outHeight = maxHeight;
|
if (outHeight > maxHeight) outHeight = maxHeight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -54,16 +59,15 @@ cl_int Action::IGetPreferredImageSize2D( cl_device_id device, size_t &outWidt
|
|||||||
outWidth /= 2;
|
outWidth /= 2;
|
||||||
outHeight /= 2;
|
outHeight /= 2;
|
||||||
|
|
||||||
if (outWidth > 2048)
|
if (outWidth > 2048) outWidth = 2048;
|
||||||
outWidth = 2048;
|
if (outHeight > 2048) outHeight = 2048;
|
||||||
if (outHeight > 2048)
|
|
||||||
outHeight = 2048;
|
|
||||||
log_info("\tImage size: %d x %d (%gMB)\n", (int)outWidth, (int)outHeight,
|
log_info("\tImage size: %d x %d (%gMB)\n", (int)outWidth, (int)outHeight,
|
||||||
(double)((int)outWidth * (int)outHeight * 4) / (1024.0 * 1024.0));
|
(double)((int)outWidth * (int)outHeight * 4) / (1024.0 * 1024.0));
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int Action::IGetPreferredImageSize3D( cl_device_id device, size_t &outWidth, size_t &outHeight, size_t &outDepth )
|
cl_int Action::IGetPreferredImageSize3D(cl_device_id device, size_t &outWidth,
|
||||||
|
size_t &outHeight, size_t &outDepth)
|
||||||
{
|
{
|
||||||
cl_ulong maxAllocSize;
|
cl_ulong maxAllocSize;
|
||||||
size_t maxWidth, maxHeight, maxDepth;
|
size_t maxWidth, maxHeight, maxDepth;
|
||||||
@@ -71,16 +75,22 @@ cl_int Action::IGetPreferredImageSize3D( cl_device_id device, size_t &outWidt
|
|||||||
|
|
||||||
|
|
||||||
// Get the largest possible buffer we could allocate
|
// Get the largest possible buffer we could allocate
|
||||||
error = clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
error = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, NULL );
|
sizeof(maxWidth), &maxWidth, NULL);
|
||||||
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT,
|
||||||
|
sizeof(maxHeight), &maxHeight, NULL);
|
||||||
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH,
|
||||||
|
sizeof(maxDepth), &maxDepth, NULL);
|
||||||
test_error(error, "Unable to get device config");
|
test_error(error, "Unable to get device config");
|
||||||
|
|
||||||
// Create something of a decent size
|
// Create something of a decent size
|
||||||
if( (cl_ulong)maxWidth * maxHeight * maxDepth > maxAllocSize / ( BufferSizeReductionFactor * 4 ) )
|
if ((cl_ulong)maxWidth * maxHeight * maxDepth
|
||||||
|
> maxAllocSize / (BufferSizeReductionFactor * 4))
|
||||||
{
|
{
|
||||||
float rootSize = cbrtf( (float)( maxAllocSize / ( BufferSizeReductionFactor * 4 ) ) );
|
float rootSize =
|
||||||
|
cbrtf((float)(maxAllocSize / (BufferSizeReductionFactor * 4)));
|
||||||
|
|
||||||
if ((size_t)rootSize > maxWidth)
|
if ((size_t)rootSize > maxWidth)
|
||||||
outWidth = maxWidth;
|
outWidth = maxWidth;
|
||||||
@@ -90,9 +100,9 @@ cl_int Action::IGetPreferredImageSize3D( cl_device_id device, size_t &outWidt
|
|||||||
outHeight = maxHeight;
|
outHeight = maxHeight;
|
||||||
else
|
else
|
||||||
outHeight = (size_t)rootSize;
|
outHeight = (size_t)rootSize;
|
||||||
outDepth = (size_t)( ( maxAllocSize / ( BufferSizeReductionFactor * 4 ) ) / ( outWidth * outHeight ) );
|
outDepth = (size_t)((maxAllocSize / (BufferSizeReductionFactor * 4))
|
||||||
if( outDepth > maxDepth )
|
/ (outWidth * outHeight));
|
||||||
outDepth = maxDepth;
|
if (outDepth > maxDepth) outDepth = maxDepth;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -105,21 +115,21 @@ cl_int Action::IGetPreferredImageSize3D( cl_device_id device, size_t &outWidt
|
|||||||
outHeight /= 2;
|
outHeight /= 2;
|
||||||
outDepth /= 2;
|
outDepth /= 2;
|
||||||
|
|
||||||
if (outWidth > 512)
|
if (outWidth > 512) outWidth = 512;
|
||||||
outWidth = 512;
|
if (outHeight > 512) outHeight = 512;
|
||||||
if (outHeight > 512)
|
if (outDepth > 512) outDepth = 512;
|
||||||
outHeight = 512;
|
log_info("\tImage size: %d x %d x %d (%gMB)\n", (int)outWidth,
|
||||||
if (outDepth > 512)
|
(int)outHeight, (int)outDepth,
|
||||||
outDepth = 512;
|
(double)((int)outWidth * (int)outHeight * (int)outDepth * 4)
|
||||||
log_info("\tImage size: %d x %d x %d (%gMB)\n", (int)outWidth, (int)outHeight, (int)outDepth,
|
/ (1024.0 * 1024.0));
|
||||||
(double)((int)outWidth*(int)outHeight*(int)outDepth*4)/(1024.0*1024.0));
|
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -------------------- Execution Sub-Classes -------------------------
|
#pragma mark -------------------- Execution Sub-Classes -------------------------
|
||||||
|
|
||||||
cl_int NDRangeKernelAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int NDRangeKernelAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
const char *long_kernel[] = {
|
const char *long_kernel[] = {
|
||||||
"__kernel void sample_test(__global float *src, __global int *dst)\n"
|
"__kernel void sample_test(__global float *src, __global int *dst)\n"
|
||||||
@@ -132,17 +142,20 @@ cl_int NDRangeKernelAction::Setup( cl_device_id device, cl_context context, cl_c
|
|||||||
" dst[tid] = (int)src[tid] * 3;\n"
|
" dst[tid] = (int)src[tid] * 3;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
"}\n" };
|
"}\n"
|
||||||
|
};
|
||||||
|
|
||||||
size_t threads[1] = { 1000 };
|
size_t threads[1] = { 1000 };
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if( create_single_kernel_helper( context, &mProgram, &mKernel, 1, long_kernel, "sample_test" ) )
|
if (create_single_kernel_helper(context, &mProgram, &mKernel, 1,
|
||||||
|
long_kernel, "sample_test"))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = get_max_common_work_group_size( context, mKernel, threads[0], &mLocalThreads[0] );
|
error = get_max_common_work_group_size(context, mKernel, threads[0],
|
||||||
|
&mLocalThreads[0]);
|
||||||
test_error(error, "Unable to get work group size to use");
|
test_error(error, "Unable to get work group size to use");
|
||||||
|
|
||||||
mStreams[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
|
mStreams[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
|
||||||
@@ -161,10 +174,13 @@ cl_int NDRangeKernelAction::Setup( cl_device_id device, cl_context context, cl_c
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int NDRangeKernelAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int NDRangeKernelAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t threads[1] = { 1000 };
|
size_t threads[1] = { 1000 };
|
||||||
cl_int error = clEnqueueNDRangeKernel( queue, mKernel, 1, NULL, threads, mLocalThreads, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueNDRangeKernel(queue, mKernel, 1, NULL, threads, mLocalThreads,
|
||||||
|
numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to execute kernel");
|
test_error(error, "Unable to execute kernel");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -172,27 +188,30 @@ cl_int NDRangeKernelAction::Execute( cl_command_queue queue, cl_uint numWaits
|
|||||||
|
|
||||||
#pragma mark -------------------- Buffer Sub-Classes -------------------------
|
#pragma mark -------------------- Buffer Sub-Classes -------------------------
|
||||||
|
|
||||||
cl_int BufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue, bool allocate )
|
cl_int BufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, bool allocate)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
cl_ulong maxAllocSize;
|
cl_ulong maxAllocSize;
|
||||||
|
|
||||||
|
|
||||||
// Get the largest possible buffer we could allocate
|
// Get the largest possible buffer we could allocate
|
||||||
error = clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
error = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
||||||
|
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
||||||
|
|
||||||
// Don't create a buffer quite that big, just so we have some space left over for other work
|
// Don't create a buffer quite that big, just so we have some space left
|
||||||
|
// over for other work
|
||||||
mSize = (size_t)(maxAllocSize / BufferSizeReductionFactor);
|
mSize = (size_t)(maxAllocSize / BufferSizeReductionFactor);
|
||||||
|
|
||||||
// Cap at 128M so tests complete in a reasonable amount of time.
|
// Cap at 128M so tests complete in a reasonable amount of time.
|
||||||
if (mSize > 128 << 20)
|
if (mSize > 128 << 20) mSize = 128 << 20;
|
||||||
mSize = 128 << 20;
|
|
||||||
|
|
||||||
mSize /= 2;
|
mSize /= 2;
|
||||||
|
|
||||||
log_info("\tBuffer size: %gMB\n", (double)mSize / (1024.0 * 1024.0));
|
log_info("\tBuffer size: %gMB\n", (double)mSize / (1024.0 * 1024.0));
|
||||||
|
|
||||||
mBuffer = clCreateBuffer( context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mSize, NULL, &error );
|
mBuffer = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
|
||||||
|
mSize, NULL, &error);
|
||||||
test_error(error, "Unable to create buffer to test against");
|
test_error(error, "Unable to create buffer to test against");
|
||||||
|
|
||||||
mOutBuffer = malloc(mSize);
|
mOutBuffer = malloc(mSize);
|
||||||
@@ -205,27 +224,33 @@ cl_int BufferAction::Setup( cl_device_id device, cl_context context, cl_command_
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int ReadBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int ReadBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
return BufferAction::Setup(device, context, queue, true);
|
return BufferAction::Setup(device, context, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int ReadBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int ReadBufferAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
cl_int error = clEnqueueReadBuffer( queue, mBuffer, CL_FALSE, 0, mSize, mOutBuffer, numWaits, waits, outEvent );
|
cl_int error = clEnqueueReadBuffer(queue, mBuffer, CL_FALSE, 0, mSize,
|
||||||
|
mOutBuffer, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue buffer read");
|
test_error(error, "Unable to enqueue buffer read");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int WriteBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
return BufferAction::Setup(device, context, queue, true);
|
return BufferAction::Setup(device, context, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int WriteBufferAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
cl_int error = clEnqueueWriteBuffer( queue, mBuffer, CL_FALSE, 0, mSize, mOutBuffer, numWaits, waits, outEvent );
|
cl_int error = clEnqueueWriteBuffer(queue, mBuffer, CL_FALSE, 0, mSize,
|
||||||
|
mOutBuffer, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue buffer write");
|
test_error(error, "Unable to enqueue buffer write");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -237,36 +262,42 @@ MapBufferAction::~MapBufferAction()
|
|||||||
clEnqueueUnmapMemObject(mQueue, mBuffer, mMappedPtr, 0, NULL, NULL);
|
clEnqueueUnmapMemObject(mQueue, mBuffer, mMappedPtr, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int MapBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int MapBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
return BufferAction::Setup(device, context, queue, false);
|
return BufferAction::Setup(device, context, queue, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int MapBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int MapBufferAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
mQueue = queue;
|
mQueue = queue;
|
||||||
mMappedPtr = clEnqueueMapBuffer( queue, mBuffer, CL_FALSE, CL_MAP_READ, 0, mSize, numWaits, waits, outEvent, &error );
|
mMappedPtr = clEnqueueMapBuffer(queue, mBuffer, CL_FALSE, CL_MAP_READ, 0,
|
||||||
|
mSize, numWaits, waits, outEvent, &error);
|
||||||
test_error(error, "Unable to enqueue buffer map");
|
test_error(error, "Unable to enqueue buffer map");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int UnmapBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int UnmapBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error = BufferAction::Setup(device, context, queue, false);
|
cl_int error = BufferAction::Setup(device, context, queue, false);
|
||||||
if( error != CL_SUCCESS )
|
if (error != CL_SUCCESS) return error;
|
||||||
return error;
|
|
||||||
|
|
||||||
mMappedPtr = clEnqueueMapBuffer( queue, mBuffer, CL_TRUE, CL_MAP_READ, 0, mSize, 0, NULL, NULL, &error );
|
mMappedPtr = clEnqueueMapBuffer(queue, mBuffer, CL_TRUE, CL_MAP_READ, 0,
|
||||||
|
mSize, 0, NULL, NULL, &error);
|
||||||
test_error(error, "Unable to enqueue buffer map");
|
test_error(error, "Unable to enqueue buffer map");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int UnmapBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int UnmapBufferAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
cl_int error = clEnqueueUnmapMemObject( queue, mBuffer, mMappedPtr, numWaits, waits, outEvent );
|
cl_int error = clEnqueueUnmapMemObject(queue, mBuffer, mMappedPtr, numWaits,
|
||||||
|
waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue buffer unmap");
|
test_error(error, "Unable to enqueue buffer unmap");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -275,7 +306,8 @@ cl_int UnmapBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_
|
|||||||
|
|
||||||
#pragma mark -------------------- Read/Write Image Classes -------------------------
|
#pragma mark -------------------- Read/Write Image Classes -------------------------
|
||||||
|
|
||||||
cl_int ReadImage2DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int ReadImage2DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -284,7 +316,8 @@ cl_int ReadImage2DAction::Setup( cl_device_id device, cl_context context, cl_com
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mImage = create_image_2d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mImage = create_image_2d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
|
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
@@ -298,17 +331,20 @@ cl_int ReadImage2DAction::Setup( cl_device_id device, cl_context context, cl_com
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int ReadImage2DAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int ReadImage2DAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
||||||
|
|
||||||
cl_int error = clEnqueueReadImage( queue, mImage, CL_FALSE, origin, region, 0, 0, mOutput, numWaits, waits, outEvent );
|
cl_int error = clEnqueueReadImage(queue, mImage, CL_FALSE, origin, region,
|
||||||
|
0, 0, mOutput, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image read");
|
test_error(error, "Unable to enqueue image read");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int ReadImage3DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int ReadImage3DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -317,7 +353,8 @@ cl_int ReadImage3DAction::Setup( cl_device_id device, cl_context context, cl_com
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mOutput = malloc(mWidth * mHeight * mDepth * 4);
|
mOutput = malloc(mWidth * mHeight * mDepth * 4);
|
||||||
@@ -330,17 +367,20 @@ cl_int ReadImage3DAction::Setup( cl_device_id device, cl_context context, cl_com
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int ReadImage3DAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int ReadImage3DAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
||||||
|
|
||||||
cl_int error = clEnqueueReadImage( queue, mImage, CL_FALSE, origin, region, 0, 0, mOutput, numWaits, waits, outEvent );
|
cl_int error = clEnqueueReadImage(queue, mImage, CL_FALSE, origin, region,
|
||||||
|
0, 0, mOutput, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image read");
|
test_error(error, "Unable to enqueue image read");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteImage2DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int WriteImage2DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -349,7 +389,8 @@ cl_int WriteImage2DAction::Setup( cl_device_id device, cl_context context, cl_co
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mImage = create_image_2d( context, CL_MEM_WRITE_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mImage = create_image_2d(context, CL_MEM_WRITE_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mOutput = malloc(mWidth * mHeight * 4);
|
mOutput = malloc(mWidth * mHeight * 4);
|
||||||
@@ -362,17 +403,21 @@ cl_int WriteImage2DAction::Setup( cl_device_id device, cl_context context, cl_co
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteImage2DAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int WriteImage2DAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
||||||
|
|
||||||
cl_int error = clEnqueueWriteImage( queue, mImage, CL_FALSE, origin, region, 0, 0, mOutput, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueWriteImage(queue, mImage, CL_FALSE, origin, region, 0, 0,
|
||||||
|
mOutput, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image write");
|
test_error(error, "Unable to enqueue image write");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteImage3DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int WriteImage3DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -381,7 +426,8 @@ cl_int WriteImage3DAction::Setup( cl_device_id device, cl_context context, cl_co
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mOutput = malloc(mWidth * mHeight * mDepth * 4);
|
mOutput = malloc(mWidth * mHeight * mDepth * 4);
|
||||||
@@ -394,11 +440,14 @@ cl_int WriteImage3DAction::Setup( cl_device_id device, cl_context context, cl_co
|
|||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int WriteImage3DAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int WriteImage3DAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
||||||
|
|
||||||
cl_int error = clEnqueueWriteImage( queue, mImage, CL_FALSE, origin, region, 0, 0, mOutput, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueWriteImage(queue, mImage, CL_FALSE, origin, region, 0, 0,
|
||||||
|
mOutput, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image write");
|
test_error(error, "Unable to enqueue image write");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -406,17 +455,21 @@ cl_int WriteImage3DAction::Execute( cl_command_queue queue, cl_uint numWaits, cl
|
|||||||
|
|
||||||
#pragma mark -------------------- Copy Image Classes -------------------------
|
#pragma mark -------------------- Copy Image Classes -------------------------
|
||||||
|
|
||||||
cl_int CopyImageAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int CopyImageAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
||||||
|
|
||||||
cl_int error = clEnqueueCopyImage( queue, mSrcImage, mDstImage, origin, origin, region, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueCopyImage(queue, mSrcImage, mDstImage, origin, origin, region,
|
||||||
|
numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image copy");
|
test_error(error, "Unable to enqueue image copy");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyImage2Dto2DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyImage2Dto2DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -427,17 +480,20 @@ cl_int CopyImage2Dto2DAction::Setup( cl_device_id device, cl_context context, cl
|
|||||||
mWidth /= 2;
|
mWidth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_2d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mSrcImage = create_image_2d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstImage = create_image_2d( context, CL_MEM_WRITE_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mDstImage = create_image_2d(context, CL_MEM_WRITE_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDepth = 1;
|
mDepth = 1;
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyImage2Dto3DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyImage2Dto3DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -448,17 +504,20 @@ cl_int CopyImage2Dto3DAction::Setup( cl_device_id device, cl_context context, cl
|
|||||||
mDepth /= 2;
|
mDepth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_2d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mSrcImage = create_image_2d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mDstImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDepth = 1;
|
mDepth = 1;
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyImage3Dto2DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyImage3Dto2DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -469,17 +528,20 @@ cl_int CopyImage3Dto2DAction::Setup( cl_device_id device, cl_context context, cl
|
|||||||
mDepth /= 2;
|
mDepth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mSrcImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstImage = create_image_2d( context, CL_MEM_WRITE_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mDstImage = create_image_2d(context, CL_MEM_WRITE_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDepth = 1;
|
mDepth = 1;
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyImage3Dto3DAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyImage3Dto3DAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -490,10 +552,12 @@ cl_int CopyImage3Dto3DAction::Setup( cl_device_id device, cl_context context, cl
|
|||||||
mDepth /= 2;
|
mDepth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mSrcImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mDstImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -501,7 +565,8 @@ cl_int CopyImage3Dto3DAction::Setup( cl_device_id device, cl_context context, cl
|
|||||||
|
|
||||||
#pragma mark -------------------- Copy Image/Buffer Classes -------------------------
|
#pragma mark -------------------- Copy Image/Buffer Classes -------------------------
|
||||||
|
|
||||||
cl_int Copy2DImageToBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int Copy2DImageToBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -512,26 +577,33 @@ cl_int Copy2DImageToBufferAction::Setup( cl_device_id device, cl_context context
|
|||||||
mWidth /= 2;
|
mWidth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_2d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mSrcImage = create_image_2d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstBuffer = clCreateBuffer( context, CL_MEM_WRITE_ONLY, mWidth * mHeight * 4, NULL, &error );
|
mDstBuffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
|
||||||
|
mWidth * mHeight * 4, NULL, &error);
|
||||||
test_error(error, "Unable to create buffer to test against");
|
test_error(error, "Unable to create buffer to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int Copy2DImageToBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int Copy2DImageToBufferAction::Execute(cl_command_queue queue,
|
||||||
|
cl_uint numWaits, cl_event *waits,
|
||||||
|
cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
||||||
|
|
||||||
cl_int error = clEnqueueCopyImageToBuffer( queue, mSrcImage, mDstBuffer, origin, region, 0, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueCopyImageToBuffer(queue, mSrcImage, mDstBuffer, origin, region,
|
||||||
|
0, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image to buffer copy");
|
test_error(error, "Unable to enqueue image to buffer copy");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int Copy3DImageToBufferAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int Copy3DImageToBufferAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -542,26 +614,33 @@ cl_int Copy3DImageToBufferAction::Setup( cl_device_id device, cl_context context
|
|||||||
mDepth /= 2;
|
mDepth /= 2;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mSrcImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mSrcImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
mDstBuffer = clCreateBuffer( context, CL_MEM_WRITE_ONLY, mWidth * mHeight * mDepth * 4, NULL, &error );
|
mDstBuffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
|
||||||
|
mWidth * mHeight * mDepth * 4, NULL, &error);
|
||||||
test_error(error, "Unable to create buffer to test against");
|
test_error(error, "Unable to create buffer to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int Copy3DImageToBufferAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int Copy3DImageToBufferAction::Execute(cl_command_queue queue,
|
||||||
|
cl_uint numWaits, cl_event *waits,
|
||||||
|
cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
||||||
|
|
||||||
cl_int error = clEnqueueCopyImageToBuffer( queue, mSrcImage, mDstBuffer, origin, region, 0, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueCopyImageToBuffer(queue, mSrcImage, mDstBuffer, origin, region,
|
||||||
|
0, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue image to buffer copy");
|
test_error(error, "Unable to enqueue image to buffer copy");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyBufferTo2DImageAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyBufferTo2DImageAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -573,26 +652,33 @@ cl_int CopyBufferTo2DImageAction::Setup( cl_device_id device, cl_context context
|
|||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
|
|
||||||
mSrcBuffer = clCreateBuffer( context, CL_MEM_READ_ONLY, mWidth * mHeight * 4, NULL, &error );
|
mSrcBuffer = clCreateBuffer(context, CL_MEM_READ_ONLY, mWidth * mHeight * 4,
|
||||||
|
NULL, &error);
|
||||||
test_error(error, "Unable to create buffer to test against");
|
test_error(error, "Unable to create buffer to test against");
|
||||||
|
|
||||||
mDstImage = create_image_2d( context, CL_MEM_WRITE_ONLY, &format, mWidth, mHeight, 0, NULL, &error );
|
mDstImage = create_image_2d(context, CL_MEM_WRITE_ONLY, &format, mWidth,
|
||||||
|
mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyBufferTo2DImageAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int CopyBufferTo2DImageAction::Execute(cl_command_queue queue,
|
||||||
|
cl_uint numWaits, cl_event *waits,
|
||||||
|
cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, 1 };
|
||||||
|
|
||||||
cl_int error = clEnqueueCopyBufferToImage( queue, mSrcBuffer, mDstImage, 0, origin, region, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueCopyBufferToImage(queue, mSrcBuffer, mDstImage, 0, origin,
|
||||||
|
region, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue buffer to image copy");
|
test_error(error, "Unable to enqueue buffer to image copy");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyBufferTo3DImageAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int CopyBufferTo3DImageAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -602,21 +688,27 @@ cl_int CopyBufferTo3DImageAction::Setup( cl_device_id device, cl_context context
|
|||||||
|
|
||||||
mDepth /= 2;
|
mDepth /= 2;
|
||||||
|
|
||||||
mSrcBuffer = clCreateBuffer( context, CL_MEM_READ_ONLY, mWidth * mHeight * mDepth * 4, NULL, &error );
|
mSrcBuffer = clCreateBuffer(context, CL_MEM_READ_ONLY,
|
||||||
|
mWidth * mHeight * mDepth * 4, NULL, &error);
|
||||||
test_error(error, "Unable to create buffer to test against");
|
test_error(error, "Unable to create buffer to test against");
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mDstImage = create_image_3d( context, CL_MEM_READ_ONLY, &format, mWidth, mHeight, mDepth, 0, 0, NULL, &error );
|
mDstImage = create_image_3d(context, CL_MEM_READ_ONLY, &format, mWidth,
|
||||||
|
mHeight, mDepth, 0, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int CopyBufferTo3DImageAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int CopyBufferTo3DImageAction::Execute(cl_command_queue queue,
|
||||||
|
cl_uint numWaits, cl_event *waits,
|
||||||
|
cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
size_t origin[3] = { 0, 0, 0 }, region[3] = { mWidth, mHeight, mDepth };
|
||||||
|
|
||||||
cl_int error = clEnqueueCopyBufferToImage( queue, mSrcBuffer, mDstImage, 0, origin, region, numWaits, waits, outEvent );
|
cl_int error =
|
||||||
|
clEnqueueCopyBufferToImage(queue, mSrcBuffer, mDstImage, 0, origin,
|
||||||
|
region, numWaits, waits, outEvent);
|
||||||
test_error(error, "Unable to enqueue buffer to image copy");
|
test_error(error, "Unable to enqueue buffer to image copy");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
@@ -630,7 +722,8 @@ MapImageAction::~MapImageAction()
|
|||||||
clEnqueueUnmapMemObject(mQueue, mImage, mMappedPtr, 0, NULL, NULL);
|
clEnqueueUnmapMemObject(mQueue, mImage, mMappedPtr, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int MapImageAction::Setup( cl_device_id device, cl_context context, cl_command_queue queue )
|
cl_int MapImageAction::Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -639,13 +732,15 @@ cl_int MapImageAction::Setup( cl_device_id device, cl_context context, cl_comman
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
cl_image_format format = { CL_RGBA, CL_SIGNED_INT8 };
|
||||||
mImage = create_image_2d( context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR, &format, mWidth, mHeight, 0, NULL, &error );
|
mImage = create_image_2d(context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR,
|
||||||
|
&format, mWidth, mHeight, 0, NULL, &error);
|
||||||
test_error(error, "Unable to create image to test against");
|
test_error(error, "Unable to create image to test against");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int MapImageAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent )
|
cl_int MapImageAction::Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -653,7 +748,9 @@ cl_int MapImageAction::Execute( cl_command_queue queue, cl_uint numWaits, cl_eve
|
|||||||
size_t outPitch;
|
size_t outPitch;
|
||||||
|
|
||||||
mQueue = queue;
|
mQueue = queue;
|
||||||
mMappedPtr = clEnqueueMapImage( queue, mImage, CL_FALSE, CL_MAP_READ, origin, region, &outPitch, NULL, numWaits, waits, outEvent, &error );
|
mMappedPtr =
|
||||||
|
clEnqueueMapImage(queue, mImage, CL_FALSE, CL_MAP_READ, origin, region,
|
||||||
|
&outPitch, NULL, numWaits, waits, outEvent, &error);
|
||||||
test_error(error, "Unable to enqueue image map");
|
test_error(error, "Unable to enqueue image map");
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
|
|||||||
@@ -23,26 +23,27 @@
|
|||||||
// it would potentially be possible for an implementation to make actions
|
// it would potentially be possible for an implementation to make actions
|
||||||
// wait on one another based on their shared I/O, not because of their
|
// wait on one another based on their shared I/O, not because of their
|
||||||
// wait lists!
|
// wait lists!
|
||||||
class Action
|
class Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Action() {}
|
Action() {}
|
||||||
virtual ~Action() {}
|
virtual ~Action() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue ) = 0;
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent ) = 0;
|
cl_command_queue queue) = 0;
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent) = 0;
|
||||||
|
|
||||||
virtual const char *GetName(void) const = 0;
|
virtual const char *GetName(void) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
cl_int IGetPreferredImageSize2D(cl_device_id device, size_t &outWidth,
|
||||||
cl_int IGetPreferredImageSize2D( cl_device_id device, size_t &outWidth, size_t &outHeight );
|
size_t &outHeight);
|
||||||
cl_int IGetPreferredImageSize3D( cl_device_id device, size_t &outWidth, size_t &outHeight, size_t &outDepth );
|
cl_int IGetPreferredImageSize3D(cl_device_id device, size_t &outWidth,
|
||||||
|
size_t &outHeight, size_t &outDepth);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simple NDRangeKernel execution that takes a noticable amount of time
|
// Simple NDRangeKernel execution that takes a noticable amount of time
|
||||||
class NDRangeKernelAction : public Action
|
class NDRangeKernelAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
NDRangeKernelAction() {}
|
NDRangeKernelAction() {}
|
||||||
virtual ~NDRangeKernelAction() {}
|
virtual ~NDRangeKernelAction() {}
|
||||||
@@ -52,15 +53,16 @@ class NDRangeKernelAction : public Action
|
|||||||
clProgramWrapper mProgram;
|
clProgramWrapper mProgram;
|
||||||
clKernelWrapper mKernel;
|
clKernelWrapper mKernel;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "NDRangeKernel"; }
|
virtual const char *GetName(void) const { return "NDRangeKernel"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base action for buffer actions
|
// Base action for buffer actions
|
||||||
class BufferAction : public Action
|
class BufferAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
clMemWrapper mBuffer;
|
clMemWrapper mBuffer;
|
||||||
size_t mSize;
|
size_t mSize;
|
||||||
@@ -69,35 +71,37 @@ class BufferAction : public Action
|
|||||||
BufferAction() { mOutBuffer = NULL; }
|
BufferAction() { mOutBuffer = NULL; }
|
||||||
virtual ~BufferAction() { free(mOutBuffer); }
|
virtual ~BufferAction() { free(mOutBuffer); }
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue, bool allocate );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, bool allocate);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReadBufferAction : public BufferAction
|
class ReadBufferAction : public BufferAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
ReadBufferAction() {}
|
ReadBufferAction() {}
|
||||||
virtual ~ReadBufferAction() {}
|
virtual ~ReadBufferAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "ReadBuffer"; }
|
virtual const char *GetName(void) const { return "ReadBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class WriteBufferAction : public BufferAction
|
class WriteBufferAction : public BufferAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
WriteBufferAction() {}
|
WriteBufferAction() {}
|
||||||
virtual ~WriteBufferAction() {}
|
virtual ~WriteBufferAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "WriteBuffer"; }
|
virtual const char *GetName(void) const { return "WriteBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapBufferAction : public BufferAction
|
class MapBufferAction : public BufferAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MapBufferAction(): mQueue(0) {}
|
MapBufferAction(): mQueue(0) {}
|
||||||
|
|
||||||
@@ -105,28 +109,30 @@ class MapBufferAction : public BufferAction
|
|||||||
void *mMappedPtr;
|
void *mMappedPtr;
|
||||||
|
|
||||||
virtual ~MapBufferAction();
|
virtual ~MapBufferAction();
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "MapBuffer"; }
|
virtual const char *GetName(void) const { return "MapBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnmapBufferAction : public BufferAction
|
class UnmapBufferAction : public BufferAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
UnmapBufferAction() {}
|
UnmapBufferAction() {}
|
||||||
virtual ~UnmapBufferAction() {}
|
virtual ~UnmapBufferAction() {}
|
||||||
|
|
||||||
void *mMappedPtr;
|
void *mMappedPtr;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "UnmapBuffer"; }
|
virtual const char *GetName(void) const { return "UnmapBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReadImage2DAction : public Action
|
class ReadImage2DAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
ReadImage2DAction() { mOutput = NULL; }
|
ReadImage2DAction() { mOutput = NULL; }
|
||||||
virtual ~ReadImage2DAction() { free(mOutput); }
|
virtual ~ReadImage2DAction() { free(mOutput); }
|
||||||
@@ -135,14 +141,15 @@ class ReadImage2DAction : public Action
|
|||||||
size_t mWidth, mHeight;
|
size_t mWidth, mHeight;
|
||||||
void *mOutput;
|
void *mOutput;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "ReadImage2D"; }
|
virtual const char *GetName(void) const { return "ReadImage2D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReadImage3DAction : public Action
|
class ReadImage3DAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
ReadImage3DAction() { mOutput = NULL; }
|
ReadImage3DAction() { mOutput = NULL; }
|
||||||
virtual ~ReadImage3DAction() { free(mOutput); }
|
virtual ~ReadImage3DAction() { free(mOutput); }
|
||||||
@@ -151,14 +158,15 @@ class ReadImage3DAction : public Action
|
|||||||
size_t mWidth, mHeight, mDepth;
|
size_t mWidth, mHeight, mDepth;
|
||||||
void *mOutput;
|
void *mOutput;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "ReadImage3D"; }
|
virtual const char *GetName(void) const { return "ReadImage3D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class WriteImage2DAction : public Action
|
class WriteImage2DAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
clMemWrapper mImage;
|
clMemWrapper mImage;
|
||||||
size_t mWidth, mHeight;
|
size_t mWidth, mHeight;
|
||||||
@@ -167,14 +175,15 @@ class WriteImage2DAction : public Action
|
|||||||
WriteImage2DAction() { mOutput = NULL; }
|
WriteImage2DAction() { mOutput = NULL; }
|
||||||
virtual ~WriteImage2DAction() { free(mOutput); }
|
virtual ~WriteImage2DAction() { free(mOutput); }
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "WriteImage2D"; }
|
virtual const char *GetName(void) const { return "WriteImage2D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class WriteImage3DAction : public Action
|
class WriteImage3DAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
clMemWrapper mImage;
|
clMemWrapper mImage;
|
||||||
size_t mWidth, mHeight, mDepth;
|
size_t mWidth, mHeight, mDepth;
|
||||||
@@ -183,14 +192,15 @@ class WriteImage3DAction : public Action
|
|||||||
WriteImage3DAction() { mOutput = NULL; }
|
WriteImage3DAction() { mOutput = NULL; }
|
||||||
virtual ~WriteImage3DAction() { free(mOutput); }
|
virtual ~WriteImage3DAction() { free(mOutput); }
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "WriteImage3D"; }
|
virtual const char *GetName(void) const { return "WriteImage3D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyImageAction : public Action
|
class CopyImageAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyImageAction() {}
|
CopyImageAction() {}
|
||||||
virtual ~CopyImageAction() {}
|
virtual ~CopyImageAction() {}
|
||||||
@@ -198,55 +208,55 @@ class CopyImageAction : public Action
|
|||||||
clMemWrapper mSrcImage, mDstImage;
|
clMemWrapper mSrcImage, mDstImage;
|
||||||
size_t mWidth, mHeight, mDepth;
|
size_t mWidth, mHeight, mDepth;
|
||||||
|
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyImage2Dto2DAction : public CopyImageAction
|
class CopyImage2Dto2DAction : public CopyImageAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyImage2Dto2DAction() {}
|
CopyImage2Dto2DAction() {}
|
||||||
virtual ~CopyImage2Dto2DAction() {}
|
virtual ~CopyImage2Dto2DAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyImage2Dto2D"; }
|
virtual const char *GetName(void) const { return "CopyImage2Dto2D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyImage2Dto3DAction : public CopyImageAction
|
class CopyImage2Dto3DAction : public CopyImageAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyImage2Dto3DAction() {}
|
CopyImage2Dto3DAction() {}
|
||||||
virtual ~CopyImage2Dto3DAction() {}
|
virtual ~CopyImage2Dto3DAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyImage2Dto3D"; }
|
virtual const char *GetName(void) const { return "CopyImage2Dto3D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyImage3Dto2DAction : public CopyImageAction
|
class CopyImage3Dto2DAction : public CopyImageAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyImage3Dto2DAction() {}
|
CopyImage3Dto2DAction() {}
|
||||||
virtual ~CopyImage3Dto2DAction() {}
|
virtual ~CopyImage3Dto2DAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyImage3Dto2D"; }
|
virtual const char *GetName(void) const { return "CopyImage3Dto2D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyImage3Dto3DAction : public CopyImageAction
|
class CopyImage3Dto3DAction : public CopyImageAction {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyImage3Dto3DAction() {}
|
CopyImage3Dto3DAction() {}
|
||||||
virtual ~CopyImage3Dto3DAction() {}
|
virtual ~CopyImage3Dto3DAction() {}
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyImage3Dto3D"; }
|
virtual const char *GetName(void) const { return "CopyImage3Dto3D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Copy2DImageToBufferAction : public Action
|
class Copy2DImageToBufferAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Copy2DImageToBufferAction() {}
|
Copy2DImageToBufferAction() {}
|
||||||
virtual ~Copy2DImageToBufferAction() {}
|
virtual ~Copy2DImageToBufferAction() {}
|
||||||
@@ -254,14 +264,15 @@ class Copy2DImageToBufferAction : public Action
|
|||||||
clMemWrapper mSrcImage, mDstBuffer;
|
clMemWrapper mSrcImage, mDstBuffer;
|
||||||
size_t mWidth, mHeight;
|
size_t mWidth, mHeight;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "Copy2DImageToBuffer"; }
|
virtual const char *GetName(void) const { return "Copy2DImageToBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Copy3DImageToBufferAction : public Action
|
class Copy3DImageToBufferAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Copy3DImageToBufferAction() {}
|
Copy3DImageToBufferAction() {}
|
||||||
virtual ~Copy3DImageToBufferAction() {}
|
virtual ~Copy3DImageToBufferAction() {}
|
||||||
@@ -269,14 +280,15 @@ class Copy3DImageToBufferAction : public Action
|
|||||||
clMemWrapper mSrcImage, mDstBuffer;
|
clMemWrapper mSrcImage, mDstBuffer;
|
||||||
size_t mWidth, mHeight, mDepth;
|
size_t mWidth, mHeight, mDepth;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "Copy3DImageToBuffer"; }
|
virtual const char *GetName(void) const { return "Copy3DImageToBuffer"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyBufferTo2DImageAction : public Action
|
class CopyBufferTo2DImageAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyBufferTo2DImageAction() {}
|
CopyBufferTo2DImageAction() {}
|
||||||
virtual ~CopyBufferTo2DImageAction() {}
|
virtual ~CopyBufferTo2DImageAction() {}
|
||||||
@@ -284,14 +296,15 @@ class CopyBufferTo2DImageAction : public Action
|
|||||||
clMemWrapper mSrcBuffer, mDstImage;
|
clMemWrapper mSrcBuffer, mDstImage;
|
||||||
size_t mWidth, mHeight;
|
size_t mWidth, mHeight;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyBufferTo2D"; }
|
virtual const char *GetName(void) const { return "CopyBufferTo2D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyBufferTo3DImageAction : public Action
|
class CopyBufferTo3DImageAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CopyBufferTo3DImageAction() {}
|
CopyBufferTo3DImageAction() {}
|
||||||
virtual ~CopyBufferTo3DImageAction() {}
|
virtual ~CopyBufferTo3DImageAction() {}
|
||||||
@@ -299,14 +312,15 @@ class CopyBufferTo3DImageAction : public Action
|
|||||||
clMemWrapper mSrcBuffer, mDstImage;
|
clMemWrapper mSrcBuffer, mDstImage;
|
||||||
size_t mWidth, mHeight, mDepth;
|
size_t mWidth, mHeight, mDepth;
|
||||||
|
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "CopyBufferTo3D"; }
|
virtual const char *GetName(void) const { return "CopyBufferTo3D"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapImageAction : public Action
|
class MapImageAction : public Action {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MapImageAction(): mQueue(0) {}
|
MapImageAction(): mQueue(0) {}
|
||||||
|
|
||||||
@@ -316,8 +330,10 @@ class MapImageAction : public Action
|
|||||||
cl_command_queue mQueue;
|
cl_command_queue mQueue;
|
||||||
|
|
||||||
virtual ~MapImageAction();
|
virtual ~MapImageAction();
|
||||||
virtual cl_int Setup( cl_device_id device, cl_context context, cl_command_queue queue );
|
virtual cl_int Setup(cl_device_id device, cl_context context,
|
||||||
virtual cl_int Execute( cl_command_queue queue, cl_uint numWaits, cl_event *waits, cl_event *outEvent );
|
cl_command_queue queue);
|
||||||
|
virtual cl_int Execute(cl_command_queue queue, cl_uint numWaits,
|
||||||
|
cl_event *waits, cl_event *outEvent);
|
||||||
|
|
||||||
virtual const char *GetName(void) const { return "MapImage"; }
|
virtual const char *GetName(void) const { return "MapImage"; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ test_definition test_list[] = {
|
|||||||
ADD_TEST(out_of_order_event_waitlist_multi_queue_multi_device),
|
ADD_TEST(out_of_order_event_waitlist_multi_queue_multi_device),
|
||||||
ADD_TEST(out_of_order_event_enqueue_wait_for_events_single_queue),
|
ADD_TEST(out_of_order_event_enqueue_wait_for_events_single_queue),
|
||||||
ADD_TEST(out_of_order_event_enqueue_wait_for_events_multi_queue),
|
ADD_TEST(out_of_order_event_enqueue_wait_for_events_multi_queue),
|
||||||
ADD_TEST( out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device ),
|
ADD_TEST(
|
||||||
|
out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device),
|
||||||
ADD_TEST(out_of_order_event_enqueue_marker_single_queue),
|
ADD_TEST(out_of_order_event_enqueue_marker_single_queue),
|
||||||
ADD_TEST(out_of_order_event_enqueue_marker_multi_queue),
|
ADD_TEST(out_of_order_event_enqueue_marker_multi_queue),
|
||||||
ADD_TEST(out_of_order_event_enqueue_marker_multi_queue_multi_device),
|
ADD_TEST(out_of_order_event_enqueue_marker_multi_queue_multi_device),
|
||||||
@@ -64,4 +65,3 @@ int main(int argc, const char *argv[])
|
|||||||
{
|
{
|
||||||
return runTestHarness(argc, argv, test_num, test_list, false, 0);
|
return runTestHarness(argc, argv, test_num, test_list, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,40 +22,97 @@ extern float random_float(float low, float high);
|
|||||||
extern float calculate_ulperror(float a, float b);
|
extern float calculate_ulperror(float a, float b);
|
||||||
|
|
||||||
|
|
||||||
extern int test_event_get_execute_status(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_event_get_execute_status(cl_device_id deviceID,
|
||||||
extern int test_event_get_write_array_status(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_event_get_read_array_status(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_command_queue queue,
|
||||||
extern int test_event_get_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
int num_elements);
|
||||||
extern int test_event_wait_for_execute(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_event_get_write_array_status(cl_device_id deviceID,
|
||||||
extern int test_event_wait_for_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_event_flush(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_command_queue queue,
|
||||||
extern int test_event_finish_execute(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
int num_elements);
|
||||||
extern int test_event_finish_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_event_get_read_array_status(cl_device_id deviceID,
|
||||||
extern int test_event_release_before_done(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_event_enqueue_marker(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_event_get_info(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_event_wait_for_execute(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_event_wait_for_array(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_event_flush(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_event_finish_execute(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_event_finish_array(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_event_release_before_done(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_event_enqueue_marker(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
#ifdef CL_VERSION_1_2
|
#ifdef CL_VERSION_1_2
|
||||||
extern int test_event_enqueue_marker_with_event_list(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_event_enqueue_marker_with_event_list(cl_device_id deviceID,
|
||||||
extern int test_event_enqueue_barrier_with_event_list(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_event_enqueue_barrier_with_event_list(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int test_out_of_order_event_waitlist_single_queue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_out_of_order_event_waitlist_single_queue(cl_device_id deviceID,
|
||||||
extern int test_out_of_order_event_waitlist_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_out_of_order_event_waitlist_multi_queue_multi_device(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_out_of_order_event_waitlist_multi_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_out_of_order_event_waitlist_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|
||||||
extern int test_out_of_order_event_enqueue_wait_for_events_single_queue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_out_of_order_event_enqueue_wait_for_events_single_queue(
|
||||||
extern int test_out_of_order_event_enqueue_wait_for_events_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
extern int test_out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
int num_elements);
|
||||||
|
extern int test_out_of_order_event_enqueue_wait_for_events_multi_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int
|
||||||
|
test_out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|
||||||
extern int test_out_of_order_event_enqueue_barrier_single_queue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
extern int test_out_of_order_event_enqueue_barrier_single_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
extern int test_out_of_order_event_enqueue_marker_single_queue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
int num_elements);
|
||||||
extern int test_out_of_order_event_enqueue_marker_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
|
||||||
extern int test_out_of_order_event_enqueue_marker_multi_queue_multi_device(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
|
|
||||||
|
|
||||||
extern int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
|
||||||
extern int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
|
||||||
extern int test_callbacks( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
|
||||||
extern int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
|
||||||
extern int test_userevents_multithreaded( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
|
||||||
|
|
||||||
|
extern int test_out_of_order_event_enqueue_marker_single_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_out_of_order_event_enqueue_marker_multi_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_out_of_order_event_enqueue_marker_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|
||||||
|
extern int test_waitlists(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_userevents(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_callbacks(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements);
|
||||||
|
extern int test_callbacks_simultaneous(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
extern int test_userevents_multithreaded(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|||||||
@@ -26,6 +26,3 @@
|
|||||||
#include "procs.h"
|
#include "procs.h"
|
||||||
|
|
||||||
#endif // _testBase_h
|
#endif // _testBase_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,20 +26,26 @@ extern const char *IGetStatusString( cl_int status );
|
|||||||
|
|
||||||
#define PRINT_OPS 0
|
#define PRINT_OPS 0
|
||||||
|
|
||||||
// Yes, this is somewhat nasty, in that we're relying on the CPU (the real CPU, not the OpenCL device)
|
// Yes, this is somewhat nasty, in that we're relying on the CPU (the real CPU,
|
||||||
// to be atomic w.r.t. boolean values. Although if it isn't, we'll just miss the check on this bool
|
// not the OpenCL device) to be atomic w.r.t. boolean values. Although if it
|
||||||
// until the next time around, so it's not that big of a deal. Ideally, we'd be using a semaphore with
|
// isn't, we'll just miss the check on this bool until the next time around, so
|
||||||
// a trywait on it, but then that introduces the fun issue of what to do on Win32, etc. This way is
|
// it's not that big of a deal. Ideally, we'd be using a semaphore with a
|
||||||
// far more portable, and worst case of failure is a slightly longer test run.
|
// trywait on it, but then that introduces the fun issue of what to do on Win32,
|
||||||
|
// etc. This way is far more portable, and worst case of failure is a slightly
|
||||||
|
// longer test run.
|
||||||
static bool sCallbackTriggered = false;
|
static bool sCallbackTriggered = false;
|
||||||
|
|
||||||
|
|
||||||
#define EVENT_CALLBACK_TYPE_TOTAL 3
|
#define EVENT_CALLBACK_TYPE_TOTAL 3
|
||||||
static bool sCallbackTriggered_flag[ EVENT_CALLBACK_TYPE_TOTAL ] ={ false,false, false };
|
static bool sCallbackTriggered_flag[EVENT_CALLBACK_TYPE_TOTAL] = { false, false,
|
||||||
cl_int event_callback_types[EVENT_CALLBACK_TYPE_TOTAL] ={ CL_SUBMITTED, CL_RUNNING, CL_COMPLETE};
|
false };
|
||||||
|
cl_int event_callback_types[EVENT_CALLBACK_TYPE_TOTAL] = { CL_SUBMITTED,
|
||||||
|
CL_RUNNING,
|
||||||
|
CL_COMPLETE };
|
||||||
|
|
||||||
// Our callback function
|
// Our callback function
|
||||||
/*void CL_CALLBACK single_event_callback_function( cl_event event, cl_int commandStatus, void * userData )
|
/*void CL_CALLBACK single_event_callback_function( cl_event event, cl_int
|
||||||
|
commandStatus, void * userData )
|
||||||
{
|
{
|
||||||
int i=*static_cast<int *>(userData);
|
int i=*static_cast<int *>(userData);
|
||||||
log_info( "\tEvent callback %d triggered\n", i);
|
log_info( "\tEvent callback %d triggered\n", i);
|
||||||
@@ -47,21 +53,29 @@ cl_int event_callback_types[EVENT_CALLBACK_TYPE_TOTAL] ={ CL_SUBMITTED, CL_RUNNI
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* use struct as call back para */
|
/* use struct as call back para */
|
||||||
typedef struct { cl_int enevt_type; int index; } CALL_BACK_USER_DATA;
|
typedef struct
|
||||||
|
{
|
||||||
|
cl_int enevt_type;
|
||||||
|
int index;
|
||||||
|
} CALL_BACK_USER_DATA;
|
||||||
|
|
||||||
void CL_CALLBACK single_event_callback_function_flags( cl_event event, cl_int commandStatus, void * userData )
|
void CL_CALLBACK single_event_callback_function_flags(cl_event event,
|
||||||
|
cl_int commandStatus,
|
||||||
|
void *userData)
|
||||||
{
|
{
|
||||||
// int i=*static_cast<int *>(userData);
|
// int i=*static_cast<int *>(userData);
|
||||||
CALL_BACK_USER_DATA *pdata = static_cast<CALL_BACK_USER_DATA *>(userData);
|
CALL_BACK_USER_DATA *pdata = static_cast<CALL_BACK_USER_DATA *>(userData);
|
||||||
|
|
||||||
log_info( "\tEvent callback %d of type %d triggered\n", pdata->index, pdata->enevt_type);
|
log_info("\tEvent callback %d of type %d triggered\n", pdata->index,
|
||||||
|
pdata->enevt_type);
|
||||||
sCallbackTriggered_flag[pdata->index] = true;
|
sCallbackTriggered_flag[pdata->index] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_callback_event_single( cl_device_id device, cl_context context, cl_command_queue queue, Action *actionToTest )
|
int test_callback_event_single(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, Action *actionToTest)
|
||||||
{
|
{
|
||||||
// Note: we don't use the waiting feature here. We just want to verify that we get a callback called
|
// Note: we don't use the waiting feature here. We just want to verify that
|
||||||
// when the given event finishes
|
// we get a callback called when the given event finishes
|
||||||
|
|
||||||
cl_int error = actionToTest->Setup(device, context, queue);
|
cl_int error = actionToTest->Setup(device, context, queue);
|
||||||
test_error(error, "Unable to set up test action");
|
test_error(error, "Unable to set up test action");
|
||||||
@@ -83,26 +97,30 @@ int test_callback_event_single( cl_device_id device, cl_context context, cl_comm
|
|||||||
{
|
{
|
||||||
user_data[i].enevt_type = event_callback_types[i];
|
user_data[i].enevt_type = event_callback_types[i];
|
||||||
user_data[i].index = i;
|
user_data[i].index = i;
|
||||||
error = clSetEventCallback( actualEvent, event_callback_types[i], single_event_callback_function_flags, user_data+i );
|
error = clSetEventCallback(actualEvent, event_callback_types[i],
|
||||||
|
single_event_callback_function_flags,
|
||||||
|
user_data + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now release the user event, which will allow our actual action to run
|
// Now release the user event, which will allow our actual action to run
|
||||||
error = clSetUserEventStatus(gateEvent, CL_COMPLETE);
|
error = clSetUserEventStatus(gateEvent, CL_COMPLETE);
|
||||||
test_error(error, "Unable to trigger gate event");
|
test_error(error, "Unable to trigger gate event");
|
||||||
|
|
||||||
// Now we wait for completion. Note that we can actually wait on the event itself, at least at first
|
// Now we wait for completion. Note that we can actually wait on the event
|
||||||
|
// itself, at least at first
|
||||||
error = clWaitForEvents(1, &actualEvent);
|
error = clWaitForEvents(1, &actualEvent);
|
||||||
test_error(error, "Unable to wait for actual test event");
|
test_error(error, "Unable to wait for actual test event");
|
||||||
|
|
||||||
// Note: we can check our callback now, and it MIGHT have been triggered, but that's not guaranteed
|
// Note: we can check our callback now, and it MIGHT have been triggered,
|
||||||
|
// but that's not guaranteed
|
||||||
if (sCallbackTriggered)
|
if (sCallbackTriggered)
|
||||||
{
|
{
|
||||||
// We're all good, so return success
|
// We're all good, so return success
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The callback has not yet been called, but that doesn't mean it won't be. So wait for it
|
// The callback has not yet been called, but that doesn't mean it won't be.
|
||||||
|
// So wait for it
|
||||||
log_info("\tWaiting for callback...");
|
log_info("\tWaiting for callback...");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
for (int i = 0; i < 10 * 10; i++)
|
for (int i = 0; i < 10 * 10; i++)
|
||||||
@@ -134,12 +152,15 @@ int test_callback_event_single( cl_device_id device, cl_context context, cl_comm
|
|||||||
{ \
|
{ \
|
||||||
name##Action action; \
|
name##Action action; \
|
||||||
log_info("-- Testing " #name "...\n"); \
|
log_info("-- Testing " #name "...\n"); \
|
||||||
if( ( error = test_callback_event_single( deviceID, context, queue, &action ) ) != CL_SUCCESS ) \
|
if ((error = test_callback_event_single(deviceID, context, queue, \
|
||||||
|
&action)) \
|
||||||
|
!= CL_SUCCESS) \
|
||||||
retVal++; \
|
retVal++; \
|
||||||
clFinish(queue); \
|
clFinish(queue); \
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_callbacks( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
int test_callbacks(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
@@ -155,7 +176,8 @@ int test_callbacks( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
|
|
||||||
if (checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
if (checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
||||||
{
|
{
|
||||||
log_info( "\nNote: device does not support images. Skipping remainder of callback tests...\n" );
|
log_info("\nNote: device does not support images. Skipping remainder "
|
||||||
|
"of callback tests...\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -167,7 +189,8 @@ int test_callbacks( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
TEST_ACTION(MapImage)
|
TEST_ACTION(MapImage)
|
||||||
|
|
||||||
if (checkFor3DImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
if (checkFor3DImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
||||||
log_info( "\nNote: device does not support 3D images. Skipping remainder of waitlist tests...\n" );
|
log_info("\nNote: device does not support 3D images. Skipping "
|
||||||
|
"remainder of waitlist tests...\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TEST_ACTION(ReadImage3D)
|
TEST_ACTION(ReadImage3D)
|
||||||
@@ -190,23 +213,27 @@ static volatile int sSimultaneousCount;
|
|||||||
Action *actions[19] = { 0 };
|
Action *actions[19] = { 0 };
|
||||||
|
|
||||||
// Callback for the simultaneous tests
|
// Callback for the simultaneous tests
|
||||||
void CL_CALLBACK simultaneous_event_callback_function( cl_event event, cl_int commandStatus, void * userData )
|
void CL_CALLBACK simultaneous_event_callback_function(cl_event event,
|
||||||
|
cl_int commandStatus,
|
||||||
|
void *userData)
|
||||||
{
|
{
|
||||||
int eventIndex = (int)(size_t)userData;
|
int eventIndex = (int)(size_t)userData;
|
||||||
int actionIndex = eventIndex / EVENT_CALLBACK_TYPE_TOTAL;
|
int actionIndex = eventIndex / EVENT_CALLBACK_TYPE_TOTAL;
|
||||||
int statusIndex = eventIndex % EVENT_CALLBACK_TYPE_TOTAL;
|
int statusIndex = eventIndex % EVENT_CALLBACK_TYPE_TOTAL;
|
||||||
log_info( "\tEvent callback triggered for action %s callback type %s \n", actions[actionIndex]->GetName(), IGetStatusString(statusIndex) );
|
log_info("\tEvent callback triggered for action %s callback type %s \n",
|
||||||
|
actions[actionIndex]->GetName(), IGetStatusString(statusIndex));
|
||||||
sSimultaneousFlags[actionIndex] = true;
|
sSimultaneousFlags[actionIndex] = true;
|
||||||
ThreadPool_AtomicAdd(&sSimultaneousCount, 1);
|
ThreadPool_AtomicAdd(&sSimultaneousCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
int test_callbacks_simultaneous(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
// Unlike the singles test, in this one, we run a bunch of events all at once, to verify that
|
// Unlike the singles test, in this one, we run a bunch of events all at
|
||||||
// the callbacks do get called once-and-only-once for each event, even if the run out of order or
|
// once, to verify that the callbacks do get called once-and-only-once for
|
||||||
// are dependent on each other
|
// each event, even if the run out of order or are dependent on each other
|
||||||
|
|
||||||
// First, the list of actions to run
|
// First, the list of actions to run
|
||||||
int actionCount = 0, index = 0;
|
int actionCount = 0, index = 0;
|
||||||
@@ -273,15 +300,18 @@ int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
if ((index > 0) && (random_in_range(0, 255, seed) & 1))
|
if ((index > 0) && (random_in_range(0, 255, seed) & 1))
|
||||||
eventPtr = &actionEvents[index - 1];
|
eventPtr = &actionEvents[index - 1];
|
||||||
|
|
||||||
error = actions[ index ]->Execute( queue, 1, eventPtr, &actionEvents[ index ] );
|
error =
|
||||||
|
actions[index]->Execute(queue, 1, eventPtr, &actionEvents[index]);
|
||||||
test_error(error, "Unable to execute test action");
|
test_error(error, "Unable to execute test action");
|
||||||
|
|
||||||
|
|
||||||
for (int k = 0; k < EVENT_CALLBACK_TYPE_TOTAL; k++)
|
for (int k = 0; k < EVENT_CALLBACK_TYPE_TOTAL; k++)
|
||||||
{
|
{
|
||||||
error = clSetEventCallback( actionEvents[index], event_callback_types[k], simultaneous_event_callback_function, (void *)(size_t)(index*EVENT_CALLBACK_TYPE_TOTAL+k ) );
|
error = clSetEventCallback(
|
||||||
|
actionEvents[index], event_callback_types[k],
|
||||||
|
simultaneous_event_callback_function,
|
||||||
|
(void *)(size_t)(index * EVENT_CALLBACK_TYPE_TOTAL + k));
|
||||||
test_error(error, "Unable to set event callback function");
|
test_error(error, "Unable to set event callback function");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,12 +326,14 @@ int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
error = clWaitForEvents(actionCount, &actionEvents[0]);
|
error = clWaitForEvents(actionCount, &actionEvents[0]);
|
||||||
test_error(error, "Unable to wait for actual test events");
|
test_error(error, "Unable to wait for actual test events");
|
||||||
|
|
||||||
// Note: we can check our callback now, and it MIGHT have been triggered, but that's not guaranteed
|
// Note: we can check our callback now, and it MIGHT have been triggered,
|
||||||
|
// but that's not guaranteed
|
||||||
int last_count = 0;
|
int last_count = 0;
|
||||||
if (((last_count = sSimultaneousCount)) == total_callbacks)
|
if (((last_count = sSimultaneousCount)) == total_callbacks)
|
||||||
{
|
{
|
||||||
// We're all good, so return success
|
// We're all good, so return success
|
||||||
log_info( "\t%d of %d callbacks received\n", sSimultaneousCount, total_callbacks );
|
log_info("\t%d of %d callbacks received\n", sSimultaneousCount,
|
||||||
|
total_callbacks);
|
||||||
|
|
||||||
if (actionEvents) delete[] actionEvents;
|
if (actionEvents) delete[] actionEvents;
|
||||||
for (size_t i = 0; i < (sizeof(actions) / sizeof(actions[0])); ++i)
|
for (size_t i = 0; i < (sizeof(actions) / sizeof(actions[0])); ++i)
|
||||||
@@ -310,7 +342,9 @@ int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We haven't gotten (all) of the callbacks, so wait for them
|
// We haven't gotten (all) of the callbacks, so wait for them
|
||||||
log_info( "\tWe've only received %d of the %d callbacks we expected; waiting for more...\n", last_count, total_callbacks );
|
log_info("\tWe've only received %d of the %d callbacks we expected; "
|
||||||
|
"waiting for more...\n",
|
||||||
|
last_count, total_callbacks);
|
||||||
|
|
||||||
for (int i = 0; i < 10 * 10; i++)
|
for (int i = 0; i < 10 * 10; i++)
|
||||||
{
|
{
|
||||||
@@ -326,7 +360,8 @@ int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we got here, some of the callbacks did not occur in time
|
// If we got here, some of the callbacks did not occur in time
|
||||||
log_error( "\nError: We only ever received %d of our %d callbacks!\n", last_count, total_callbacks );
|
log_error("\nError: We only ever received %d of our %d callbacks!\n",
|
||||||
|
last_count, total_callbacks);
|
||||||
log_error("Events that did not receive callbacks:\n");
|
log_error("Events that did not receive callbacks:\n");
|
||||||
for (index = 0; actions[index] != NULL; index++)
|
for (index = 0; actions[index] != NULL; index++)
|
||||||
{
|
{
|
||||||
@@ -336,6 +371,4 @@ int test_callbacks_simultaneous( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
|
|
||||||
if (actionEvents) delete[] actionEvents;
|
if (actionEvents) delete[] actionEvents;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,16 @@ const char *write_kernels[] = {
|
|||||||
/*
|
/*
|
||||||
Tests event dependencies by running two kernels that use the same buffer.
|
Tests event dependencies by running two kernels that use the same buffer.
|
||||||
If two_queues is set they are run in separate queues.
|
If two_queues is set they are run in separate queues.
|
||||||
If test_enqueue_wait_for_events is set then clEnqueueWaitForEvent is called between them.
|
If test_enqueue_wait_for_events is set then clEnqueueWaitForEvent is called
|
||||||
If test_barrier is set then clEnqueueBarrier is called between them (only for single queue).
|
between them. If test_barrier is set then clEnqueueBarrier is called between
|
||||||
If neither are set, nothing is done to prevent them from executing in the wrong order. This can be used for verification.
|
them (only for single queue). If neither are set, nothing is done to prevent
|
||||||
|
them from executing in the wrong order. This can be used for verification.
|
||||||
*/
|
*/
|
||||||
int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, int two_queues, int two_devices,
|
int test_event_enqueue_wait_for_events_run_test(
|
||||||
int test_enqueue_wait_for_events, int test_barrier, int use_waitlist, int use_marker)
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements, int two_queues, int two_devices,
|
||||||
|
int test_enqueue_wait_for_events, int test_barrier, int use_waitlist,
|
||||||
|
int use_marker)
|
||||||
{
|
{
|
||||||
cl_int error = CL_SUCCESS;
|
cl_int error = CL_SUCCESS;
|
||||||
size_t threads[3] = { TEST_SIZE, 0, 0 };
|
size_t threads[3] = { TEST_SIZE, 0, 0 };
|
||||||
@@ -53,46 +57,60 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
int max_count = TEST_SIZE;
|
int max_count = TEST_SIZE;
|
||||||
|
|
||||||
cl_platform_id platform;
|
cl_platform_id platform;
|
||||||
cl_command_queue queues[2]; // Not a wrapper so we don't autorelease if they are the same
|
cl_command_queue
|
||||||
clCommandQueueWrapper queueWrappers[2]; // If they are different, we use the wrapper so it will auto release
|
queues[2]; // Not a wrapper so we don't autorelease if they are the same
|
||||||
|
clCommandQueueWrapper queueWrappers[2]; // If they are different, we use the
|
||||||
|
// wrapper so it will auto release
|
||||||
clContextWrapper context_to_use;
|
clContextWrapper context_to_use;
|
||||||
clMemWrapper data;
|
clMemWrapper data;
|
||||||
clProgramWrapper program;
|
clProgramWrapper program;
|
||||||
clKernelWrapper kernel1[TEST_COUNT], kernel2[TEST_COUNT];
|
clKernelWrapper kernel1[TEST_COUNT], kernel2[TEST_COUNT];
|
||||||
clEventWrapper event[TEST_COUNT*4+2]; // If we usemarkers we get 2 more events per iteration
|
clEventWrapper event[TEST_COUNT * 4 + 2]; // If we usemarkers we get 2 more
|
||||||
|
// events per iteration
|
||||||
|
|
||||||
if (test_enqueue_wait_for_events)
|
if (test_enqueue_wait_for_events)
|
||||||
log_info("\tTesting with clEnqueueBarrierWithWaitList as barrier function.\n");
|
log_info("\tTesting with clEnqueueBarrierWithWaitList as barrier "
|
||||||
|
"function.\n");
|
||||||
if (test_barrier)
|
if (test_barrier)
|
||||||
log_info("\tTesting with clEnqueueBarrierWithWaitList as barrier function.\n");
|
log_info("\tTesting with clEnqueueBarrierWithWaitList as barrier "
|
||||||
|
"function.\n");
|
||||||
if (use_waitlist)
|
if (use_waitlist)
|
||||||
log_info("\tTesting with waitlist-based depenednecies between kernels.\n");
|
log_info(
|
||||||
|
"\tTesting with waitlist-based depenednecies between kernels.\n");
|
||||||
if (use_marker)
|
if (use_marker)
|
||||||
log_info("\tTesting with clEnqueueMarker as a barrier function.\n");
|
log_info("\tTesting with clEnqueueMarker as a barrier function.\n");
|
||||||
if (test_barrier && (two_queues || two_devices)) {
|
if (test_barrier && (two_queues || two_devices))
|
||||||
log_error("\tTest requested with clEnqueueBarrier across two queues. This is not a valid combination.\n");
|
{
|
||||||
|
log_error("\tTest requested with clEnqueueBarrier across two queues. "
|
||||||
|
"This is not a valid combination.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetPlatformIDs(1, &platform, NULL);
|
error = clGetPlatformIDs(1, &platform, NULL);
|
||||||
test_error(error, "clGetPlatformIDs failed.");
|
test_error(error, "clGetPlatformIDs failed.");
|
||||||
|
|
||||||
// If we are to use two devices, then get them and create a context with both.
|
// If we are to use two devices, then get them and create a context with
|
||||||
|
// both.
|
||||||
cl_device_id *two_device_ids;
|
cl_device_id *two_device_ids;
|
||||||
if (two_devices) {
|
if (two_devices)
|
||||||
|
{
|
||||||
two_device_ids = (cl_device_id *)malloc(sizeof(cl_device_id) * 2);
|
two_device_ids = (cl_device_id *)malloc(sizeof(cl_device_id) * 2);
|
||||||
cl_uint number_returned;
|
cl_uint number_returned;
|
||||||
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 2, two_device_ids, &number_returned);
|
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 2, two_device_ids,
|
||||||
|
&number_returned);
|
||||||
test_error(error, "clGetDeviceIDs for CL_DEVICE_TYPE_ALL failed.");
|
test_error(error, "clGetDeviceIDs for CL_DEVICE_TYPE_ALL failed.");
|
||||||
if (number_returned != 2) {
|
if (number_returned != 2)
|
||||||
|
{
|
||||||
log_info("Failed to obtain two devices. Test can not run.\n");
|
log_info("Failed to obtain two devices. Test can not run.\n");
|
||||||
free(two_device_ids);
|
free(two_device_ids);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<2; i++) {
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
cl_device_type type;
|
cl_device_type type;
|
||||||
error = clGetDeviceInfo(two_device_ids[i], CL_DEVICE_TYPE, sizeof(cl_device_type), &type, NULL);
|
error = clGetDeviceInfo(two_device_ids[i], CL_DEVICE_TYPE,
|
||||||
|
sizeof(cl_device_type), &type, NULL);
|
||||||
test_error(error, "clGetDeviceInfo failed.");
|
test_error(error, "clGetDeviceInfo failed.");
|
||||||
if (type & CL_DEVICE_TYPE_CPU)
|
if (type & CL_DEVICE_TYPE_CPU)
|
||||||
log_info("\tDevice %d is CL_DEVICE_TYPE_CPU.\n", i);
|
log_info("\tDevice %d is CL_DEVICE_TYPE_CPU.\n", i);
|
||||||
@@ -104,12 +122,16 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
log_info("\tDevice %d is CL_DEVICE_TYPE_DEFAULT.\n", i);
|
log_info("\tDevice %d is CL_DEVICE_TYPE_DEFAULT.\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
context_to_use = clCreateContext(NULL, 2, two_device_ids, notify_callback, NULL, &error);
|
context_to_use = clCreateContext(NULL, 2, two_device_ids,
|
||||||
|
notify_callback, NULL, &error);
|
||||||
test_error(error, "clCreateContext failed for two devices.");
|
test_error(error, "clCreateContext failed for two devices.");
|
||||||
|
|
||||||
log_info("\tTesting with two devices.\n");
|
log_info("\tTesting with two devices.\n");
|
||||||
} else {
|
}
|
||||||
context_to_use = clCreateContext(NULL, 1, &deviceID, NULL, NULL, &error);
|
else
|
||||||
|
{
|
||||||
|
context_to_use =
|
||||||
|
clCreateContext(NULL, 1, &deviceID, NULL, NULL, &error);
|
||||||
test_error(error, "clCreateContext failed for one device.");
|
test_error(error, "clCreateContext failed for one device.");
|
||||||
|
|
||||||
log_info("\tTesting with one device.\n");
|
log_info("\tTesting with one device.\n");
|
||||||
@@ -117,41 +139,55 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
|
|
||||||
// If we are using two queues then create them
|
// If we are using two queues then create them
|
||||||
cl_command_queue_properties props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
|
cl_command_queue_properties props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
|
||||||
if (two_queues) {
|
if (two_queues)
|
||||||
|
{
|
||||||
// Get a second queue
|
// Get a second queue
|
||||||
if (two_devices)
|
if (two_devices)
|
||||||
{
|
{
|
||||||
if( !checkDeviceForQueueSupport( two_device_ids[ 0 ], props ) ||
|
if (!checkDeviceForQueueSupport(two_device_ids[0], props)
|
||||||
!checkDeviceForQueueSupport( two_device_ids[ 1 ], props ) )
|
|| !checkDeviceForQueueSupport(two_device_ids[1], props))
|
||||||
{
|
{
|
||||||
log_info( "WARNING: One or more device for multi-device test does not support out-of-order exec mode; skipping test.\n" );
|
log_info(
|
||||||
|
"WARNING: One or more device for multi-device test does "
|
||||||
|
"not support out-of-order exec mode; skipping test.\n");
|
||||||
return -1942;
|
return -1942;
|
||||||
}
|
}
|
||||||
|
|
||||||
queueWrappers[0] = clCreateCommandQueue(context_to_use, two_device_ids[0], props, &error);
|
queueWrappers[0] = clCreateCommandQueue(
|
||||||
test_error(error, "clCreateCommandQueue for first queue on first device failed.");
|
context_to_use, two_device_ids[0], props, &error);
|
||||||
queueWrappers[1] = clCreateCommandQueue(context_to_use, two_device_ids[1], props, &error);
|
test_error(
|
||||||
test_error(error, "clCreateCommandQueue for second queue on second device failed.");
|
error,
|
||||||
|
"clCreateCommandQueue for first queue on first device failed.");
|
||||||
|
queueWrappers[1] = clCreateCommandQueue(
|
||||||
|
context_to_use, two_device_ids[1], props, &error);
|
||||||
|
test_error(error,
|
||||||
|
"clCreateCommandQueue for second queue on second device "
|
||||||
|
"failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Single device has already been checked for out-of-order exec support
|
// Single device has already been checked for out-of-order exec
|
||||||
queueWrappers[0] = clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
// support
|
||||||
|
queueWrappers[0] =
|
||||||
|
clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
||||||
test_error(error, "clCreateCommandQueue for first queue failed.");
|
test_error(error, "clCreateCommandQueue for first queue failed.");
|
||||||
queueWrappers[1] = clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
queueWrappers[1] =
|
||||||
|
clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
||||||
test_error(error, "clCreateCommandQueue for second queue failed.");
|
test_error(error, "clCreateCommandQueue for second queue failed.");
|
||||||
}
|
}
|
||||||
// Ugly hack to make sure we only have the wrapper auto-release if they are different queues
|
// Ugly hack to make sure we only have the wrapper auto-release if they
|
||||||
|
// are different queues
|
||||||
queues[0] = queueWrappers[0];
|
queues[0] = queueWrappers[0];
|
||||||
queues[1] = queueWrappers[1];
|
queues[1] = queueWrappers[1];
|
||||||
log_info("\tTesting with two queues.\n");
|
log_info("\tTesting with two queues.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// (Note: single device has already been checked for out-of-order exec support)
|
// (Note: single device has already been checked for out-of-order exec
|
||||||
// Otherwise create one queue and have the second one be the same
|
// support) Otherwise create one queue and have the second one be the
|
||||||
queueWrappers[0] = clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
// same
|
||||||
|
queueWrappers[0] =
|
||||||
|
clCreateCommandQueue(context_to_use, deviceID, props, &error);
|
||||||
test_error(error, "clCreateCommandQueue for first queue failed.");
|
test_error(error, "clCreateCommandQueue for first queue failed.");
|
||||||
queues[0] = queueWrappers[0];
|
queues[0] = queueWrappers[0];
|
||||||
queues[1] = (cl_command_queue)queues[0];
|
queues[1] = (cl_command_queue)queues[0];
|
||||||
@@ -160,27 +196,31 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
|
|
||||||
|
|
||||||
// Setup - create a buffer and the two kernels
|
// Setup - create a buffer and the two kernels
|
||||||
data = clCreateBuffer(context_to_use, CL_MEM_READ_WRITE, TEST_SIZE*sizeof(cl_int), NULL, &error);
|
data = clCreateBuffer(context_to_use, CL_MEM_READ_WRITE,
|
||||||
|
TEST_SIZE * sizeof(cl_int), NULL, &error);
|
||||||
test_error(error, "clCreateBuffer failed");
|
test_error(error, "clCreateBuffer failed");
|
||||||
|
|
||||||
|
|
||||||
// Initialize the values to zero
|
// Initialize the values to zero
|
||||||
cl_int *values = (cl_int *)malloc(TEST_SIZE * sizeof(cl_int));
|
cl_int *values = (cl_int *)malloc(TEST_SIZE * sizeof(cl_int));
|
||||||
for (i=0; i<(int)TEST_SIZE; i++)
|
for (i = 0; i < (int)TEST_SIZE; i++) values[i] = 0;
|
||||||
values[i] = 0;
|
error =
|
||||||
error = clEnqueueWriteBuffer(queues[0], data, CL_TRUE, 0, TEST_SIZE*sizeof(cl_int), values, 0, NULL, NULL);
|
clEnqueueWriteBuffer(queues[0], data, CL_TRUE, 0,
|
||||||
|
TEST_SIZE * sizeof(cl_int), values, 0, NULL, NULL);
|
||||||
test_error(error, "clEnqueueWriteBuffer failed");
|
test_error(error, "clEnqueueWriteBuffer failed");
|
||||||
expected_value = 0;
|
expected_value = 0;
|
||||||
|
|
||||||
// Build the kernels
|
// Build the kernels
|
||||||
if (create_single_kernel_helper( context_to_use, &program, &kernel1[0], 1, write_kernels, "write_up" ))
|
if (create_single_kernel_helper(context_to_use, &program, &kernel1[0], 1,
|
||||||
|
write_kernels, "write_up"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
error = clSetKernelArg(kernel1[0], 0, sizeof(data), &data);
|
error = clSetKernelArg(kernel1[0], 0, sizeof(data), &data);
|
||||||
error |= clSetKernelArg(kernel1[0], 1, sizeof(max_count), &max_count);
|
error |= clSetKernelArg(kernel1[0], 1, sizeof(max_count), &max_count);
|
||||||
test_error(error, "clSetKernelArg 1 failed");
|
test_error(error, "clSetKernelArg 1 failed");
|
||||||
|
|
||||||
for (i=1; i<TEST_COUNT; i++) {
|
for (i = 1; i < TEST_COUNT; i++)
|
||||||
|
{
|
||||||
kernel1[i] = clCreateKernel(program, "write_up", &error);
|
kernel1[i] = clCreateKernel(program, "write_up", &error);
|
||||||
test_error(error, "clCreateKernel 1 failed");
|
test_error(error, "clCreateKernel 1 failed");
|
||||||
|
|
||||||
@@ -189,7 +229,8 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
test_error(error, "clSetKernelArg 1 failed");
|
test_error(error, "clSetKernelArg 1 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<TEST_COUNT; i++) {
|
for (i = 0; i < TEST_COUNT; i++)
|
||||||
|
{
|
||||||
kernel2[i] = clCreateKernel(program, "write_down", &error);
|
kernel2[i] = clCreateKernel(program, "write_down", &error);
|
||||||
test_error(error, "clCreateKernel 2 failed");
|
test_error(error, "clCreateKernel 2 failed");
|
||||||
|
|
||||||
@@ -198,44 +239,67 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
test_error(error, "clSetKernelArg 2 failed");
|
test_error(error, "clSetKernelArg 2 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execution - run the first kernel, then enqueue the wait on the events, then the second kernel
|
// Execution - run the first kernel, then enqueue the wait on the events,
|
||||||
// If clEnqueueBarrierWithWaitList works, the buffer will be filled with 1s, then multiplied by 4s,
|
// then the second kernel If clEnqueueBarrierWithWaitList works, the buffer
|
||||||
// then incremented to 5s, repeatedly. Otherwise the values may be 2s (if the first one doesn't work) or 8s
|
// will be filled with 1s, then multiplied by 4s, then incremented to 5s,
|
||||||
// (if the second one doesn't work).
|
// repeatedly. Otherwise the values may be 2s (if the first one doesn't
|
||||||
|
// work) or 8s (if the second one doesn't work).
|
||||||
if (RANDOMIZE)
|
if (RANDOMIZE)
|
||||||
log_info("Queues chosen randomly for each kernel execution.\n");
|
log_info("Queues chosen randomly for each kernel execution.\n");
|
||||||
else
|
else
|
||||||
log_info("Queues chosen alternatily for each kernel execution.\n");
|
log_info("Queues chosen alternatily for each kernel execution.\n");
|
||||||
|
|
||||||
event_count = 0;
|
event_count = 0;
|
||||||
for (i=0; i<(int)TEST_SIZE; i++)
|
for (i = 0; i < (int)TEST_SIZE; i++) values[i] = 1;
|
||||||
values[i] = 1;
|
error = clEnqueueWriteBuffer(queues[0], data, CL_FALSE, 0,
|
||||||
error = clEnqueueWriteBuffer(queues[0], data, CL_FALSE, 0, TEST_SIZE*sizeof(cl_int), values, 0, NULL, &event[event_count]);
|
TEST_SIZE * sizeof(cl_int), values, 0, NULL,
|
||||||
|
&event[event_count]);
|
||||||
test_error(error, "clEnqueueWriteBuffer 2 failed");
|
test_error(error, "clEnqueueWriteBuffer 2 failed");
|
||||||
expected_value = 1;
|
expected_value = 1;
|
||||||
expected_if_only_queue[0] = 1;
|
expected_if_only_queue[0] = 1;
|
||||||
expected_if_only_queue[1] = 1;
|
expected_if_only_queue[1] = 1;
|
||||||
|
|
||||||
int queue_to_use = 1;
|
int queue_to_use = 1;
|
||||||
if (test_enqueue_wait_for_events) {
|
if (test_enqueue_wait_for_events)
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1, &event[event_count], NULL );
|
{
|
||||||
|
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1,
|
||||||
|
&event[event_count], NULL);
|
||||||
test_error(error, "Unable to queue wait for events");
|
test_error(error, "Unable to queue wait for events");
|
||||||
} else if (test_barrier) {
|
}
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL, NULL);
|
else if (test_barrier)
|
||||||
|
{
|
||||||
|
error =
|
||||||
|
clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL, NULL);
|
||||||
test_error(error, "Unable to queue barrier");
|
test_error(error, "Unable to queue barrier");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (loop_count=0; loop_count<TEST_COUNT; loop_count++) {
|
for (loop_count = 0; loop_count < TEST_COUNT; loop_count++)
|
||||||
|
{
|
||||||
// Execute kernel 1
|
// Execute kernel 1
|
||||||
event_count++;
|
event_count++;
|
||||||
if (use_waitlist | use_marker) {
|
if (use_waitlist | use_marker)
|
||||||
if (DEBUG_OUT) log_info("clEnqueueNDRangeKernel(queues[%d], kernel1[%d], 1, NULL, threads, NULL, 1, &event[%d], &event[%d])\n", queue_to_use, loop_count, event_count-1, event_count);
|
{
|
||||||
error = clEnqueueNDRangeKernel(queues[queue_to_use], kernel1[loop_count], 1, NULL, threads, NULL, 1, &event[event_count-1], &event[event_count]);
|
if (DEBUG_OUT)
|
||||||
} else {
|
log_info("clEnqueueNDRangeKernel(queues[%d], kernel1[%d], 1, "
|
||||||
if (DEBUG_OUT) log_info("clEnqueueNDRangeKernel(queues[%d], kernel1[%d], 1, NULL, threads, NULL, 0, NULL, &event[%d])\n", queue_to_use, loop_count, event_count);
|
"NULL, threads, NULL, 1, &event[%d], &event[%d])\n",
|
||||||
error = clEnqueueNDRangeKernel(queues[queue_to_use], kernel1[loop_count], 1, NULL, threads, NULL, 0, NULL, &event[event_count]);
|
queue_to_use, loop_count, event_count - 1,
|
||||||
|
event_count);
|
||||||
|
error = clEnqueueNDRangeKernel(
|
||||||
|
queues[queue_to_use], kernel1[loop_count], 1, NULL, threads,
|
||||||
|
NULL, 1, &event[event_count - 1], &event[event_count]);
|
||||||
}
|
}
|
||||||
if (error) {
|
else
|
||||||
|
{
|
||||||
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueNDRangeKernel(queues[%d], kernel1[%d], 1, "
|
||||||
|
"NULL, threads, NULL, 0, NULL, &event[%d])\n",
|
||||||
|
queue_to_use, loop_count, event_count);
|
||||||
|
error = clEnqueueNDRangeKernel(
|
||||||
|
queues[queue_to_use], kernel1[loop_count], 1, NULL, threads,
|
||||||
|
NULL, 0, NULL, &event[event_count]);
|
||||||
|
}
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
log_info("\tLoop count %d\n", loop_count);
|
log_info("\tLoop count %d\n", loop_count);
|
||||||
print_error(error, "clEnqueueNDRangeKernel for kernel 1 failed");
|
print_error(error, "clEnqueueNDRangeKernel for kernel 1 failed");
|
||||||
return error;
|
return error;
|
||||||
@@ -244,16 +308,19 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
expected_if_only_queue[queue_to_use] *= 2;
|
expected_if_only_queue[queue_to_use] *= 2;
|
||||||
|
|
||||||
// If we are using a marker, it needs to go in the same queue
|
// If we are using a marker, it needs to go in the same queue
|
||||||
if (use_marker) {
|
if (use_marker)
|
||||||
|
{
|
||||||
event_count++;
|
event_count++;
|
||||||
if (DEBUG_OUT) log_info("clEnqueueMarker(queues[%d], event[%d])\n", queue_to_use, event_count);
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueMarker(queues[%d], event[%d])\n",
|
||||||
|
queue_to_use, event_count);
|
||||||
|
|
||||||
#ifdef CL_VERSION_1_2
|
#ifdef CL_VERSION_1_2
|
||||||
error = clEnqueueMarkerWithWaitList(queues[queue_to_use], 0, NULL, &event[event_count]);
|
error = clEnqueueMarkerWithWaitList(queues[queue_to_use], 0, NULL,
|
||||||
|
&event[event_count]);
|
||||||
#else
|
#else
|
||||||
error = clEnqueueMarker(queues[queue_to_use], &event[event_count]);
|
error = clEnqueueMarker(queues[queue_to_use], &event[event_count]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick the next queue to run
|
// Pick the next queue to run
|
||||||
@@ -263,26 +330,51 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
queue_to_use = (queue_to_use + 1) % 2;
|
queue_to_use = (queue_to_use + 1) % 2;
|
||||||
|
|
||||||
// Put in a barrier if requested
|
// Put in a barrier if requested
|
||||||
if (test_enqueue_wait_for_events) {
|
if (test_enqueue_wait_for_events)
|
||||||
if (DEBUG_OUT) log_info("clEnqueueBarrierWithWaitList(queues[%d], 1, &event[%d], NULL)\n", queue_to_use, event_count);
|
{
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1, &event[event_count], NULL);
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueBarrierWithWaitList(queues[%d], 1, "
|
||||||
|
"&event[%d], NULL)\n",
|
||||||
|
queue_to_use, event_count);
|
||||||
|
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1,
|
||||||
|
&event[event_count], NULL);
|
||||||
test_error(error, "Unable to queue wait for events");
|
test_error(error, "Unable to queue wait for events");
|
||||||
} else if (test_barrier) {
|
}
|
||||||
if (DEBUG_OUT) log_info("clEnqueueBarrierWithWaitList(queues[%d])\n", queue_to_use);
|
else if (test_barrier)
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL, NULL);
|
{
|
||||||
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueBarrierWithWaitList(queues[%d])\n",
|
||||||
|
queue_to_use);
|
||||||
|
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL,
|
||||||
|
NULL);
|
||||||
test_error(error, "Unable to queue barrier");
|
test_error(error, "Unable to queue barrier");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute Kernel 2
|
// Execute Kernel 2
|
||||||
event_count++;
|
event_count++;
|
||||||
if (use_waitlist | use_marker) {
|
if (use_waitlist | use_marker)
|
||||||
if (DEBUG_OUT) log_info("clEnqueueNDRangeKernel(queues[%d], kernel2[%d], 1, NULL, threads, NULL, 1, &event[%d], &event[%d])\n", queue_to_use, loop_count, event_count-1, event_count);
|
{
|
||||||
error = clEnqueueNDRangeKernel(queues[queue_to_use], kernel2[loop_count], 1, NULL, threads, NULL, 1, &event[event_count-1], &event[event_count]);
|
if (DEBUG_OUT)
|
||||||
} else {
|
log_info("clEnqueueNDRangeKernel(queues[%d], kernel2[%d], 1, "
|
||||||
if (DEBUG_OUT) log_info("clEnqueueNDRangeKernel(queues[%d], kernel2[%d], 1, NULL, threads, NULL, 0, NULL, &event[%d])\n", queue_to_use, loop_count, event_count);
|
"NULL, threads, NULL, 1, &event[%d], &event[%d])\n",
|
||||||
error = clEnqueueNDRangeKernel(queues[queue_to_use], kernel2[loop_count], 1, NULL, threads, NULL, 0, NULL, &event[event_count]);
|
queue_to_use, loop_count, event_count - 1,
|
||||||
|
event_count);
|
||||||
|
error = clEnqueueNDRangeKernel(
|
||||||
|
queues[queue_to_use], kernel2[loop_count], 1, NULL, threads,
|
||||||
|
NULL, 1, &event[event_count - 1], &event[event_count]);
|
||||||
}
|
}
|
||||||
if (error) {
|
else
|
||||||
|
{
|
||||||
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueNDRangeKernel(queues[%d], kernel2[%d], 1, "
|
||||||
|
"NULL, threads, NULL, 0, NULL, &event[%d])\n",
|
||||||
|
queue_to_use, loop_count, event_count);
|
||||||
|
error = clEnqueueNDRangeKernel(
|
||||||
|
queues[queue_to_use], kernel2[loop_count], 1, NULL, threads,
|
||||||
|
NULL, 0, NULL, &event[event_count]);
|
||||||
|
}
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
log_info("\tLoop count %d\n", loop_count);
|
log_info("\tLoop count %d\n", loop_count);
|
||||||
print_error(error, "clEnqueueNDRangeKernel for kernel 2 failed");
|
print_error(error, "clEnqueueNDRangeKernel for kernel 2 failed");
|
||||||
return error;
|
return error;
|
||||||
@@ -291,12 +383,16 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
expected_if_only_queue[queue_to_use]--;
|
expected_if_only_queue[queue_to_use]--;
|
||||||
|
|
||||||
// If we are using a marker, it needs to go in the same queue
|
// If we are using a marker, it needs to go in the same queue
|
||||||
if (use_marker) {
|
if (use_marker)
|
||||||
|
{
|
||||||
event_count++;
|
event_count++;
|
||||||
if (DEBUG_OUT) log_info("clEnqueueMarker(queues[%d], event[%d])\n", queue_to_use, event_count);
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueMarker(queues[%d], event[%d])\n",
|
||||||
|
queue_to_use, event_count);
|
||||||
|
|
||||||
#ifdef CL_VERSION_1_2
|
#ifdef CL_VERSION_1_2
|
||||||
error = clEnqueueMarkerWithWaitList(queues[queue_to_use], 0, NULL, &event[event_count]);
|
error = clEnqueueMarkerWithWaitList(queues[queue_to_use], 0, NULL,
|
||||||
|
&event[event_count]);
|
||||||
#else
|
#else
|
||||||
error = clEnqueueMarker(queues[queue_to_use], &event[event_count]);
|
error = clEnqueueMarker(queues[queue_to_use], &event[event_count]);
|
||||||
#endif
|
#endif
|
||||||
@@ -309,87 +405,137 @@ int test_event_enqueue_wait_for_events_run_test( cl_device_id deviceID, cl_conte
|
|||||||
queue_to_use = (queue_to_use + 1) % 2;
|
queue_to_use = (queue_to_use + 1) % 2;
|
||||||
|
|
||||||
// Put in a barrier if requested
|
// Put in a barrier if requested
|
||||||
if (test_enqueue_wait_for_events) {
|
if (test_enqueue_wait_for_events)
|
||||||
if (DEBUG_OUT) log_info("clEnqueueBarrierWithWaitList(queues[%d], 1, &event[%d], NULL)\n", queue_to_use, event_count);
|
{
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1, &event[event_count], NULL );
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueBarrierWithWaitList(queues[%d], 1, "
|
||||||
|
"&event[%d], NULL)\n",
|
||||||
|
queue_to_use, event_count);
|
||||||
|
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 1,
|
||||||
|
&event[event_count], NULL);
|
||||||
test_error(error, "Unable to queue wait for events");
|
test_error(error, "Unable to queue wait for events");
|
||||||
} else if (test_barrier) {
|
}
|
||||||
if (DEBUG_OUT) log_info("clEnqueueBarrierWithWaitList(queues[%d])\n", queue_to_use);
|
else if (test_barrier)
|
||||||
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL, NULL);
|
{
|
||||||
|
if (DEBUG_OUT)
|
||||||
|
log_info("clEnqueueBarrierWithWaitList(queues[%d])\n",
|
||||||
|
queue_to_use);
|
||||||
|
error = clEnqueueBarrierWithWaitList(queues[queue_to_use], 0, NULL,
|
||||||
|
NULL);
|
||||||
test_error(error, "Unable to queue barrier");
|
test_error(error, "Unable to queue barrier");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now finish up everything
|
// Now finish up everything
|
||||||
if (two_queues) {
|
if (two_queues)
|
||||||
|
{
|
||||||
error = clFlush(queues[1]);
|
error = clFlush(queues[1]);
|
||||||
test_error(error, "clFlush[1] failed");
|
test_error(error, "clFlush[1] failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clEnqueueReadBuffer(queues[0], data, CL_TRUE, 0, TEST_SIZE*sizeof(cl_int), values, 1, &event[event_count], NULL);
|
error = clEnqueueReadBuffer(queues[0], data, CL_TRUE, 0,
|
||||||
|
TEST_SIZE * sizeof(cl_int), values, 1,
|
||||||
|
&event[event_count], NULL);
|
||||||
|
|
||||||
test_error(error, "clEnqueueReadBuffer failed");
|
test_error(error, "clEnqueueReadBuffer failed");
|
||||||
|
|
||||||
failed = 0;
|
failed = 0;
|
||||||
for (i = 0; i < (int)TEST_SIZE; i++)
|
for (i = 0; i < (int)TEST_SIZE; i++)
|
||||||
if (values[i] != expected_value) {
|
if (values[i] != expected_value)
|
||||||
|
{
|
||||||
failed = 1;
|
failed = 1;
|
||||||
log_info("\tvalues[%d] = %d, expected %d (If only queue 1 accessed memory: %d only queue 2 accessed memory: %d)\n",
|
log_info("\tvalues[%d] = %d, expected %d (If only queue 1 accessed "
|
||||||
i, values[i], expected_value, expected_if_only_queue[0], expected_if_only_queue[1]);
|
"memory: %d only queue 2 accessed memory: %d)\n",
|
||||||
|
i, values[i], expected_value, expected_if_only_queue[0],
|
||||||
|
expected_if_only_queue[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(values);
|
free(values);
|
||||||
if (two_devices)
|
if (two_devices) free(two_device_ids);
|
||||||
free(two_device_ids);
|
|
||||||
|
|
||||||
return failed;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements,
|
int test(cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
int two_queues, int two_devices,
|
int num_elements, int two_queues, int two_devices,
|
||||||
int test_enqueue_wait_for_events, int test_barrier, int use_waitlists, int use_marker)
|
int test_enqueue_wait_for_events, int test_barrier, int use_waitlists,
|
||||||
|
int use_marker)
|
||||||
{
|
{
|
||||||
if( !checkDeviceForQueueSupport( deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) )
|
if (!checkDeviceForQueueSupport(deviceID,
|
||||||
|
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE))
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Device does not support out-of-order exec mode; skipping test.\n" );
|
log_info("WARNING: Device does not support out-of-order exec mode; "
|
||||||
|
"skipping test.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Running test for baseline results to determine if out-of-order execution can be detected...\n");
|
log_info("Running test for baseline results to determine if out-of-order "
|
||||||
int baseline_results = test_event_enqueue_wait_for_events_run_test(deviceID, context, queue, num_elements, two_queues, two_devices, 0, 0, 0, 0);
|
"execution can be detected...\n");
|
||||||
if (baseline_results == 0) {
|
int baseline_results = test_event_enqueue_wait_for_events_run_test(
|
||||||
|
deviceID, context, queue, num_elements, two_queues, two_devices, 0, 0,
|
||||||
|
0, 0);
|
||||||
|
if (baseline_results == 0)
|
||||||
|
{
|
||||||
if (test_enqueue_wait_for_events)
|
if (test_enqueue_wait_for_events)
|
||||||
log_info("WARNING: could not detect any out-of-order execution without using clEnqueueBarrierWithWaitList, so this test is not a valid test of out-of-order event dependencies.\n");
|
log_info(
|
||||||
|
"WARNING: could not detect any out-of-order execution without "
|
||||||
|
"using clEnqueueBarrierWithWaitList, so this test is not a "
|
||||||
|
"valid test of out-of-order event dependencies.\n");
|
||||||
if (test_barrier)
|
if (test_barrier)
|
||||||
log_info("WARNING: could not detect any out-of-order execution without using clEnqueueBarrierWithWaitList, so this test is not a valid test of out-of-order event dependencies.\n");
|
log_info(
|
||||||
|
"WARNING: could not detect any out-of-order execution without "
|
||||||
|
"using clEnqueueBarrierWithWaitList, so this test is not a "
|
||||||
|
"valid test of out-of-order event dependencies.\n");
|
||||||
if (use_waitlists)
|
if (use_waitlists)
|
||||||
log_info("WARNING: could not detect any out-of-order execution without using waitlists, so this test is not a valid test of out-of-order event dependencies.\n");
|
log_info("WARNING: could not detect any out-of-order execution "
|
||||||
|
"without using waitlists, so this test is not a valid "
|
||||||
|
"test of out-of-order event dependencies.\n");
|
||||||
if (use_marker)
|
if (use_marker)
|
||||||
log_info("WARNING: could not detect any out-of-order execution without using clEnqueueMarker, so this test is not a valid test of out-of-order event dependencies.\n");
|
log_info("WARNING: could not detect any out-of-order execution "
|
||||||
} else if (baseline_results == 1) {
|
"without using clEnqueueMarker, so this test is not a "
|
||||||
|
"valid test of out-of-order event dependencies.\n");
|
||||||
|
}
|
||||||
|
else if (baseline_results == 1)
|
||||||
|
{
|
||||||
if (test_enqueue_wait_for_events)
|
if (test_enqueue_wait_for_events)
|
||||||
log_info("Detected incorrect execution (possibly out-of-order) without clEnqueueBarrierWithWaitList. Test can be a valid test of out-of-order event dependencies.\n");
|
log_info("Detected incorrect execution (possibly out-of-order) "
|
||||||
|
"without clEnqueueBarrierWithWaitList. Test can be a "
|
||||||
|
"valid test of out-of-order event dependencies.\n");
|
||||||
if (test_barrier)
|
if (test_barrier)
|
||||||
log_info("Detected incorrect execution (possibly out-of-order) without clEnqueueBarrierWithWaitList. Test can be a valid test of out-of-order event dependencies.\n");
|
log_info("Detected incorrect execution (possibly out-of-order) "
|
||||||
|
"without clEnqueueBarrierWithWaitList. Test can be a "
|
||||||
|
"valid test of out-of-order event dependencies.\n");
|
||||||
if (use_waitlists)
|
if (use_waitlists)
|
||||||
log_info("Detected incorrect execution (possibly out-of-order) without waitlists. Test can be a valid test of out-of-order event dependencies.\n");
|
log_info("Detected incorrect execution (possibly out-of-order) "
|
||||||
|
"without waitlists. Test can be a valid test of "
|
||||||
|
"out-of-order event dependencies.\n");
|
||||||
if (use_marker)
|
if (use_marker)
|
||||||
log_info("Detected incorrect execution (possibly out-of-order) without clEnqueueMarker. Test can be a valid test of out-of-order event dependencies.\n");
|
log_info("Detected incorrect execution (possibly out-of-order) "
|
||||||
} else if( baseline_results == -1942 ) {
|
"without clEnqueueMarker. Test can be a valid test of "
|
||||||
|
"out-of-order event dependencies.\n");
|
||||||
|
}
|
||||||
|
else if (baseline_results == -1942)
|
||||||
|
{
|
||||||
// Just ignore and return (out-of-order exec mode not supported)
|
// Just ignore and return (out-of-order exec mode not supported)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print_error(baseline_results, "Baseline run failed");
|
print_error(baseline_results, "Baseline run failed");
|
||||||
return baseline_results;
|
return baseline_results;
|
||||||
}
|
}
|
||||||
log_info("Running test for actual results...\n");
|
log_info("Running test for actual results...\n");
|
||||||
return test_event_enqueue_wait_for_events_run_test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
return test_event_enqueue_wait_for_events_run_test(
|
||||||
|
deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_out_of_order_event_waitlist_single_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_waitlist_single_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 0;
|
int two_queues = 0;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -397,10 +543,15 @@ int test_out_of_order_event_waitlist_single_queue( cl_device_id deviceID, cl_con
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 1;
|
int use_waitlists = 1;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_out_of_order_event_waitlist_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_waitlist_multi_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -408,10 +559,14 @@ int test_out_of_order_event_waitlist_multi_queue( cl_device_id deviceID, cl_cont
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 1;
|
int use_waitlists = 1;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_out_of_order_event_waitlist_multi_queue_multi_device( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_waitlist_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 1;
|
int two_devices = 1;
|
||||||
@@ -419,11 +574,15 @@ int test_out_of_order_event_waitlist_multi_queue_multi_device( cl_device_id devi
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 1;
|
int use_waitlists = 1;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_wait_for_events_single_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_wait_for_events_single_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 0;
|
int two_queues = 0;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -431,10 +590,14 @@ int test_out_of_order_event_enqueue_wait_for_events_single_queue( cl_device_id d
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_wait_for_events_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_wait_for_events_multi_queue(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -442,11 +605,15 @@ int test_out_of_order_event_enqueue_wait_for_events_multi_queue( cl_device_id de
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 1;
|
int two_devices = 1;
|
||||||
@@ -454,13 +621,16 @@ int test_out_of_order_event_enqueue_wait_for_events_multi_queue_multi_device( cl
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int test_out_of_order_event_enqueue_barrier_single_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
int test_out_of_order_event_enqueue_barrier_single_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 0;
|
int two_queues = 0;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -468,11 +638,16 @@ int test_out_of_order_event_enqueue_barrier_single_queue( cl_device_id deviceID,
|
|||||||
int test_barrier = 1;
|
int test_barrier = 1;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 0;
|
int use_marker = 0;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_marker_single_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_marker_single_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 0;
|
int two_queues = 0;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -480,10 +655,15 @@ int test_out_of_order_event_enqueue_marker_single_queue( cl_device_id deviceID,
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 1;
|
int use_marker = 1;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_marker_multi_queue( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_marker_multi_queue(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 0;
|
int two_devices = 0;
|
||||||
@@ -491,11 +671,15 @@ int test_out_of_order_event_enqueue_marker_multi_queue( cl_device_id deviceID, c
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 1;
|
int use_marker = 1;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_out_of_order_event_enqueue_marker_multi_queue_multi_device( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_out_of_order_event_enqueue_marker_multi_queue_multi_device(
|
||||||
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
int two_queues = 1;
|
int two_queues = 1;
|
||||||
int two_devices = 1;
|
int two_devices = 1;
|
||||||
@@ -503,7 +687,7 @@ int test_out_of_order_event_enqueue_marker_multi_queue_multi_device( cl_device_i
|
|||||||
int test_barrier = 0;
|
int test_barrier = 0;
|
||||||
int use_waitlists = 0;
|
int use_waitlists = 0;
|
||||||
int use_marker = 1;
|
int use_marker = 1;
|
||||||
return test(deviceID, context, queue, num_elements, two_queues, two_devices, test_enqueue_wait_for_events, test_barrier, use_waitlists, use_marker);
|
return test(deviceID, context, queue, num_elements, two_queues, two_devices,
|
||||||
|
test_enqueue_wait_for_events, test_barrier, use_waitlists,
|
||||||
|
use_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,20 +31,26 @@ const char *sample_long_test_kernel[] = {
|
|||||||
" dst[tid] = (int)src[tid] * 3;\n"
|
" dst[tid] = (int)src[tid] * 3;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
"}\n" };
|
"}\n"
|
||||||
|
};
|
||||||
|
|
||||||
int create_and_execute_kernel( cl_context inContext, cl_command_queue inQueue, cl_program *outProgram, cl_kernel *outKernel, cl_mem *streams,
|
int create_and_execute_kernel(cl_context inContext, cl_command_queue inQueue,
|
||||||
unsigned int lineCount, const char **lines, const char *kernelName, cl_event *outEvent )
|
cl_program *outProgram, cl_kernel *outKernel,
|
||||||
|
cl_mem *streams, unsigned int lineCount,
|
||||||
|
const char **lines, const char *kernelName,
|
||||||
|
cl_event *outEvent)
|
||||||
{
|
{
|
||||||
size_t threads[1] = { 1000 }, localThreads[1];
|
size_t threads[1] = { 1000 }, localThreads[1];
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if( create_single_kernel_helper( inContext, outProgram, outKernel, lineCount, lines, kernelName ) )
|
if (create_single_kernel_helper(inContext, outProgram, outKernel, lineCount,
|
||||||
|
lines, kernelName))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = get_max_common_work_group_size( inContext, *outKernel, threads[0], &localThreads[0] );
|
error = get_max_common_work_group_size(inContext, *outKernel, threads[0],
|
||||||
|
&localThreads[0]);
|
||||||
test_error(error, "Unable to get work group size to use");
|
test_error(error, "Unable to get work group size to use");
|
||||||
|
|
||||||
streams[0] = clCreateBuffer(inContext, CL_MEM_READ_WRITE,
|
streams[0] = clCreateBuffer(inContext, CL_MEM_READ_WRITE,
|
||||||
@@ -60,7 +66,8 @@ int create_and_execute_kernel( cl_context inContext, cl_command_queue inQueue, c
|
|||||||
error = clSetKernelArg(*outKernel, 1, sizeof(streams[1]), &streams[1]);
|
error = clSetKernelArg(*outKernel, 1, sizeof(streams[1]), &streams[1]);
|
||||||
test_error(error, "Unable to set kernel arguments");
|
test_error(error, "Unable to set kernel arguments");
|
||||||
|
|
||||||
error = clEnqueueNDRangeKernel(inQueue, *outKernel, 1, NULL, threads, localThreads, 0, NULL, outEvent);
|
error = clEnqueueNDRangeKernel(inQueue, *outKernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, outEvent);
|
||||||
test_error(error, "Unable to execute test kernel");
|
test_error(error, "Unable to execute test kernel");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -72,7 +79,10 @@ clKernelWrapper kernel; \
|
|||||||
clMemWrapper streams[2]; \
|
clMemWrapper streams[2]; \
|
||||||
clEventWrapper event; \
|
clEventWrapper event; \
|
||||||
int error; \
|
int error; \
|
||||||
if( create_and_execute_kernel( c, q, &program, &kernel, &streams[0], 1, sample_long_test_kernel, "sample_test", &event ) ) return -1;
|
if (create_and_execute_kernel(c, q, &program, &kernel, &streams[0], 1, \
|
||||||
|
sample_long_test_kernel, "sample_test", \
|
||||||
|
&event)) \
|
||||||
|
return -1;
|
||||||
|
|
||||||
#define FINISH_EVENT(_q) clFinish(_q)
|
#define FINISH_EVENT(_q) clFinish(_q)
|
||||||
|
|
||||||
@@ -92,7 +102,8 @@ const char *IGetStatusString( cl_int status )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Note: tests clGetEventStatus and clReleaseEvent (implicitly) */
|
/* Note: tests clGetEventStatus and clReleaseEvent (implicitly) */
|
||||||
int test_event_get_execute_status( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_get_execute_status(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int status;
|
cl_int status;
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
@@ -101,11 +112,15 @@ int test_event_get_execute_status( cl_device_id deviceID, cl_context context, cl
|
|||||||
error = clWaitForEvents(1, &event);
|
error = clWaitForEvents(1, &event);
|
||||||
test_error(error, "Unable to wait for event");
|
test_error(error, "Unable to wait for event");
|
||||||
|
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
test_error( error, "Calling clGetEventStatus to wait for event completion failed" );
|
sizeof(status), &status, NULL);
|
||||||
|
test_error(error,
|
||||||
|
"Calling clGetEventStatus to wait for event completion failed");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after event complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after event complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +128,8 @@ int test_event_get_execute_status( cl_device_id deviceID, cl_context context, cl
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_get_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_get_info(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
|
|
||||||
@@ -121,49 +137,66 @@ int test_event_get_info( cl_device_id deviceID, cl_context context, cl_command_q
|
|||||||
cl_command_queue otherQueue;
|
cl_command_queue otherQueue;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_QUEUE, sizeof( otherQueue ), &otherQueue, &size );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_QUEUE, sizeof(otherQueue),
|
||||||
|
&otherQueue, &size);
|
||||||
test_error(error, "Unable to get event info!");
|
test_error(error, "Unable to get event info!");
|
||||||
// We can not check if this is the right queue because this is an opaque object.
|
// We can not check if this is the right queue because this is an opaque
|
||||||
|
// object.
|
||||||
if (size != sizeof(queue))
|
if (size != sizeof(queue))
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned command queue size does not validate (expected %d, got %d)\n", (int)sizeof( queue ), (int)size );
|
log_error("ERROR: Returned command queue size does not validate "
|
||||||
|
"(expected %d, got %d)\n",
|
||||||
|
(int)sizeof(queue), (int)size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_command_type type;
|
cl_command_type type;
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_TYPE, sizeof( type ), &type, &size );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_TYPE, sizeof(type), &type,
|
||||||
|
&size);
|
||||||
test_error(error, "Unable to get event info!");
|
test_error(error, "Unable to get event info!");
|
||||||
if (type != CL_COMMAND_NDRANGE_KERNEL)
|
if (type != CL_COMMAND_NDRANGE_KERNEL)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned command type does not validate (expected %d, got %d)\n", (int)CL_COMMAND_NDRANGE_KERNEL, (int)type );
|
log_error("ERROR: Returned command type does not validate (expected "
|
||||||
|
"%d, got %d)\n",
|
||||||
|
(int)CL_COMMAND_NDRANGE_KERNEL, (int)type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (size != sizeof(type))
|
if (size != sizeof(type))
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned command type size does not validate (expected %d, got %d)\n", (int)sizeof( type ), (int)size );
|
log_error("ERROR: Returned command type size does not validate "
|
||||||
|
"(expected %d, got %d)\n",
|
||||||
|
(int)sizeof(type), (int)size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_uint count;
|
cl_uint count;
|
||||||
error = clGetEventInfo( event, CL_EVENT_REFERENCE_COUNT, sizeof( count ), &count, &size );
|
error = clGetEventInfo(event, CL_EVENT_REFERENCE_COUNT, sizeof(count),
|
||||||
|
&count, &size);
|
||||||
test_error(error, "Unable to get event info for CL_EVENT_REFERENCE_COUNT!");
|
test_error(error, "Unable to get event info for CL_EVENT_REFERENCE_COUNT!");
|
||||||
if (size != sizeof(count))
|
if (size != sizeof(count))
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned command type size does not validate (expected %d, got %d)\n", (int)sizeof( type ), (int)size );
|
log_error("ERROR: Returned command type size does not validate "
|
||||||
|
"(expected %d, got %d)\n",
|
||||||
|
(int)sizeof(type), (int)size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_context testCtx;
|
cl_context testCtx;
|
||||||
error = clGetEventInfo( event, CL_EVENT_CONTEXT, sizeof( testCtx ), &testCtx, &size );
|
error = clGetEventInfo(event, CL_EVENT_CONTEXT, sizeof(testCtx), &testCtx,
|
||||||
|
&size);
|
||||||
test_error(error, "Unable to get event context info!");
|
test_error(error, "Unable to get event context info!");
|
||||||
if (size != sizeof(context))
|
if (size != sizeof(context))
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned context size does not validate (expected %d, got %d)\n", (int)sizeof( context ), (int)size );
|
log_error("ERROR: Returned context size does not validate (expected "
|
||||||
|
"%d, got %d)\n",
|
||||||
|
(int)sizeof(context), (int)size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (testCtx != context)
|
if (testCtx != context)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Returned context does not match (expected %p, got %p)\n", (void *)context, (void *)testCtx );
|
log_error(
|
||||||
|
"ERROR: Returned context does not match (expected %p, got %p)\n",
|
||||||
|
(void *)context, (void *)testCtx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +204,8 @@ int test_event_get_info( cl_device_id deviceID, cl_context context, cl_command_q
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_get_write_array_status( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_get_write_array_status(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_mem stream;
|
cl_mem stream;
|
||||||
cl_float testArray[1024 * 32];
|
cl_float testArray[1024 * 32];
|
||||||
@@ -184,18 +218,24 @@ int test_event_get_write_array_status( cl_device_id deviceID, cl_context context
|
|||||||
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
||||||
test_error(error, "Creating test array failed");
|
test_error(error, "Creating test array failed");
|
||||||
|
|
||||||
error = clEnqueueWriteBuffer(queue, stream, CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)testArray, 0, NULL, &event);
|
error = clEnqueueWriteBuffer(queue, stream, CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32,
|
||||||
|
(void *)testArray, 0, NULL, &event);
|
||||||
test_error(error, "Unable to set testing kernel data");
|
test_error(error, "Unable to set testing kernel data");
|
||||||
|
|
||||||
/* Now wait for it to be done */
|
/* Now wait for it to be done */
|
||||||
error = clWaitForEvents(1, &event);
|
error = clWaitForEvents(1, &event);
|
||||||
test_error(error, "Unable to wait for event");
|
test_error(error, "Unable to wait for event");
|
||||||
|
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
test_error( error, "Calling clGetEventStatus to wait for event completion failed" );
|
sizeof(status), &status, NULL);
|
||||||
|
test_error(error,
|
||||||
|
"Calling clGetEventStatus to wait for event completion failed");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array write complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array write complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +246,8 @@ int test_event_get_write_array_status( cl_device_id deviceID, cl_context context
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_get_read_array_status( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_get_read_array_status(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_mem stream;
|
cl_mem stream;
|
||||||
cl_float testArray[1024 * 32];
|
cl_float testArray[1024 * 32];
|
||||||
@@ -219,17 +260,23 @@ int test_event_get_read_array_status( cl_device_id deviceID, cl_context context,
|
|||||||
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
||||||
test_error(error, "Creating test array failed");
|
test_error(error, "Creating test array failed");
|
||||||
|
|
||||||
error = clEnqueueReadBuffer(queue, stream, CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)testArray, 0, NULL, &event);
|
error = clEnqueueReadBuffer(queue, stream, CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32, (void *)testArray,
|
||||||
|
0, NULL, &event);
|
||||||
test_error(error, "Unable to get testing kernel data");
|
test_error(error, "Unable to get testing kernel data");
|
||||||
|
|
||||||
|
|
||||||
/* It should still be running... */
|
/* It should still be running... */
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
|
|
||||||
if( status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED && status != CL_COMPLETE)
|
if (status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED
|
||||||
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus during array read (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"during array read (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,11 +284,15 @@ int test_event_get_read_array_status( cl_device_id deviceID, cl_context context,
|
|||||||
error = clWaitForEvents(1, &event);
|
error = clWaitForEvents(1, &event);
|
||||||
test_error(error, "Unable to wait for event");
|
test_error(error, "Unable to wait for event");
|
||||||
|
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
test_error( error, "Calling clGetEventStatus to wait for event completion failed" );
|
sizeof(status), &status, NULL);
|
||||||
|
test_error(error,
|
||||||
|
"Calling clGetEventStatus to wait for event completion failed");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array read complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array read complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +305,8 @@ int test_event_get_read_array_status( cl_device_id deviceID, cl_context context,
|
|||||||
|
|
||||||
/* clGetEventStatus not implemented yet */
|
/* clGetEventStatus not implemented yet */
|
||||||
|
|
||||||
int test_event_wait_for_execute( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_wait_for_execute(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int status;
|
cl_int status;
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
@@ -264,11 +316,14 @@ int test_event_wait_for_execute( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
test_error(error, "Unable to wait for execute event");
|
test_error(error, "Unable to wait for execute event");
|
||||||
|
|
||||||
/* Make sure it worked */
|
/* Make sure it worked */
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after event complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after event complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +331,8 @@ int test_event_wait_for_execute( cl_device_id deviceID, cl_context context, cl_c
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_wait_for_array( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_wait_for_array(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_mem streams[2];
|
cl_mem streams[2];
|
||||||
cl_float readArray[1024 * 32];
|
cl_float readArray[1024 * 32];
|
||||||
@@ -293,26 +349,38 @@ int test_event_wait_for_array( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
||||||
test_error(error, "Creating test array failed");
|
test_error(error, "Creating test array failed");
|
||||||
|
|
||||||
error = clEnqueueReadBuffer(queue, streams[0], CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)readArray, 0, NULL, &events[0]);
|
error = clEnqueueReadBuffer(queue, streams[0], CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32, (void *)readArray,
|
||||||
|
0, NULL, &events[0]);
|
||||||
test_error(error, "Unable to read testing kernel data");
|
test_error(error, "Unable to read testing kernel data");
|
||||||
|
|
||||||
error = clEnqueueWriteBuffer(queue, streams[1], CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)writeArray, 0, NULL, &events[1]);
|
error = clEnqueueWriteBuffer(queue, streams[1], CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32,
|
||||||
|
(void *)writeArray, 0, NULL, &events[1]);
|
||||||
test_error(error, "Unable to write testing kernel data");
|
test_error(error, "Unable to write testing kernel data");
|
||||||
|
|
||||||
/* Both should still be running */
|
/* Both should still be running */
|
||||||
error = clGetEventInfo( events[0], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if( status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED && status != CL_COMPLETE)
|
if (status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED
|
||||||
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus during array read (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"during array read (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetEventInfo( events[1], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if( status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED && status != CL_COMPLETE)
|
if (status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED
|
||||||
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus during array write (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"during array write (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,19 +389,25 @@ int test_event_wait_for_array( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
test_error(error, "Unable to wait for array events");
|
test_error(error, "Unable to wait for array events");
|
||||||
|
|
||||||
/* Double check status on both */
|
/* Double check status on both */
|
||||||
error = clGetEventInfo( events[0], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array read complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array read complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetEventInfo( events[1], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array write complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array write complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,24 +419,26 @@ int test_event_wait_for_array( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_flush( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_flush(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
int loopCount = 0;
|
int loopCount = 0;
|
||||||
cl_int status;
|
cl_int status;
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
|
|
||||||
/* Now flush. Note that we can't guarantee this actually lets the op finish, but we can guarantee it's no longer queued */
|
/* Now flush. Note that we can't guarantee this actually lets the op finish,
|
||||||
|
* but we can guarantee it's no longer queued */
|
||||||
error = clFlush(queue);
|
error = clFlush(queue);
|
||||||
test_error(error, "Unable to flush events");
|
test_error(error, "Unable to flush events");
|
||||||
|
|
||||||
/* Make sure it worked */
|
/* Make sure it worked */
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
sizeof(status), &status, NULL);
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
|
|
||||||
if( status != CL_QUEUED )
|
if (status != CL_QUEUED) break;
|
||||||
break;
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
sleep(1); // give it some time here.
|
sleep(1); // give it some time here.
|
||||||
@@ -374,15 +450,18 @@ int test_event_flush( cl_device_id deviceID, cl_context context, cl_command_queu
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
CL_QUEUED (command has been enqueued in the command-queue),
|
CL_QUEUED (command has been enqueued in the command-queue),
|
||||||
CL_SUBMITTED (enqueued command has been submitted by the host to the device associated with the command-queue),
|
CL_SUBMITTED (enqueued command has been submitted by the host to the device
|
||||||
CL_RUNNING (device is currently executing this command),
|
associated with the command-queue), CL_RUNNING (device is currently
|
||||||
CL_COMPLETE (the command has completed), or
|
executing this command), CL_COMPLETE (the command has completed), or Error
|
||||||
Error code given by a negative integer value. (command was abnormally terminated – this may be caused by a bad memory access etc.).
|
code given by a negative integer value. (command was abnormally terminated –
|
||||||
|
this may be caused by a bad memory access etc.).
|
||||||
*/
|
*/
|
||||||
if(status != CL_COMPLETE && status != CL_SUBMITTED &&
|
if (status != CL_COMPLETE && status != CL_SUBMITTED && status != CL_RUNNING
|
||||||
status != CL_RUNNING && status != CL_COMPLETE)
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after event flush (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after event flush (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +474,8 @@ Error code given by a negative integer value. (command was abnormally terminated
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_event_finish_execute( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_finish_execute(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int status;
|
cl_int status;
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
@@ -405,11 +485,14 @@ int test_event_finish_execute( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
test_error(error, "Unable to finish all events");
|
test_error(error, "Unable to finish all events");
|
||||||
|
|
||||||
/* Make sure it worked */
|
/* Make sure it worked */
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after event complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after event complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +500,8 @@ int test_event_finish_execute( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_finish_array( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_finish_array(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_mem streams[2];
|
cl_mem streams[2];
|
||||||
cl_float readArray[1024 * 32];
|
cl_float readArray[1024 * 32];
|
||||||
@@ -434,26 +518,38 @@ int test_event_finish_array( cl_device_id deviceID, cl_context context, cl_comma
|
|||||||
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
sizeof(cl_float) * 1024 * 32, NULL, &error);
|
||||||
test_error(error, "Creating test array failed");
|
test_error(error, "Creating test array failed");
|
||||||
|
|
||||||
error = clEnqueueReadBuffer(queue, streams[0], CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)readArray, 0, NULL, &events[0]);
|
error = clEnqueueReadBuffer(queue, streams[0], CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32, (void *)readArray,
|
||||||
|
0, NULL, &events[0]);
|
||||||
test_error(error, "Unable to read testing kernel data");
|
test_error(error, "Unable to read testing kernel data");
|
||||||
|
|
||||||
error = clEnqueueWriteBuffer(queue, streams[1], CL_FALSE, 0, sizeof(cl_float)*1024*32, (void *)writeArray, 0, NULL, &events[1]);
|
error = clEnqueueWriteBuffer(queue, streams[1], CL_FALSE, 0,
|
||||||
|
sizeof(cl_float) * 1024 * 32,
|
||||||
|
(void *)writeArray, 0, NULL, &events[1]);
|
||||||
test_error(error, "Unable to write testing kernel data");
|
test_error(error, "Unable to write testing kernel data");
|
||||||
|
|
||||||
/* Both should still be running */
|
/* Both should still be running */
|
||||||
error = clGetEventInfo( events[0], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if( status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED && status != CL_COMPLETE)
|
if (status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED
|
||||||
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus during array read (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"during array read (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetEventInfo( events[1], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if( status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED && status != CL_COMPLETE)
|
if (status != CL_RUNNING && status != CL_QUEUED && status != CL_SUBMITTED
|
||||||
|
&& status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus during array write (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"during array write (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,19 +558,25 @@ int test_event_finish_array( cl_device_id deviceID, cl_context context, cl_comma
|
|||||||
test_error(error, "Unable to finish all events");
|
test_error(error, "Unable to finish all events");
|
||||||
|
|
||||||
/* Double check status on both */
|
/* Double check status on both */
|
||||||
error = clGetEventInfo( events[0], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array read complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array read complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetEventInfo( events[1], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventStatus didn't work!");
|
test_error(error, "Calling clGetEventStatus didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetErrorStatus after array write complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetErrorStatus "
|
||||||
|
"after array write complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +591,8 @@ int test_event_finish_array( cl_device_id deviceID, cl_context context, cl_comma
|
|||||||
|
|
||||||
#define NUM_EVENT_RUNS 100
|
#define NUM_EVENT_RUNS 100
|
||||||
|
|
||||||
int test_event_release_before_done( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_release_before_done(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
// Create a kernel to run
|
// Create a kernel to run
|
||||||
clProgramWrapper program;
|
clProgramWrapper program;
|
||||||
@@ -501,17 +604,20 @@ int test_event_release_before_done( cl_device_id deviceID, cl_context context, c
|
|||||||
int error, i;
|
int error, i;
|
||||||
|
|
||||||
// Create a kernel
|
// Create a kernel
|
||||||
if( create_single_kernel_helper( context, &program, &kernel[0], 1, sample_long_test_kernel, "sample_test" ) )
|
if (create_single_kernel_helper(context, &program, &kernel[0], 1,
|
||||||
|
sample_long_test_kernel, "sample_test"))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 1; i < NUM_EVENT_RUNS; i++ ) {
|
for (i = 1; i < NUM_EVENT_RUNS; i++)
|
||||||
|
{
|
||||||
kernel[i] = clCreateKernel(program, "sample_test", &error);
|
kernel[i] = clCreateKernel(program, "sample_test", &error);
|
||||||
test_error(error, "Unable to create kernel");
|
test_error(error, "Unable to create kernel");
|
||||||
}
|
}
|
||||||
|
|
||||||
error = get_max_common_work_group_size( context, kernel[0], 1024, &threads[0] );
|
error =
|
||||||
|
get_max_common_work_group_size(context, kernel[0], 1024, &threads[0]);
|
||||||
test_error(error, "Unable to get work group size to use");
|
test_error(error, "Unable to get work group size to use");
|
||||||
|
|
||||||
// Create a set of streams to use as arguments
|
// Create a set of streams to use as arguments
|
||||||
@@ -530,14 +636,16 @@ int test_event_release_before_done( cl_device_id deviceID, cl_context context, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the kernels one by one, hopefully making sure they won't be done by the time we get to the end
|
// Execute the kernels one by one, hopefully making sure they won't be done
|
||||||
|
// by the time we get to the end
|
||||||
for (i = 0; i < NUM_EVENT_RUNS; i++)
|
for (i = 0; i < NUM_EVENT_RUNS; i++)
|
||||||
{
|
{
|
||||||
error = clSetKernelArg(kernel[i], 0, sizeof(cl_mem), &streams[i][0]);
|
error = clSetKernelArg(kernel[i], 0, sizeof(cl_mem), &streams[i][0]);
|
||||||
error |= clSetKernelArg(kernel[i], 1, sizeof(cl_mem), &streams[i][1]);
|
error |= clSetKernelArg(kernel[i], 1, sizeof(cl_mem), &streams[i][1]);
|
||||||
test_error(error, "Unable to set kernel arguments");
|
test_error(error, "Unable to set kernel arguments");
|
||||||
|
|
||||||
error = clEnqueueNDRangeKernel( queue, kernel[i], 1, NULL, threads, threads, 0, NULL, &events[i]);
|
error = clEnqueueNDRangeKernel(queue, kernel[i], 1, NULL, threads,
|
||||||
|
threads, 0, NULL, &events[i]);
|
||||||
test_error(error, "Unable to execute test kernel");
|
test_error(error, "Unable to execute test kernel");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,7 +656,9 @@ int test_event_release_before_done( cl_device_id deviceID, cl_context context, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get status on the last one, then free it
|
// Get status on the last one, then free it
|
||||||
error = clGetEventInfo( events[ NUM_EVENT_RUNS - 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(events[NUM_EVENT_RUNS - 1],
|
||||||
|
CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(status),
|
||||||
|
&status, NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
|
|
||||||
clReleaseEvent(events[NUM_EVENT_RUNS - 1]);
|
clReleaseEvent(events[NUM_EVENT_RUNS - 1]);
|
||||||
@@ -556,11 +666,14 @@ int test_event_release_before_done( cl_device_id deviceID, cl_context context, c
|
|||||||
// Was the status still-running?
|
// Was the status still-running?
|
||||||
if (status == CL_COMPLETE)
|
if (status == CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Events completed before they could be released, so test is a null-op. Increase workload and try again." );
|
log_info("WARNING: Events completed before they could be released, so "
|
||||||
|
"test is a null-op. Increase workload and try again.");
|
||||||
}
|
}
|
||||||
else if( status == CL_RUNNING || status == CL_QUEUED || status == CL_SUBMITTED )
|
else if (status == CL_RUNNING || status == CL_QUEUED
|
||||||
|
|| status == CL_SUBMITTED)
|
||||||
{
|
{
|
||||||
log_info( "Note: Event status was running or queued when released, so test was good.\n" );
|
log_info("Note: Event status was running or queued when released, so "
|
||||||
|
"test was good.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't crash by now, the test succeeded
|
// If we didn't crash by now, the test succeeded
|
||||||
@@ -569,12 +682,14 @@ int test_event_release_before_done( cl_device_id deviceID, cl_context context, c
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_enqueue_marker( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_enqueue_marker(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int status;
|
cl_int status;
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
|
|
||||||
/* Now we queue a marker and wait for that, which--since it queues afterwards--should guarantee the execute finishes too */
|
/* Now we queue a marker and wait for that, which--since it queues
|
||||||
|
* afterwards--should guarantee the execute finishes too */
|
||||||
clEventWrapper markerEvent;
|
clEventWrapper markerEvent;
|
||||||
// error = clEnqueueMarker( queue, &markerEvent );
|
// error = clEnqueueMarker( queue, &markerEvent );
|
||||||
|
|
||||||
@@ -589,11 +704,14 @@ int test_event_enqueue_marker( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
test_error(error, "Unable to wait for marker event");
|
test_error(error, "Unable to wait for marker event");
|
||||||
|
|
||||||
/* Check the status of the first event */
|
/* Check the status of the first event */
|
||||||
error = clGetEventInfo( event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status ), &status, NULL );
|
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status), &status, NULL);
|
||||||
test_error(error, "Calling clGetEventInfo didn't work!");
|
test_error(error, "Calling clGetEventInfo didn't work!");
|
||||||
if (status != CL_COMPLETE)
|
if (status != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Incorrect status returned from clGetEventInfo after event complete (%d:%s)\n", status, IGetStatusString( status ) );
|
log_error("ERROR: Incorrect status returned from clGetEventInfo after "
|
||||||
|
"event complete (%d:%s)\n",
|
||||||
|
status, IGetStatusString(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,37 +720,47 @@ int test_event_enqueue_marker( cl_device_id deviceID, cl_context context, cl_com
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CL_VERSION_1_2
|
#ifdef CL_VERSION_1_2
|
||||||
int test_event_enqueue_marker_with_event_list( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_enqueue_marker_with_event_list(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
cl_event event_list[3] = { NULL, NULL, NULL };
|
cl_event event_list[3] = { NULL, NULL, NULL };
|
||||||
|
|
||||||
size_t threads[1] = { 10 }, localThreads[1] = { 1 };
|
size_t threads[1] = { 10 }, localThreads[1] = { 1 };
|
||||||
cl_uint event_count = 2;
|
cl_uint event_count = 2;
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[0]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[0]);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList 1 ");
|
test_error(error, " clEnqueueMarkerWithWaitList 1 ");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[1]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[1]);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList 2");
|
test_error(error, " clEnqueueMarkerWithWaitList 2");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, NULL);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, NULL);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList 3");
|
test_error(error, " clEnqueueMarkerWithWaitList 3");
|
||||||
|
|
||||||
// test the case event returned
|
// test the case event returned
|
||||||
error =clEnqueueMarkerWithWaitList(queue, event_count, event_list, &event_list[2]);
|
error = clEnqueueMarkerWithWaitList(queue, event_count, event_list,
|
||||||
|
&event_list[2]);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList ");
|
test_error(error, " clEnqueueMarkerWithWaitList ");
|
||||||
|
|
||||||
error = clReleaseEvent(event_list[0]);
|
error = clReleaseEvent(event_list[0]);
|
||||||
error |= clReleaseEvent(event_list[1]);
|
error |= clReleaseEvent(event_list[1]);
|
||||||
test_error(error, "clReleaseEvent");
|
test_error(error, "clReleaseEvent");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[0]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[0]);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList 1 -1 ");
|
test_error(error, " clEnqueueMarkerWithWaitList 1 -1 ");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[1]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[1]);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList 2-2");
|
test_error(error, " clEnqueueMarkerWithWaitList 2-2");
|
||||||
|
|
||||||
// test the case event =NULL, caused [CL_INVALID_VALUE] : OpenCL Error : clEnqueueMarkerWithWaitList failed: event is a NULL value
|
// test the case event =NULL, caused [CL_INVALID_VALUE] : OpenCL Error :
|
||||||
|
// clEnqueueMarkerWithWaitList failed: event is a NULL value
|
||||||
error = clEnqueueMarkerWithWaitList(queue, event_count, event_list, NULL);
|
error = clEnqueueMarkerWithWaitList(queue, event_count, event_list, NULL);
|
||||||
test_error(error, " clEnqueueMarkerWithWaitList ");
|
test_error(error, " clEnqueueMarkerWithWaitList ");
|
||||||
|
|
||||||
@@ -645,36 +773,46 @@ int test_event_enqueue_marker_with_event_list( cl_device_id deviceID, cl_context
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_event_enqueue_barrier_with_event_list( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
int test_event_enqueue_barrier_with_event_list(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements)
|
||||||
{
|
{
|
||||||
SETUP_EVENT(context, queue);
|
SETUP_EVENT(context, queue);
|
||||||
cl_event event_list[3] = { NULL, NULL, NULL };
|
cl_event event_list[3] = { NULL, NULL, NULL };
|
||||||
|
|
||||||
size_t threads[1] = { 10 }, localThreads[1] = { 1 };
|
size_t threads[1] = { 10 }, localThreads[1] = { 1 };
|
||||||
cl_uint event_count = 2;
|
cl_uint event_count = 2;
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[0]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[0]);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList 1 ");
|
test_error(error, " clEnqueueBarrierWithWaitList 1 ");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[1]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[1]);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList 2");
|
test_error(error, " clEnqueueBarrierWithWaitList 2");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, NULL);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, NULL);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList 20");
|
test_error(error, " clEnqueueBarrierWithWaitList 20");
|
||||||
|
|
||||||
// test the case event returned
|
// test the case event returned
|
||||||
error =clEnqueueBarrierWithWaitList(queue, event_count, event_list, &event_list[2]);
|
error = clEnqueueBarrierWithWaitList(queue, event_count, event_list,
|
||||||
|
&event_list[2]);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList ");
|
test_error(error, " clEnqueueBarrierWithWaitList ");
|
||||||
|
|
||||||
clReleaseEvent(event_list[0]);
|
clReleaseEvent(event_list[0]);
|
||||||
clReleaseEvent(event_list[1]);
|
clReleaseEvent(event_list[1]);
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[0]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[0]);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList 1 ");
|
test_error(error, " clEnqueueBarrierWithWaitList 1 ");
|
||||||
|
|
||||||
error= clEnqueueNDRangeKernel( queue,kernel,1,NULL, threads, localThreads, 0, NULL, &event_list[1]);
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
|
localThreads, 0, NULL, &event_list[1]);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList 2");
|
test_error(error, " clEnqueueBarrierWithWaitList 2");
|
||||||
|
|
||||||
// test the case event =NULL, caused [CL_INVALID_VALUE] : OpenCL Error : clEnqueueMarkerWithWaitList failed: event is a NULL value
|
// test the case event =NULL, caused [CL_INVALID_VALUE] : OpenCL Error :
|
||||||
|
// clEnqueueMarkerWithWaitList failed: event is a NULL value
|
||||||
error = clEnqueueBarrierWithWaitList(queue, event_count, event_list, NULL);
|
error = clEnqueueBarrierWithWaitList(queue, event_count, event_list, NULL);
|
||||||
test_error(error, " clEnqueueBarrierWithWaitList ");
|
test_error(error, " clEnqueueBarrierWithWaitList ");
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define CL_EXIT_ERROR(cmd, ...) \
|
#define CL_EXIT_ERROR(cmd, ...) \
|
||||||
{ \
|
{ \
|
||||||
if ((cmd) != CL_SUCCESS) { \
|
if ((cmd) != CL_SUCCESS) \
|
||||||
|
{ \
|
||||||
log_error("CL ERROR: %s %u: ", __FILE__, __LINE__); \
|
log_error("CL ERROR: %s %u: ", __FILE__, __LINE__); \
|
||||||
log_error(##__VA_ARGS__); \
|
log_error(##__VA_ARGS__); \
|
||||||
log_error("\n"); \
|
log_error("\n"); \
|
||||||
@@ -41,7 +42,8 @@ return -1;\
|
|||||||
#else
|
#else
|
||||||
#define CL_EXIT_ERROR(cmd, format, ...) \
|
#define CL_EXIT_ERROR(cmd, format, ...) \
|
||||||
{ \
|
{ \
|
||||||
if ((cmd) != CL_SUCCESS) { \
|
if ((cmd) != CL_SUCCESS) \
|
||||||
|
{ \
|
||||||
log_error("CL ERROR: %s %u: ", __FILE__, __LINE__); \
|
log_error("CL ERROR: %s %u: ", __FILE__, __LINE__); \
|
||||||
log_error(format, ##__VA_ARGS__); \
|
log_error(format, ##__VA_ARGS__); \
|
||||||
log_error("\n"); \
|
log_error("\n"); \
|
||||||
@@ -52,17 +54,26 @@ return -1;\
|
|||||||
|
|
||||||
#define CL_EXIT_BUILD_ERROR(cmd, program, format, ...) \
|
#define CL_EXIT_BUILD_ERROR(cmd, program, format, ...) \
|
||||||
{ \
|
{ \
|
||||||
if ((cmd) != CL_SUCCESS) { \
|
if ((cmd) != CL_SUCCESS) \
|
||||||
|
{ \
|
||||||
cl_uint num_devices_; \
|
cl_uint num_devices_; \
|
||||||
clGetProgramInfo(program,CL_PROGRAM_NUM_DEVICES,sizeof(num_devices_),&num_devices_,NULL);\
|
clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES, \
|
||||||
|
sizeof(num_devices_), &num_devices_, NULL); \
|
||||||
cl_device_id *device_list; \
|
cl_device_id *device_list; \
|
||||||
device_list=(cl_device_id *)malloc(num_devices_*sizeof(cl_device_id));\
|
device_list = \
|
||||||
clGetProgramInfo(program,CL_PROGRAM_DEVICES,num_devices_*sizeof(cl_device_id),device_list,NULL);\
|
(cl_device_id *)malloc(num_devices_ * sizeof(cl_device_id)); \
|
||||||
for (unsigned i=0;i<num_devices_;++i) {\
|
clGetProgramInfo(program, CL_PROGRAM_DEVICES, \
|
||||||
|
num_devices_ * sizeof(cl_device_id), device_list, \
|
||||||
|
NULL); \
|
||||||
|
for (unsigned i = 0; i < num_devices_; ++i) \
|
||||||
|
{ \
|
||||||
size_t len; \
|
size_t len; \
|
||||||
char buffer[2048]; \
|
char buffer[2048]; \
|
||||||
clGetProgramBuildInfo(program,device_list[i],CL_PROGRAM_BUILD_LOG,sizeof(buffer),buffer,&len);\
|
clGetProgramBuildInfo(program, device_list[i], \
|
||||||
log_error("DEVICE %u CL BUILD ERROR: %s(%u): ",i,__FILE__,__LINE__);\
|
CL_PROGRAM_BUILD_LOG, sizeof(buffer), \
|
||||||
|
buffer, &len); \
|
||||||
|
log_error("DEVICE %u CL BUILD ERROR: %s(%u): ", i, __FILE__, \
|
||||||
|
__LINE__); \
|
||||||
log_error(format, ##__VA_ARGS__); \
|
log_error(format, ##__VA_ARGS__); \
|
||||||
log_error("\n"); \
|
log_error("\n"); \
|
||||||
} \
|
} \
|
||||||
@@ -71,15 +82,17 @@ return -1;\
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* src[] = {
|
const char *src[] = { "__kernel void simple_task(__global float* output) {\n"
|
||||||
"__kernel void simple_task(__global float* output) {\n"
|
|
||||||
" output[0] += 1;\n"
|
" output[0] += 1;\n"
|
||||||
"}\n"
|
"}\n" };
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MaxDevices = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { MaxDevices = 8 };
|
int test_userevents(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
cl_int err;
|
cl_int err;
|
||||||
@@ -90,74 +103,117 @@ int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
// Test event properties.
|
// Test event properties.
|
||||||
cl_int s;
|
cl_int s;
|
||||||
size_t sizeofs;
|
size_t sizeofs;
|
||||||
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof s, &s, &sizeofs),"clGetEventInfo failed");
|
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
CL_EXIT_ERROR((sizeof s == sizeofs) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong size for CL_EVENT_COMMAND_EXECUTION_STATUS");
|
sizeof s, &s, &sizeofs),
|
||||||
CL_EXIT_ERROR((s == CL_SUBMITTED) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong value for CL_EVENT_COMMAND_EXECUTION_STATUS");
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR((sizeof s == sizeofs) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong size for "
|
||||||
|
"CL_EVENT_COMMAND_EXECUTION_STATUS");
|
||||||
|
CL_EXIT_ERROR((s == CL_SUBMITTED) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong value for "
|
||||||
|
"CL_EVENT_COMMAND_EXECUTION_STATUS");
|
||||||
|
|
||||||
cl_command_type t;
|
cl_command_type t;
|
||||||
size_t sizeoft;
|
size_t sizeoft;
|
||||||
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_COMMAND_TYPE, sizeof t, &t, &sizeoft),"clGetEventInfo failed");
|
CL_EXIT_ERROR(
|
||||||
CL_EXIT_ERROR((sizeof t == sizeoft) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong size for CL_EVENT_COMMAND_TYPE");
|
clGetEventInfo(u1, CL_EVENT_COMMAND_TYPE, sizeof t, &t, &sizeoft),
|
||||||
CL_EXIT_ERROR((t == CL_COMMAND_USER) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong value for CL_EVENT_COMMAND_TYPE");
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(sizeof t == sizeoft) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong size for CL_EVENT_COMMAND_TYPE");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(t == CL_COMMAND_USER) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong value for CL_EVENT_COMMAND_TYPE");
|
||||||
|
|
||||||
cl_command_queue q;
|
cl_command_queue q;
|
||||||
size_t sizeofq;
|
size_t sizeofq;
|
||||||
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_COMMAND_QUEUE, sizeof q, &q, &sizeofq),"clGetEventInfo failed");
|
CL_EXIT_ERROR(
|
||||||
CL_EXIT_ERROR((sizeof q == sizeofq) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong size for CL_EVENT_COMMAND_QUEUE");
|
clGetEventInfo(u1, CL_EVENT_COMMAND_QUEUE, sizeof q, &q, &sizeofq),
|
||||||
CL_EXIT_ERROR((q == NULL) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong value for CL_EVENT_COMMAND_QUEUE");
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(sizeof q == sizeofq) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong size for CL_EVENT_COMMAND_QUEUE");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(q == NULL) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong value for CL_EVENT_COMMAND_QUEUE");
|
||||||
|
|
||||||
cl_context c;
|
cl_context c;
|
||||||
size_t sizeofc;
|
size_t sizeofc;
|
||||||
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_CONTEXT, sizeof c, &c, &sizeofc),"clGetEventInfo failed");
|
CL_EXIT_ERROR(clGetEventInfo(u1, CL_EVENT_CONTEXT, sizeof c, &c, &sizeofc),
|
||||||
CL_EXIT_ERROR((sizeof c == sizeofc) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong size for CL_EVENT_CONTEXT");
|
"clGetEventInfo failed");
|
||||||
CL_EXIT_ERROR((c == context) ? CL_SUCCESS : -1,"clGetEventInfo returned wrong value for CL_EVENT_CONTEXT");
|
CL_EXIT_ERROR((sizeof c == sizeofc) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong size for CL_EVENT_CONTEXT");
|
||||||
|
CL_EXIT_ERROR((c == context) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo returned wrong value for CL_EVENT_CONTEXT");
|
||||||
|
|
||||||
cl_ulong p;
|
cl_ulong p;
|
||||||
err = clGetEventProfilingInfo(u1,CL_PROFILING_COMMAND_QUEUED,sizeof p,&p,0);
|
err = clGetEventProfilingInfo(u1, CL_PROFILING_COMMAND_QUEUED, sizeof p, &p,
|
||||||
CL_EXIT_ERROR((err != CL_SUCCESS) ? CL_SUCCESS : -1,"clGetEventProfilingInfo returned wrong error.");
|
0);
|
||||||
|
CL_EXIT_ERROR((err != CL_SUCCESS) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventProfilingInfo returned wrong error.");
|
||||||
|
|
||||||
// Test semantics.
|
// Test semantics.
|
||||||
cl_program program;
|
cl_program program;
|
||||||
err = create_single_kernel_helper_create_program(context, &program, 1, src);
|
err = create_single_kernel_helper_create_program(context, &program, 1, src);
|
||||||
CL_EXIT_ERROR(err, "clCreateProgramWithSource failed");
|
CL_EXIT_ERROR(err, "clCreateProgramWithSource failed");
|
||||||
|
|
||||||
CL_EXIT_BUILD_ERROR(clBuildProgram(program,0,NULL,"",NULL,NULL),program,"Building program from inline src:\t%s",src[0]);
|
CL_EXIT_BUILD_ERROR(clBuildProgram(program, 0, NULL, "", NULL, NULL),
|
||||||
|
program, "Building program from inline src:\t%s",
|
||||||
|
src[0]);
|
||||||
|
|
||||||
cl_kernel k0 = clCreateKernel(program, "simple_task", &err);
|
cl_kernel k0 = clCreateKernel(program, "simple_task", &err);
|
||||||
CL_EXIT_ERROR(err, "clCreateKernel failed");
|
CL_EXIT_ERROR(err, "clCreateKernel failed");
|
||||||
|
|
||||||
float buffer[1];
|
float buffer[1];
|
||||||
cl_mem output = clCreateBuffer(context,CL_MEM_USE_HOST_PTR,sizeof buffer, buffer, &err);
|
cl_mem output = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof buffer,
|
||||||
|
buffer, &err);
|
||||||
CL_EXIT_ERROR(err, "clCreateBuffer failed.");
|
CL_EXIT_ERROR(err, "clCreateBuffer failed.");
|
||||||
|
|
||||||
CL_EXIT_ERROR(clSetKernelArg(k0,0,sizeof(output),&output),"clSetKernelArg failed");
|
CL_EXIT_ERROR(clSetKernelArg(k0, 0, sizeof(output), &output),
|
||||||
|
"clSetKernelArg failed");
|
||||||
|
|
||||||
|
|
||||||
// Successful case. //////////////////////////////////////////////////////////////////////////////////////
|
// Successful case.
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
{
|
||||||
cl_event e[4];
|
cl_event e[4];
|
||||||
cl_uint N = sizeof e / sizeof(cl_event);
|
cl_uint N = sizeof e / sizeof(cl_event);
|
||||||
|
|
||||||
log_info("Enqueuing tasks\n");
|
log_info("Enqueuing tasks\n");
|
||||||
for (cl_uint i = 0; i != N; ++i)
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clEnqueueTask(queue,k0,1,&u1,&e[i]),"clEnqueueTaskFailed");
|
CL_EXIT_ERROR(clEnqueueTask(queue, k0, 1, &u1, &e[i]),
|
||||||
|
"clEnqueueTaskFailed");
|
||||||
|
|
||||||
log_info("Checking task status before setting user event status\n");
|
log_info("Checking task status before setting user event status\n");
|
||||||
for (cl_uint i = 0; i != N; ++i) {
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clGetEventInfo(e[i],CL_EVENT_COMMAND_EXECUTION_STATUS,sizeof s,&s,0),"clGetEventInfo failed");
|
{
|
||||||
CL_EXIT_ERROR((s >= CL_SUBMITTED) ? CL_SUCCESS : -1,"clGetEventInfo %u returned wrong status before user event",i);
|
CL_EXIT_ERROR(clGetEventInfo(e[i],
|
||||||
|
CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof s, &s, 0),
|
||||||
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(s >= CL_SUBMITTED) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo %u returned wrong status before user event", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Setting user event status to complete\n");
|
log_info("Setting user event status to complete\n");
|
||||||
CL_EXIT_ERROR(clSetUserEventStatus(u1,CL_COMPLETE),"clSetUserEventStatus failed");
|
CL_EXIT_ERROR(clSetUserEventStatus(u1, CL_COMPLETE),
|
||||||
|
"clSetUserEventStatus failed");
|
||||||
|
|
||||||
log_info("Waiting for tasks to finish executing\n");
|
log_info("Waiting for tasks to finish executing\n");
|
||||||
CL_EXIT_ERROR(clWaitForEvents(1, &e[N - 1]), "clWaitForEvent failed");
|
CL_EXIT_ERROR(clWaitForEvents(1, &e[N - 1]), "clWaitForEvent failed");
|
||||||
|
|
||||||
log_info("Checking task status after setting user event status\n");
|
log_info("Checking task status after setting user event status\n");
|
||||||
for (cl_uint i = 0; i != N; ++i) {
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clGetEventInfo(e[i],CL_EVENT_COMMAND_EXECUTION_STATUS,sizeof s,&s,0),"clGetEventInfo failed");
|
{
|
||||||
CL_EXIT_ERROR((s != CL_QUEUED) ? CL_SUCCESS : -1,"clGetEventInfo %u returned wrong status %04x after successful user event",i,s);
|
CL_EXIT_ERROR(clGetEventInfo(e[i],
|
||||||
|
CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof s, &s, 0),
|
||||||
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR((s != CL_QUEUED) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo %u returned wrong status %04x after "
|
||||||
|
"successful user event",
|
||||||
|
i, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
CL_EXIT_ERROR(clReleaseEvent(u1), "clReleaseEvent failed");
|
CL_EXIT_ERROR(clReleaseEvent(u1), "clReleaseEvent failed");
|
||||||
@@ -166,10 +222,10 @@ int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
CL_EXIT_ERROR(clReleaseEvent(e[i]), "clReleaseEvent failed");
|
CL_EXIT_ERROR(clReleaseEvent(e[i]), "clReleaseEvent failed");
|
||||||
|
|
||||||
log_info("Successful user event case passed.\n");
|
log_info("Successful user event case passed.\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test unsuccessful user event case. ///////////////////////////////////////////////////////////////////
|
// Test unsuccessful user event case.
|
||||||
|
// ///////////////////////////////////////////////////////////////////
|
||||||
{
|
{
|
||||||
cl_event u2 = clCreateUserEvent(context, &err);
|
cl_event u2 = clCreateUserEvent(context, &err);
|
||||||
CL_EXIT_ERROR(err, "clCreateUserEvent failed");
|
CL_EXIT_ERROR(err, "clCreateUserEvent failed");
|
||||||
@@ -179,24 +235,42 @@ int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
|
|
||||||
log_info("Enqueuing tasks\n");
|
log_info("Enqueuing tasks\n");
|
||||||
for (cl_uint i = 0; i != N; ++i)
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clEnqueueTask(queue,k0,1,&u2,&e[i]),"clEnqueueTaskFailed");
|
CL_EXIT_ERROR(clEnqueueTask(queue, k0, 1, &u2, &e[i]),
|
||||||
|
"clEnqueueTaskFailed");
|
||||||
|
|
||||||
log_info("Checking task status before setting user event status\n");
|
log_info("Checking task status before setting user event status\n");
|
||||||
for (cl_uint i = 0; i != N; ++i) {
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clGetEventInfo(e[i],CL_EVENT_COMMAND_EXECUTION_STATUS,sizeof s,&s,0),"clGetEventInfo failed");
|
{
|
||||||
CL_EXIT_ERROR((s == CL_QUEUED || s == CL_SUBMITTED) ? CL_SUCCESS : -1,"clGetEventInfo %u returned wrong status %d before user event",i, (int) s);
|
CL_EXIT_ERROR(clGetEventInfo(e[i],
|
||||||
|
CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof s, &s, 0),
|
||||||
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR(
|
||||||
|
(s == CL_QUEUED || s == CL_SUBMITTED) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo %u returned wrong status %d before user event",
|
||||||
|
i, (int)s);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Setting user event status to unsuccessful result\n");
|
log_info("Setting user event status to unsuccessful result\n");
|
||||||
CL_EXIT_ERROR(clSetUserEventStatus(u2,-1),"clSetUserEventStatus failed");
|
CL_EXIT_ERROR(clSetUserEventStatus(u2, -1),
|
||||||
|
"clSetUserEventStatus failed");
|
||||||
|
|
||||||
log_info("Waiting for tasks to finish executing\n");
|
log_info("Waiting for tasks to finish executing\n");
|
||||||
CL_EXIT_ERROR((clWaitForEvents( N, &e[0] )!=CL_SUCCESS) ? CL_SUCCESS : -1,"clWaitForEvent succeeded when it should have failed");
|
CL_EXIT_ERROR((clWaitForEvents(N, &e[0]) != CL_SUCCESS) ? CL_SUCCESS
|
||||||
|
: -1,
|
||||||
|
"clWaitForEvent succeeded when it should have failed");
|
||||||
|
|
||||||
log_info("Checking task status after setting user event status\n");
|
log_info("Checking task status after setting user event status\n");
|
||||||
for (cl_uint i = 0; i != N; ++i) {
|
for (cl_uint i = 0; i != N; ++i)
|
||||||
CL_EXIT_ERROR(clGetEventInfo(e[i],CL_EVENT_COMMAND_EXECUTION_STATUS,sizeof s,&s,0),"clGetEventInfo failed");
|
{
|
||||||
CL_EXIT_ERROR((s != CL_QUEUED) ? CL_SUCCESS : -1,"clGetEventInfo %u returned wrong status %04x after unsuccessful user event",i,s);
|
CL_EXIT_ERROR(clGetEventInfo(e[i],
|
||||||
|
CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof s, &s, 0),
|
||||||
|
"clGetEventInfo failed");
|
||||||
|
CL_EXIT_ERROR((s != CL_QUEUED) ? CL_SUCCESS : -1,
|
||||||
|
"clGetEventInfo %u returned wrong status %04x after "
|
||||||
|
"unsuccessful user event",
|
||||||
|
i, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
CL_EXIT_ERROR(clReleaseEvent(u2), "clReleaseEvent failed");
|
CL_EXIT_ERROR(clReleaseEvent(u2), "clReleaseEvent failed");
|
||||||
@@ -212,6 +286,4 @@ int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
clReleaseMemObject(output);
|
clReleaseMemObject(output);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ void trigger_user_event(cl_event *event)
|
|||||||
clSetUserEventStatus(*event, CL_COMPLETE);
|
clSetUserEventStatus(*event, CL_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_userevents_multithreaded( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
int test_userevents_multithreaded(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
|
|
||||||
@@ -70,4 +71,3 @@ int test_userevents_multithreaded( cl_device_id deviceID, cl_context context, cl
|
|||||||
// If we got here without error, we're good
|
// If we got here without error, we're good
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ extern const char *IGetStatusString( cl_int status );
|
|||||||
|
|
||||||
#define PRINT_OPS 0
|
#define PRINT_OPS 0
|
||||||
|
|
||||||
int test_waitlist( cl_device_id device, cl_context context, cl_command_queue queue, Action *actionToTest, bool multiple )
|
int test_waitlist(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, Action *actionToTest, bool multiple)
|
||||||
{
|
{
|
||||||
NDRangeKernelAction actions[2];
|
NDRangeKernelAction actions[2];
|
||||||
clEventWrapper events[3];
|
clEventWrapper events[3];
|
||||||
@@ -67,11 +68,13 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
if (multiple)
|
if (multiple)
|
||||||
{
|
{
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
||||||
error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[1]), &status[1], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
}
|
}
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
||||||
error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[0]), &status[0], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
|
|
||||||
log_info("\t\tEvent status after starting reference events: reference "
|
log_info("\t\tEvent status after starting reference events: reference "
|
||||||
@@ -81,26 +84,32 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
|
|
||||||
if ((status[0] == CL_COMPLETE) || (multiple && status[1] == CL_COMPLETE))
|
if ((status[0] == CL_COMPLETE) || (multiple && status[1] == CL_COMPLETE))
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Reference event(s) already completed before we could execute test event! Possible that the reference event blocked (implicitly passing)\n" );
|
log_info("WARNING: Reference event(s) already completed before we "
|
||||||
|
"could execute test event! Possible that the reference event "
|
||||||
|
"blocked (implicitly passing)\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRINT_OPS) log_info("\tExecuting action to test...\n");
|
if (PRINT_OPS) log_info("\tExecuting action to test...\n");
|
||||||
error = actionToTest->Execute( queue, ( multiple ) ? 2 : 1, &events[ 0 ], &events[ 2 ] );
|
error = actionToTest->Execute(queue, (multiple) ? 2 : 1, &events[0],
|
||||||
|
&events[2]);
|
||||||
test_error(error, "Unable to execute test event");
|
test_error(error, "Unable to execute test event");
|
||||||
|
|
||||||
// Hopefully, the first event is still running
|
// Hopefully, the first event is still running
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
|
||||||
error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
|
error = clGetEventInfo(events[2], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[2]), &status[2], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
if (multiple)
|
if (multiple)
|
||||||
{
|
{
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
||||||
error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[1]), &status[1], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
}
|
}
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
||||||
error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[0]), &status[0], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
|
|
||||||
log_info("\t\tEvent status after starting test event: reference event 0: "
|
log_info("\t\tEvent status after starting test event: reference event 0: "
|
||||||
@@ -113,7 +122,8 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
{
|
{
|
||||||
if (status[0] == CL_COMPLETE && status[1] == CL_COMPLETE)
|
if (status[0] == CL_COMPLETE && status[1] == CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Both events completed, so unable to test further (implicitly passing).\n" );
|
log_info("WARNING: Both events completed, so unable to test "
|
||||||
|
"further (implicitly passing).\n");
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -132,13 +142,18 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
{
|
{
|
||||||
if (status[0] == CL_COMPLETE)
|
if (status[0] == CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Reference event completed, so unable to test further (implicitly passing).\n" );
|
log_info("WARNING: Reference event completed, so unable to test "
|
||||||
|
"further (implicitly passing).\n");
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( status[ 0 ] != CL_RUNNING && status[ 0 ] != CL_QUEUED && status[ 0 ] != CL_SUBMITTED )
|
if (status[0] != CL_RUNNING && status[0] != CL_QUEUED
|
||||||
|
&& status[0] != CL_SUBMITTED)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Test failed because first wait event is not currently running, queued, or submitted! (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
|
log_error(
|
||||||
|
"ERROR: Test failed because first wait event is not currently "
|
||||||
|
"running, queued, or submitted! (status: 0: %s)\n",
|
||||||
|
IGetStatusString(status[0]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -146,7 +161,8 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
|
|
||||||
if (status[2] != CL_QUEUED && status[2] != CL_SUBMITTED)
|
if (status[2] != CL_QUEUED && status[2] != CL_SUBMITTED)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Test event is not waiting to run! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
|
log_error("ERROR: Test event is not waiting to run! (status: 2: %s)\n",
|
||||||
|
IGetStatusString(status[2]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -158,16 +174,19 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
|
|
||||||
// Grab statuses again
|
// Grab statuses again
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
|
||||||
error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
|
error = clGetEventInfo(events[2], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[2]), &status[2], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
if (multiple)
|
if (multiple)
|
||||||
{
|
{
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
|
||||||
error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
|
error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[1]), &status[1], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
}
|
}
|
||||||
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
|
||||||
error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
|
error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||||
|
sizeof(status[0]), &status[0], NULL);
|
||||||
test_error(error, "Unable to get event status");
|
test_error(error, "Unable to get event status");
|
||||||
|
|
||||||
log_info("\t\tEvent status after waiting for reference event 0: reference "
|
log_info("\t\tEvent status after waiting for reference event 0: reference "
|
||||||
@@ -179,12 +198,15 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
// Sanity
|
// Sanity
|
||||||
if (status[0] != CL_COMPLETE)
|
if (status[0] != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Waited for first event but it's not complete (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
|
log_error("ERROR: Waited for first event but it's not complete "
|
||||||
|
"(status: 0: %s)\n",
|
||||||
|
IGetStatusString(status[0]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're multiple, and the second event isn't complete, then our test event should still be queued
|
// If we're multiple, and the second event isn't complete, then our test
|
||||||
|
// event should still be queued
|
||||||
if (multiple && status[1] != CL_COMPLETE)
|
if (multiple && status[1] != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
if (status[1] == CL_RUNNING && status[2] == CL_RUNNING)
|
if (status[1] == CL_RUNNING && status[2] == CL_RUNNING)
|
||||||
@@ -195,7 +217,9 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
}
|
}
|
||||||
if (status[2] != CL_QUEUED && status[2] != CL_SUBMITTED)
|
if (status[2] != CL_QUEUED && status[2] != CL_SUBMITTED)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Test event did not wait for second event before starting! (status of ref: 1: %s, of test: 2: %s)\n", IGetStatusString( status[ 1 ] ), IGetStatusString( status[ 2 ] ) );
|
log_error("ERROR: Test event did not wait for second event before "
|
||||||
|
"starting! (status of ref: 1: %s, of test: 2: %s)\n",
|
||||||
|
IGetStatusString(status[1]), IGetStatusString(status[2]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -232,22 +256,28 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
// Sanity
|
// Sanity
|
||||||
if (status[1] != CL_COMPLETE)
|
if (status[1] != CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Waited for second reference event but it didn't complete (status: 1: %s)\n", IGetStatusString( status[ 1 ] ) );
|
log_error("ERROR: Waited for second reference event but it didn't "
|
||||||
|
"complete (status: 1: %s)\n",
|
||||||
|
IGetStatusString(status[1]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, the test event SHOULD be running, but if it completed, we consider it a pass
|
// At this point, the test event SHOULD be running, but if it completed, we
|
||||||
|
// consider it a pass
|
||||||
if (status[2] == CL_COMPLETE)
|
if (status[2] == CL_COMPLETE)
|
||||||
{
|
{
|
||||||
log_info("WARNING: Test event already completed. Assumed valid.\n");
|
log_info("WARNING: Test event already completed. Assumed valid.\n");
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( status[ 2 ] != CL_RUNNING && status[ 2 ] != CL_SUBMITTED && status[ 2 ] != CL_QUEUED)
|
if (status[2] != CL_RUNNING && status[2] != CL_SUBMITTED
|
||||||
|
&& status[2] != CL_QUEUED)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Second event did not start running after reference event(s) completed! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
|
log_error("ERROR: Second event did not start running after reference "
|
||||||
|
"event(s) completed! (status: 2: %s)\n",
|
||||||
|
IGetStatusString(status[2]));
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -284,20 +314,24 @@ int test_waitlist( cl_device_id device, cl_context context, cl_command_queue que
|
|||||||
{ \
|
{ \
|
||||||
name##Action action; \
|
name##Action action; \
|
||||||
log_info("-- Testing " #name " (waiting on 1 event)...\n"); \
|
log_info("-- Testing " #name " (waiting on 1 event)...\n"); \
|
||||||
if( ( error = test_waitlist( deviceID, context, queue, &action, false ) ) != CL_SUCCESS ) \
|
if ((error = test_waitlist(deviceID, context, queue, &action, false)) \
|
||||||
|
!= CL_SUCCESS) \
|
||||||
retVal++; \
|
retVal++; \
|
||||||
clFinish(queue); \
|
clFinish(queue); \
|
||||||
} \
|
} \
|
||||||
if( error == CL_SUCCESS ) /* Only run multiples test if single test passed */ \
|
if (error \
|
||||||
|
== CL_SUCCESS) /* Only run multiples test if single test passed */ \
|
||||||
{ \
|
{ \
|
||||||
name##Action action; \
|
name##Action action; \
|
||||||
log_info("-- Testing " #name " (waiting on 2 events)...\n"); \
|
log_info("-- Testing " #name " (waiting on 2 events)...\n"); \
|
||||||
if( ( error = test_waitlist( deviceID, context, queue, &action, true ) ) != CL_SUCCESS ) \
|
if ((error = test_waitlist(deviceID, context, queue, &action, true)) \
|
||||||
|
!= CL_SUCCESS) \
|
||||||
retVal++; \
|
retVal++; \
|
||||||
clFinish(queue); \
|
clFinish(queue); \
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue oldQueue, int num_elements )
|
int test_waitlists(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue oldQueue, int num_elements)
|
||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
@@ -305,11 +339,13 @@ int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
|
|
||||||
if (!checkDeviceForQueueSupport(deviceID, props))
|
if (!checkDeviceForQueueSupport(deviceID, props))
|
||||||
{
|
{
|
||||||
log_info( "WARNING: Device does not support out-of-order exec mode; skipping test.\n" );
|
log_info("WARNING: Device does not support out-of-order exec mode; "
|
||||||
|
"skipping test.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clCommandQueueWrapper queue = clCreateCommandQueue( context, deviceID, props, &error );
|
clCommandQueueWrapper queue =
|
||||||
|
clCreateCommandQueue(context, deviceID, props, &error);
|
||||||
test_error(error, "Unable to create out-of-order queue");
|
test_error(error, "Unable to create out-of-order queue");
|
||||||
|
|
||||||
log_info("\n");
|
log_info("\n");
|
||||||
@@ -323,7 +359,8 @@ int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
|
|
||||||
if (checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
if (checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
||||||
{
|
{
|
||||||
log_info( "\nNote: device does not support images. Skipping remainder of waitlist tests...\n" );
|
log_info("\nNote: device does not support images. Skipping remainder "
|
||||||
|
"of waitlist tests...\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -335,7 +372,8 @@ int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
TEST_ACTION(MapImage)
|
TEST_ACTION(MapImage)
|
||||||
|
|
||||||
if (checkFor3DImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
if (checkFor3DImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED)
|
||||||
log_info("Device does not support 3D images. Skipping remainder of waitlist tests...\n");
|
log_info("Device does not support 3D images. Skipping remainder of "
|
||||||
|
"waitlist tests...\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TEST_ACTION(ReadImage3D)
|
TEST_ACTION(ReadImage3D)
|
||||||
@@ -350,4 +388,3 @@ int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user