Results 1 to 3 of 3

Thread: OpenCL not finding devices as dll

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2

    OpenCL not finding devices as dll

    Hy

    So I am fairly new to OpenCL and GPGPU in general , all has been great until I wanted to integrate it with one of my C# applications issue being that if I call the functioning from C# OpenCL does not find any valid devices but if I switch from .dll to .exe and execute it as a console application it works just fine

    C++ code sample
    Code :
    #if _MSC_VER 
    #define EXPORT_API __declspec(dllexport) functions with this
    #else
    #define EXPORT_API 
    #endif
     
    .........
     
    extern "C"
    {
    int EXPORT_API CLGetDeviceCount()
    {
    	cl::Platform::get( &platforms);
    	cl_context_properties cps[3] =  { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[i])(), 0 };
    	context = cl::Context (CL_DEVICE_TYPE_ALL , cps);
     
    	devices = context.getInfo<CL_CONTEXT_DEVICES>();
     
    	return devices.size() ;
    }
    }

    C# code sample
    Code :
    using System.Runtime.InteropServices;
     
    ......
     
    public class SimpleCLCall 
     {
     [DllImport("CLTest")]
        private static extern int CLGetDeviceCount();
     
      public int clDeviceCount()
      {
      return CLGetDeviceCount();
      }
    }

  2. #2

    Re: OpenCL not finding devices as dll

    I don't have experience with your problem, but perhaps it would be easier if you used the exisiting .Net wrappers:
    Cloo: http://sourceforge.net/projects/cloo/
    The Open Toolkit library: http://sourceforge.net/projects/opentk/

    I have no experience with either, so I can't help you much further. Looking at the source code might also help you if you still want to write your own version.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    2

    Re: OpenCL not finding devices as dll

    Thank you for the reply , I looked over cloo and is great implementation and it works with my application , but I will still write my own one helps on the learning the API and how everything works easier

Similar Threads

  1. Finding a general lib for OpenCL
    By lilei9110 in forum OpenCL
    Replies: 10
    Last Post: 04-16-2010, 05:44 AM
  2. Replies: 1
    Last Post: 02-06-2010, 07:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •