cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Frio
Journeyman III

Using OpenCL beta from a .NET application causes a memory access violation exception

Hello,

I am trying to experiment with the beta OpenCL SDK calling OpenCL from a C# .NET managed application.

Any call to the OpenCL API causes a memory access violation exception, both when calling OpenCL directly from C# or when creating a native dll and calling the OpenCL API from a function in the native dll. 

I added a C# console application project to your OpenCLSamplesVS solution and created manual bindings to the OpenCL dll, the result is always a memory exception reading location 0x00000000.

Cheers,

Frio

0 Likes
14 Replies
genaganna
Journeyman III

It seems you are not able to call any c/c++ dll from c#.

 

I guess calling conventions could be a issue.

0 Likes

I am using a number of additional C++ dlls without a single problem.

As I said, even calling the OpenCL API from within a C/C++ function in the C++ native dll (invoked by C#) it still causes the access violation; the code executes just fine up to the OpenCL API call, then crash...

Any other call to any other C/C++ dll functions works perfectly.

Frio

0 Likes

Frio,

 

     I am able to call OpenCL API function from c/c++ dll(called by c++).

 

      what i have done

 

       1. created clib.dll which contain one function which is calling OpenCL API

       2. created c++ application which calls function defined clib.dll

0 Likes

hi genaganna,

thanks for your comments, perhaps I haven't explained myself correctly.

This is the situation:

I have a C# (.NET managed) application.

I want to call OpenCL API functions from the C# application.

This is what I tried:

1) I tried to call the OpenCL API directly from C# and a memory access violation occurs.

2) I created a C++ dll (OpenCLSupport.dll) which contains one function which calls OpenCL API; then I called the function in OpenCLSupport.dll from C# and the same memory access violation occurs.

I need to use OpenCL API from C# and any attempts I have made result in the same memory access violation, I suspect there might be a problem, could you please investigate?

Cheers,

Frio

0 Likes

Could you post the code?

0 Likes

Here is a snippet, it doesn't do anything useful, but the equivalent C++ code doesn't crash.

My program is obviously different, but calling ANY OpenCL API results in the same memory access violation.

Frio

using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication1 { unsafe class Program { [DllImport("OpenCL")] static extern int clReleaseMemObject(IntPtr a); static void Main(string[] args) { clReleaseMemObject(IntPtr.Zero); } } }

0 Likes

Which OS are you using?

 

0 Likes
Frio
Journeyman III

Windows XP Professional SP3 32-bit

0 Likes

Thanks.

This is a known problem with WindowXP and it has to do with our use of declspec and TLS. This is being tracked internally and will be fixed in an up and comming update.

0 Likes
Frio
Journeyman III

Ok, thanks.

Any clue about when the update is going to be released?

Cheers,

Frio

0 Likes
Illusio
Journeyman III

Just a small FYI: There are several open source C# bindings available at this point. While they probably won't help you with the XP issue, at least they can save you quite a bit of mindnumbingly boring work.

 

http://sourceforge.net/projects/openclnet/develop

http://www.opentk.com/

 

0 Likes

Originally posted by: brg Thanks.

 

This is a known problem with WindowXP and it has to do with our use of declspec and TLS. This is being tracked internally and will be fixed in an up and comming update.



Is there any update on this issue? It is blocking our .Net bindings (http://www.opentk.com).

I am seeing this on the Vista version of the SDK (2.0 beta 2 and beta 3). The Linux version is working correctly.

0 Likes

I get the same error message if I try to use OpenCL.dll from a Delphi GUI (windowed) application.  It seems it is because OpenCL.dll tries to write the silly expiry message to the stderr (or stdout).  Hence if you write a console application in Windows, you can use the current OpenCL.dll made by AMD/ATI.  But if you make a GUI application, you can only use nVIDIA's OpenCL solution properly -- which doesn't print anything to the stderr or stdout.

0 Likes

Frio, TheFiddler, fiery,

Is this issue resolved with the 2.0 SDK?

0 Likes