CLR Assembly Reference Created CLR Assembly but cannot reference classes
In Visual Studio 2010 I created a Visual C++ CLR class library. Set the build customizations to Cuda 4.0. Created a .cu cuda file. Added a class or two. Wrapped a namespace around it. Compiled. Used the object browser to see what's up, and noticed the namespace and classes created by nvcc.exe exist. In another .NET project I referenced the assembly. OK fine, no problems so far. Then in the code of the other .NET project I try to use the namespace and the classes I just created (in cuda files compiled by nvcc). Error says "namespace name 'xyz' cannot be found (are you missing a using directive or an assembly reference?)" Uh no I'm not. I can see the darn thing with the object browser. It's right there. What I did notice however is that the class can't be set to public. nvcc does not allow the word public to preceed class. Without the class being set to public I may not be able to use the class elsewhere, meaning in other assemblies.

How do I make a class public within this cuda language? Where is the formal definition of this nvcc language anyway? I looked around for it on the internet and it wasn't apparently clear where to find this documentation.

namespace XYZ
{
class MyClass1
{
};

public class MyClass2
{
};
}

For example MyClass1 is proper syntax MyClass2 is not. If the class is not public it cannot be accessed by other assemblies.
In Visual Studio 2010 I created a Visual C++ CLR class library. Set the build customizations to Cuda 4.0. Created a .cu cuda file. Added a class or two. Wrapped a namespace around it. Compiled. Used the object browser to see what's up, and noticed the namespace and classes created by nvcc.exe exist. In another .NET project I referenced the assembly. OK fine, no problems so far. Then in the code of the other .NET project I try to use the namespace and the classes I just created (in cuda files compiled by nvcc). Error says "namespace name 'xyz' cannot be found (are you missing a using directive or an assembly reference?)" Uh no I'm not. I can see the darn thing with the object browser. It's right there. What I did notice however is that the class can't be set to public. nvcc does not allow the word public to preceed class. Without the class being set to public I may not be able to use the class elsewhere, meaning in other assemblies.



How do I make a class public within this cuda language? Where is the formal definition of this nvcc language anyway? I looked around for it on the internet and it wasn't apparently clear where to find this documentation.



namespace XYZ

{

class MyClass1

{

};



public class MyClass2

{

};

}



For example MyClass1 is proper syntax MyClass2 is not. If the class is not public it cannot be accessed by other assemblies.

#1
Posted 08/25/2011 09:57 PM   
Just following up. Created a .cpp class in the assembly. This class acts as a hook into the assembly. The class is a normal Visual C++ class and can be set to public. This in turn calls a static method in the cuda class. So in effect what I have is a C# application program calling a C++ CLR library with both .cpp and .cu files. It is a CLR/managed assembly. I even was able to get events to work. What I still haven't figured out is how to use the #using <MYCSHARP.dll> and using namespace MYNAMESPACE:: directives from within nvcc. nvcc gives me the "unrecognized preprocessing directive" error and "name followed by :: must be a class or namespace name" error when I try to add this type of stuff to a .cu cuda program. The reason that I want to do this is because I have a common base of code for the project and subsystems written in C#. I would like to be able to use this common base within the C++/Cuda assembly. As it stands it does not appear that I will be able to do this. I have done this before with just straight Visual C++ assemblies. But not this mixed C++/Cuda assembly. At least not in the cuda program files within that mixed assembly.
Just following up. Created a .cpp class in the assembly. This class acts as a hook into the assembly. The class is a normal Visual C++ class and can be set to public. This in turn calls a static method in the cuda class. So in effect what I have is a C# application program calling a C++ CLR library with both .cpp and .cu files. It is a CLR/managed assembly. I even was able to get events to work. What I still haven't figured out is how to use the #using <MYCSHARP.dll> and using namespace MYNAMESPACE:: directives from within nvcc. nvcc gives me the "unrecognized preprocessing directive" error and "name followed by :: must be a class or namespace name" error when I try to add this type of stuff to a .cu cuda program. The reason that I want to do this is because I have a common base of code for the project and subsystems written in C#. I would like to be able to use this common base within the C++/Cuda assembly. As it stands it does not appear that I will be able to do this. I have done this before with just straight Visual C++ assemblies. But not this mixed C++/Cuda assembly. At least not in the cuda program files within that mixed assembly.

#2
Posted 08/29/2011 07:23 PM   
Scroll To Top