ironted / aparapi

Automatically exported from code.google.com/p/aparapi
Other
0 stars 0 forks source link

How Learn Aparapi and use it!Any pdf , tutorial and ... #166

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.I want to write to 2 or 3 program with aparapi , I don't know anything about 
Opencl, so I ask how i learn aparapi?!!
2.My first program that i want to read is Breadth first search on graph , i 
write serial code and openmp code!my serial code is here :
do{
         stop=false;

            for (i = 0; i < noOfNodes ; i++)
            {
                if (mask[i] && curLevel == nodesArray[i].curIndex ){//if mask node true and cureIndex equal with current level cand be find neighbours
                    for (j = 0; j < nodesArray[i].numNeighbours; j++){
                        tempIndex = nodesArray[i].neighbours[j];
                        if (!visited[tempIndex]){//if visited=true then before find neighbours
                            mask[tempIndex] = true;
                            visited[tempIndex] = true;//go to true
                            parent[tempIndex] = i;
                            stop = true;
                            nodesArray[tempIndex].curIndex=curLevel+1;
                            distance[tempIndex] = distance[i] + 1;
                        }// end  if
                    }//end for j
                }
            }//end parallel for

}while(stop);
3.I use intellijidea and it was help to me to write this code but not working , 
i don't know how to write this program correctly!

 do{
            stop[0] = false;

            //for (i = 0; i < vectFirst.zie(); i++)

            Kernel kernel = new Kernel() {
                @Override
                public void run() {
                    int i=getGlobalId();
                        if (mask[i] && curLevel[0] == nodesArray[i].curIndex ){//if mask node true and cureIndex equal with current level cand be find neighbours
                            for (j[0] = 0; j[0] < nodesArray[i].numNeighbours; j[0]++){
                                tempIndex[0] = nodesArray[i].neighbours[j[0]];
                                if (!visited[tempIndex[0]]){//if visited=true then before find neighbours
                                    mask[tempIndex[0]] = true;
                                    visited[tempIndex[0]] = true;//go to true
                                    parent[tempIndex[0]] = i;
                                    stop[0] = true;
                                    System.out.println("!visited["+i+"] so Node "+tempIndex[0]+" Are neighbour");
                                    nodesArray[tempIndex[0]].curIndex=curLevel[0]+1;
                                    distance[tempIndex[0]] = distance[i] + 1;
                                }// end  if
                            }//end for j
                        }
                }
            };
            Range range = Range.create(noOfNodes);
            kernel.execute(range);
    curLevel[0]++;
        } while (stop[0]);

What is the expected output? What do you see instead?
** No compile error , output is some error after run it!:

com.amd.aparapi.ClassParseException: @151 NEW We don't support new instructions
    at com.amd.aparapi.MethodModel.createListOfInstructions(MethodModel.java:268)
    at com.amd.aparapi.MethodModel.init(MethodModel.java:1649)
    at com.amd.aparapi.MethodModel.<init>(MethodModel.java:1456)
    at com.amd.aparapi.ClassModel.getMethodModel(ClassModel.java:2601)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2634)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2643)
    at com.amd.aparapi.KernelRunner.execute(KernelRunner.java:1380)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1774)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1705)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1675)
    at Graph.bfs(Graph.java:126)
    at main.main(main.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Jul 01, 2015 10:43:20 AM com.amd.aparapi.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class Graph$1: @151 NEW We 
don't support new instructions
com.amd.aparapi.ClassParseException: @151 NEW We don't support new instructions
    at com.amd.aparapi.MethodModel.createListOfInstructions(MethodModel.java:268)
    at com.amd.aparapi.MethodModel.init(MethodModel.java:1649)
    at com.amd.aparapi.MethodModel.<init>(MethodModel.java:1456)
    at com.amd.aparapi.ClassModel.getMethodModel(ClassModel.java:2601)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2634)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2643)
    at com.amd.aparapi.KernelRunner.execute(KernelRunner.java:1380)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1774)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1705)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1675)
    at Graph.bfs(Graph.java:126)
    at main.main(main.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
!visited[0] so Node 5 Are neighbour
!visited[3] so Node 4 Are neighbour
com.amd.aparapi.ClassParseException: @151 NEW We don't support new instructions
    at com.amd.aparapi.MethodModel.createListOfInstructions(MethodModel.java:268)
    at com.amd.aparapi.MethodModel.init(MethodModel.java:1649)
    at com.amd.aparapi.MethodModel.<init>(MethodModel.java:1456)
    at com.amd.aparapi.ClassModel.getMethodModel(ClassModel.java:2601)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2634)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2643)
    at com.amd.aparapi.KernelRunner.execute(KernelRunner.java:1380)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1774)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1705)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1675)
    at Graph.bfs(Graph.java:126)
    at main.main(main.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Jul 01, 2015 10:43:20 AM com.amd.aparapi.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class Graph$1: @151 NEW We 
don't support new instructions
com.amd.aparapi.ClassParseException: @151 NEW We don't support new instructions
    at com.amd.aparapi.MethodModel.createListOfInstructions(MethodModel.java:268)
    at com.amd.aparapi.MethodModel.init(MethodModel.java:1649)
    at com.amd.aparapi.MethodModel.<init>(MethodModel.java:1456)
    at com.amd.aparapi.ClassModel.getMethodModel(ClassModel.java:2601)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2634)
    at com.amd.aparapi.ClassModel.getEntrypoint(ClassModel.java:2643)
    at com.amd.aparapi.KernelRunner.execute(KernelRunner.java:1380)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1774)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1705)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1675)
    at Graph.bfs(Graph.java:126)
    at main.main(main.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

What version of the product are you using? On what operating system?
I use in windows , and sample that i use work correctly , when i run Info run 
correctly and show that my laptop have to opencl environment 1.is a cpu  and 
gpu 
and 2.is one gpu!

Please provide any additional information below.
Thanks All of you.Please help me.

Original issue reported on code.google.com by siamakgo...@gmail.com on 1 Jul 2015 at 6:16

GoogleCodeExporter commented 8 years ago
i read this link i think that i have to change my data structure and i can not 
use class objects like graph 
https://code.google.com/p/aparapi/wiki/JavaKernelGuidelines

Original comment by siamakgo...@gmail.com on 1 Jul 2015 at 11:58

GoogleCodeExporter commented 8 years ago
So Aparapi will not let you use 'new'.  You cannot allocate on the GPU

Looking at your code, I suspect the 'new' is coming from your use of 
System.out.println(....) which is creating a 'new' StringBuilder behind the 
scenes.

Comment this line out and see what happens 

Original comment by gfr...@google.com on 1 Jul 2015 at 4:25

GoogleCodeExporter commented 8 years ago
how to write bfs with aparapi?Anyone can help Me?

Original comment by siamakgo...@gmail.com on 25 Jul 2015 at 9:22