I have an interesting problem.  In the context of developing additional
functionality for the gpuR package I want to have the option for users to
provide a custom OpenCL kernel that will compile and provide a function
that can immediately be used within R.  I am quite close where I can
dynamically create the necessary C++ files, compile, and load the
function.  This leads to my current problem.

If I take a kernel that currently works within the package and use it to
create this custom function the following happens.  I can get the
previously initialized matrices from the context index I pass (i.e. I can
print them).  This made me believe that I can use my previously defined
contexts and objects.  But when I get to the 'viennacl::ocl::enqueue' call
of the kernel function it throws the error which I thought I read meant the
contexts weren't matching but I'm not sure where the disconnect is.

ViennaCL: Error -38 in function arg (
path/to/R/R-3.4.0/library/RViennaCL/include/viennacl/ocl/kernel.hpp:239 )
Error in cpp_gpuMatrix_custom_igemm(igpuA@address, TRUE, igpuB@address,  :
  ViennaCL: FATAL ERROR: CL_INVALID_MEM_OBJECT.
If you think that this is a bug in ViennaCL, please report it at
viennacl-support@lists.sourceforge.net and supply at least the following
information:
 * Operating System
 * Which OpenCL implementation (AMD, NVIDIA, etc.)
 * ViennaCL version
Many thanks in advance!


Running with VIENNACL_DEBUG_ALL I get the following output:

ViennaCL: Initializing context no. 0
ViennaCL: Initializing new ViennaCL context.
ViennaCL: Setting all devices for context...
ViennaCL: Getting platform...
ViennaCL: Querying devices available at current platform.
ViennaCL: Found 1 devices.
ViennaCL: Creating device object (CTOR with cl_device_id)
ViennaCL: Creating device object (Copy CTOR)
ViennaCL: Number of devices for context: 1
ViennaCL: Creating device object (Copy CTOR)
ViennaCL: Initialization of new ViennaCL context done.
ViennaCL: Creating device object (Copy CTOR)
ViennaCL: Creating device object (Copy CTOR)
ViennaCL: Adding new queue for device 0x2e2a00 to context 0x21847b40
ViennaCL: Context no. 0 initialized with 1 devices
ViennaCL: Device id: 0x2e2a00
ViennaCL: Creating device object (Copy CTOR)
ViennaCL: Adding program 'my_kernel' with source to context 0x21847b40
ViennaCL: Creating kernel object (full CTOR): iMatMult
ViennaCL: Stored program 'my_kernel' in context 0x21847b40
ViennaCL: There is/are 1 program(s)
ViennaCL: Getting program 'my_kernel' from context 0x21847b40
ViennaCL: There are 1 programs
ViennaCL: Setting global work size to 128 at index 0 for kernel iMatMult
ViennaCL: Setting global work size to 128 at index 1 for kernel iMatMult
ViennaCL: Setting local work size to 16 at index 0 for kernel iMatMult
ViennaCL: Setting local work size to 16 at index 1 for kernel iMatMult
ViennaCL: Setting int precision kernel argument 4 at pos 0 for kernel
iMatMult
ViennaCL: Setting int precision kernel argument 128 at pos 1 for kernel
iMatMult
ViennaCL: Setting int precision kernel argument 4 at pos 2 for kernel
iMatMult
ViennaCL: Setting int precision kernel argument 128 at pos 3 for kernel
iMatMult
ViennaCL: Setting generic kernel argument 0x1f59f720 at pos 4 for kernel
iMatMult

I initially see that it is 'initializing context 0' when it was previously
initialized within the main 'gpuR' package.  Perhaps this is okay, provided
it is initialized in the same way?  Or perhaps I need to find a way to
carry the previous context between functions (e.g. an external pointer).

Any thoughts are appreciated,

Charles
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
ViennaCL-support mailing list
ViennaCL-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-support

Reply via email to