3

First for all I would like to start by saying I am relatively new to openCL and kinda rusty in C++. Also this is the first time I'm asking a question so feel free to correct me or point to something I could improve in the post.

I am interested in creating a project that will create mixed mode assembly dll (CLR Library Project) to be loaded and used by CLR Form applications. The DLL is importing the openCL static library c++ header files (native code) and using a managed wrapper class to use to expose it to the CLR.

However I keep falling into the pitfall of fatal error C1001 which really isn't much to go through.

1>C:\Program Files (x86)\AMD APP\include\cl\cl.hpp(1270): warning C4290: C++ exception      specification ignored except to indicate a function is not __declspec(nothrow)
1>C:\Program Files (x86)\AMD APP\include\cl\cl.hpp(3708): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'msc1.cpp', line 1420)
1>To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++ 

Which points to

cl_int enqueueNativeKernel(
void (CL_CALLBACK *userFptr)(void *),  

I am using amd APP SDK v2.6 with the openCL 1.2 specs,Visual Studio 2010 Ultimate and linking the header/lib provided by the SDK. In theory the crossing from unmanaged to unmanaged code shouldn't be an issue buut since it's compiled with /CLR I included the #pragmas to indicate the unmanaged passing anyway

#pragma once
#pragma managed(push,off)
#define __NO_STD_STRING
#define __NO_STD_VECTOR
#include <cl\cl.hpp>

#pragma comment(lib,"OpenCL.lib")
#pragma managed(pop)

//rest of code

Always with the dreadful C1001 error,and a Compiler Crash(CL.exe because of c1xx.dll) and no matter how I play with the switches I am at a loss.

Switches are as follows /CLR, /MDd, Optimisation Disabled, EHa for Exception handling. And removing #defines or any of the wrapping code does't change a thing nor removing the #pragmas.

I should note that the project compiles fine with the C API included instead (CL\cl.h) and I know I could use that instead.

Has anyone else encountered this issue? Or am I doing something terribly wrong?I would really appreciate some info on the matter.

devnull
  • 43
  • 7
  • 1
    Something you can try is to use OpenCL from unmanaged code compiled without `/clr`, and link that with your managed code. The easiest way to do this is with a static library containing the unmanaged code, and use a project dependency to pull this into the managed project. – Ben Voigt Mar 14 '12 at 04:53
  • Possibly related: [Target .NET 3.5 C++/CLI in Visual Studio 2010 Beta 2](http://stackoverflow.com/questions/2106163/target-net-3-5-c-cli-in-visual-studio-2010-beta-2) In particular, follow the advice to clean all temporary files from your project, and ensure that you're targeting the correct version of the .NET Framework. Also see: [C1001 - Compiler crash on C++/CLI project in VS2010 when target framework is 3.5](https://connect.microsoft.com/VisualStudio/feedback/details/560606/c1001-compiler-crash-on-c-cli-project-in-vs2010-when-target-framework-is-3-5) – Cody Gray - on strike Mar 14 '12 at 06:40
  • @CodyGray I have tried that, however there was no change. And I always made sure it was targeting net 4.0 actually.The issue can be easily reproduced. Thanks for the suggestion :) – devnull Mar 14 '12 at 16:17
  • @BenVoigt - For what it is worth, that is what I do to get around this issue. – Jonathan DeCarlo Mar 14 '12 at 18:58

1 Answers1

2

An internal compiler error means that your compiler has crashed. It didn't find an error in your code; the compiler itself broke. This is due to a bug in the compiler, but if your code is wrong, then that could have helped trigger the bug.

Since "your code" in this case is not really your code, but OpenCL's code, it may just be that it can't be compiled by the C++/CLI compiler.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • That's probably true. I was having similar thoughts on that. Maybe I should clarify by saying that I wonder if anyone has seen that before and knows what the hell is wrong with the c++ header that causes the compiler to crash. Since it has no issue whatsoever with the pure C API, I wondered if it could be solved with a preprocessor directive that I missed or don't know about. The header is open source anyway so anyone can have a look at it. Thanks for the help anyway :) Makes me wonder if Microsoft would have a better answer. – devnull Mar 14 '12 at 16:21