Re: [javacpp-project] Error in .cu file : a namespace name(thrust) is not allowed here

174 views
Skip to first unread message

Samuel Audet

unread,
Apr 23, 2013, 8:07:41 AM4/23/13
to javacpp...@googlegroups.com
On 04/23/2013 05:28 PM, Piyush Arya wrote:
> Any idea why this is shown as error ?

I am not sure, but let's start with something simpler. Can you let me
know what happens if you copy/paste the ThrustTest example exactly and
run the following three commands as is?
$ javac -cp javacpp.jar ThrustTest.java
$ java -jar javacpp.jar ThrustTest -properties linux-x86_64-cuda
$ java -cp javacpp.jar ThrustTest
On my machine, I get some warnings, but no errors and everything runs fine.

What do you get?

Samuel

Piyush Arya

unread,
Apr 23, 2013, 8:55:57 AM4/23/13
to javacpp...@googlegroups.com
That code was working initially, but now its throwing  error  
$ java  -cp javacpp.jar ThrustTest
Exception in thread "main" java.lang.NoClassDefFoundError:  -cp
Caused by: java.lang.ClassNotFoundException:  -cp
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class:  -cp. Program will exit.

Perhaps due to some system settings i am playing with last couple of days to make my app working.


On Tuesday, April 23, 2013 1:58:56 PM UTC+5:30, Piyush Arya wrote:
I am using  Javacpp with maven 2.1 on Ubuntu 11.10.

pom.xml include exec plugin as shown
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>javacpp</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument> -jar  </argument>       <argument> /home/piyush/JCuda/javacpp.jar </argument>
                                <argument> -classpath  </argument> <argument> ${project.build.outputDirectory}:/home/piyush/JCuda/jcuda-0.5.0.jar:/home/piyush/JCuda/jcusparse-0.5.0.jar  </argument>
                                <argument> -d  </argument>         <argument>  ${project.build.outputDirectory}/lib/  </argument>
                                <argument>  -properties  </argument>    <argument>  linux-x86_64-cuda  </argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I am trying http://code.google.com/p/javacpp/wiki/ThrustAndCUDA code with maven in my java app.
When nvcc is compiling jniOps.cu file it is showing error-
/home/piyush/TestWebapp6/target/classes/lib/jniCudaOps.cu(1154): error: a namespace name is not allowed
which in code is

JNIEXPORT void JNICALL Java_com_skenzo_cuda_CudaOps_copy(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jobject arg2) {
    thrust* ptr0 = arg0;
    thrust* ptr1 = arg1;
    int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID));
    jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID);
    ptr2 += position2;
    try {
        thrust::copy(*ptr0, *ptr1, ptr2);
    } catch (...) {
        JavaCPP_handleException(env);
    }
}

Piyush

unread,
Apr 23, 2013, 9:14:48 AM4/23/13
to javacpp...@googlegroups.com
Sorry for last message.
I deleted previous .class files and the above code is working fine now. Its is only creating problem while using with java app (with maven)


--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
The question is not why, its how.

Piyush

unread,
Apr 23, 2013, 9:31:00 AM4/23/13
to javacpp-project
While running this code http://code.google.com/p/javacpp/wiki/ThrustAndCUDA i copied the intermediate jniThrustTest.cu and found that thrust is always used as namespace (thrust::). So is it some annotations i am missing which lead to 
illegal code generation.
I am putting the file which use thrust here for your reference http://pastebin.com/uhRSLt6Y

Piyush

unread,
Apr 24, 2013, 7:53:09 AM4/24/13
to javacpp-project
Here are couple of warnings thrown before building of .so file

24 Apr, 2013 4:29:21 PM com.googlecode.javacpp.Generator doParametersBefore
WARNING: Method "public static native void com.skenzo.cuda.CudaOps.copy(com.skenzo.cuda.CudaOps$IntDevicePointer,com.skenzo.cuda.CudaOps$IntDevicePointer,com.googlecode.javacpp.IntPointer)" has an unsupported parameter of type "com.skenzo.cuda.CudaOps.IntDevicePointer". Compilation will most likely fail.
24 Apr, 2013 4:29:21 PM com.googlecode.javacpp.Generator doParametersBefore
WARNING: Method "public static native void com.skenzo.cuda.CudaOps.copy(com.skenzo.cuda.CudaOps$IntDevicePointer,com.skenzo.cuda.CudaOps$IntDevicePointer,com.googlecode.javacpp.IntPointer)" has an unsupported parameter of type "com.skenzo.cuda.CudaOps.IntDevicePointer". Compilation will most likely fail.
24 Apr, 2013 4:29:21 PM com.googlecode.javacpp.Generator doParametersBefore
WARNING: Method "public static native void com.skenzo.cuda.CudaOps.sort(com.skenzo.cuda.CudaOps$IntDevicePointer,com.skenzo.cuda.CudaOps$IntDevicePointer)" has an unsupported parameter of type "com.skenzo.cuda.CudaOps.IntDevicePointer". Compilation will most likely fail.

..... and so on


Samuel Audet

unread,
Apr 24, 2013, 8:35:05 AM4/24/13
to javacpp...@googlegroups.com
On 04/24/2013 08:53 PM, Piyush wrote:
> I am putting the file which use thrust here for your reference http://pastebin.com/uhRSLt6Y

Thanks, this is the problem here:
import jcuda.Pointer;
JavaCPP doesn't support types from JCuda...

Samuel

Piyush

unread,
Apr 24, 2013, 8:56:47 AM4/24/13
to javacpp-project
Does it mean i can't use jcuda in my whole app which uses javacpp. I am not using jcudaPointer in thrust code.
Sorry if the solution is obvious. I am new in java development.
Thanks for your time.


--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-project+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


Samuel Audet

unread,
Apr 24, 2013, 9:02:55 AM4/24/13
to javacpp...@googlegroups.com
On 04/24/2013 09:56 PM, Piyush wrote:
> Does it mean i can't use jcuda in my whole app which uses javacpp. I am
> not using jcudaPointer in thrust code.
> Sorry if the solution is obvious. I am new in java development.
> Thanks for your time.

No, it means you have to access the Pointer classes by their fully
qualified names if you need to use both of them together in the same
.java file. Please read this page:
http://docs.oracle.com/javase/tutorial/java/package/usepkgs.html

Samuel

Piyush

unread,
Apr 24, 2013, 9:48:00 AM4/24/13
to javacpp-project
Worked like a charm.
Thanks a lot




Samuel

--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-project+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages