cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
685 Views
Registered: ‎01-28-2019

OpenCL kernel execution on KCU1500 "throwing an instance of 'std::runtime_error' what(): not implemented"

Software configuration: Ubuntu 18.04 (kernel 4.15.0-50-generic) and SDAccel (v2018.2).

Hardware configuration: KCU1500 FPGA

Description of the problem: In one of the latest tests that we run, we have a kernel named "copyArray" that has 5 parameters. The first two parameters are the source and destination pointers to the arrays, while the remaining three pointers are related to constant memory, local memory, and private memory. For the record the last three pointers are not used in the kernel, but we experimented because we intend to use them in future.

The kernel code is the following:

__kernel void copyArray(__global uchar *arrayA, __global uchar *arrayB, __constant uchar *_constant_region, __local uchar *_local_region, __global uchar *_private_region)
{
  int numElements = 128;
  int i=0;

  for (i=0; i<numElements; i++)
	arrayB[i]  =  arrayA[i];
}

And this is the code of the host function that executes the kernel:

void runKernel() {
	cl_int status;
	status  = clSetKernelArg(kernel, 0, sizeof(bufferA), &bufferA);
	cout << "[clSetKernelArg] index: 0 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 1, sizeof(bufferB), &bufferB);
	cout << "[clSetKernelArg] index: 1 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 2, sizeof(cl_mem), NULL);
	cout << "[clSetKernelArg] index: 2 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 3, sizeof(cl_mem), NULL);
	cout << "[clSetKernelArg] index: 3 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 4, sizeof(cl_mem), NULL);
	cout << "[clSetKernelArg] index: 4 and status:" << status << endl;
	size_t globalWorkSize[1] = {1};
	size_t localWorkSize[1] = {1};
	status = clEnqueueNDRangeKernel(commandQueue, kernel, 1, NULL, globalWorkSize, NULL, 0, NULL, &kernelEvent);
	clWaitForEvents(1,&kernelEvent);
	cout << "Heap has been executed" << endl;
}

The code above has been successfully compiled and executed on an Intel Arria 10 FPGA, an NVIDIA GPU and an AMD GPU. On the Xilinx FPGA we noticed that although the return status of the clSetKernelArg function is CL_SUCCESS (0), the following message occurs during execution:

[clSetKernelArg] index: 0 and status:0
[clSetKernelArg] index: 1 and status:0
[clSetKernelArg] index: 2 and status:0
[clSetKernelArg] index: 3 and status:0
[clSetKernelArg] index: 4 and status:0
terminate called after throwing an instance of 'std::runtime_error'
  what():  not implemented
Aborted (core dumped)

 

Solution: Then we attempted to pass some dummy pointers pointing to a cl_mem object instead of a NULL pointer, and this solved the problem. Therefore we believe that this version of the Xilinx driver that implements the OpenCL functions, it does not handle properly the case of NULL pointers as parameter. (The only exception is the local memory parameter, which must be NULL based on the OpenCL standard.)

The code of the correct host function:

void runKernel() {
	cl_int status;
	status  = clSetKernelArg(kernel, 0, sizeof(bufferA), &bufferA);
	cout << "[clSetKernelArg] index: 0 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 1, sizeof(bufferB), &bufferB);
	cout << "[clSetKernelArg] index: 1 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 2, sizeof(bufferConstant), &bufferConstant);
	cout << "[clSetKernelArg] index: 2 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 3, sizeof(cl_mem), NULL);
	cout << "[clSetKernelArg] index: 3 and status:" << status << endl;
	status |= clSetKernelArg(kernel, 4, sizeof(bufferPrivate), &bufferPrivate);
	cout << "[clSetKernelArg] index: 4 and status:" << status << endl;
	size_t globalWorkSize[1] = {1};
	size_t localWorkSize[1] = {1};
	status = clEnqueueNDRangeKernel(commandQueue, kernel, 1, NULL, globalWorkSize, NULL, 0, NULL, &kernelEvent);
	clWaitForEvents(1,&kernelEvent);
	cout << "Heap has been executed" << endl;
}

and this is the message during the execution:

[clSetKernelArg] index: 0 and status:0
[clSetKernelArg] index: 1 and status:0
[clSetKernelArg] index: 2 and status:0
[clSetKernelArg] index: 3 and status:0
[clSetKernelArg] index: 4 and status:0
Heap has been executed

We hope this may be of help to some of you, and this error may has been fixed in later versions of the driver (>2018.2).

2 Replies
Highlighted
Xilinx Employee
Xilinx Employee
598 Views
Registered: ‎03-24-2010

Thanks for your suggestion.  We'll take it into consideration.

But I'd like to confirm if OpenCL standard has definition for this situation?

Regards,
brucey
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
589 Views
Registered: ‎01-28-2019

Hello,

Thanks for the consideration.

The following text is from this url which provides information about the clSetKernelArg function. 

If the argument is a memory object (buffer or image), the arg_value entry will be a pointer to the appropriate buffer or image object. The memory object must be created with the context associated with the kernel object. A NULL value can also be specified if the argument is a buffer object in which case a NULL value will be used as the value for the argument declared as a pointer to __global or __constant memory in the kernel. If the argument is declared with the __local qualifier, the arg_valueentry must be NULL

Best Regards

 

0 Kudos