Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Priveyes
@Pascal66
@freemo For all of us, System.setProperty("com.aparapi.enable.PUTFIELD", "true"); is a great things. Then If we can modify Config this avoid many dev problems.
@freemo last but not least, the old (2018) error bounty about unsused variable isnt resolved.
CoreRasurae
@CoreRasurae
git.qoto.org seems to be experiencing problems for the past days
Hungry Blue Dev
@hungrybluedev
The aparapi.com website is down. So is git.qoto.org
CoreRasurae
@CoreRasurae
At this moment both websites were back online
grfrost
@grfrost
Out of curiousity @Pascal66 . What problem is System.setProperty("com.aparapi.enable.PUTFIELD", "true") solving? Unless you really understand the 'raceyness' of fields, I suspect that you don't need this.
Hungry Blue Dev
@hungrybluedev
@CoreRasurae The websites are back, yes
Btw how do we unroll nested loops in the Kernel? Suppose the simple matrix multiplication algorithm
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                long sum = 0;
                for (int k = 0; k < N; k++) {
                    sum += a[i][k] * b[k][j];
                }
                c[i][j] = sum;
            }
        }
I tried something like this:
        Kernel kernel = new Kernel() {
            @Override
            public void run() {
                int i = getGlobalId(1);
                int j = getGlobalId(2);
                int k = getGlobalId(3);
                c[i][j] += a[i][k] * b[k][j];
            }
        };
Hungry Blue Dev
@hungrybluedev

This only gets me:

[[1, 0, 0, 0], [5, 0, 0, 0], [9, 0, 0, 0], [13, 0, 0, 0]]

vs

[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
Here, a is the second matrix, b is the identity and the second one is the expected result. The first one results from the kernel
Hungry Blue Dev
@hungrybluedev
(Using 0, 1 and 2 as ID dimensions also didn't work)
Priveyes
@Pascal66
@grfrost Without it , I have to use an array for many variables instead assign them directly as a=b with putfield a[0]=b[0] without (not searching why) but it work
grfrost
@grfrost
@Pascal66 so putfield will work if (and its a big if) you only expect one of the kernel dispatches to write a value to this field or if more than one writes a value, but you don't care which value you get (because you can't reason the order of dispatches) So with more than one kernel putting, it is basically a race. It can be used to signify/flag that a search has succeeded. But that is about all.
Barney Pitt
@barneypitt
@grfrost I use putfield=true in many, many kernels, and never had a race problem (that I know of!). Kernel fields are private (memory space), aren't they? Or are we talking at cross-purposes?
grfrost
@grfrost
I did not think they were private. (Hmm must look at code, it has been a while ;) ), but my reasoning is that we only have one 'class' as a template for the kernel. We do not create one instance class per threadid. So if each kenel were to write to the 'memory offset' representing a single field. How do we disambiguate? How do we decide which of these are returned back to the original Kernel class.
@hungrybluedev I think you will still need at least one loop. You may be able to use local memory to store useful partial values. See this for a template. http://www.es.ele.tue.nl/~mwijtvliet/5KK73/?page=mmopencl
Barney Pitt
@barneypitt

@grfrost I have never examined the "output" value of any (primitive) kernel field - for the reasons you state they would be meaningless. In fact, I'd be surprised if the JNI code copies anything in to them (what would if copy the value from?).

In fact, if the run() method was one monolithic method which didn't call other methods (as in fact is the case with the compiled OpenCL - every single method call gets inlined when OpenCL is compiled - hence recusrsion not allowed!) then there would be no need for setting field values. In fact, local variables would do.

But for maintaining state between method calls, field setting is invaluable (especially as Java has no "out parameter" semantics for returning multiple values from a method). It's especially important for polymorphic Kernels ... most of my Kernels extend base Kernel classes and the base classes often have methods which mutate fields.

I'm basically certain kernel fields use private memory in Aparapi (i.e. no modifier - as private memory space is the default memory space) . Though I haven't double checked the code, none of my Kernels would work if they weren't!

Incidentally, when doing JTP execution, of course, the Kernels are clone()d, so theoretically something meaningful could be "returned" in primitive fields, though obviously we throw away the clones.

In any case, I the "enable putfield" flag can be circumvented anyway because "simple setters" (bean pattern setters) are allowed in any case. So enabling putfield by default just avoids having to create setters for all mutable fields.
grfrost
@grfrost
@barneypitt @Pascal66 I see. You want putfields for non kernel code paths. I assumed aparapi only reports an error if a 'putfield' is determined to be reachable from the run() method? is it just blanketly bitching if any putfield is found? BTW I know there was a branch where we allowed the kernel access to the 'understood to be racey' putstatic fields. So that we could control reductions, rather than forcing buffer[1] allocations. I wonder if we trashed that idea.
Barney Pitt
@barneypitt

@gfrost No, I definitely want them for the kernel code path! (Pretty sure you are right that Aparapi only complains if the putfield is actually used on the kernel execution path.)

I never care about Java accessing the "output" values of primitive fields. But I very much care about OpenCL accessing them. E.g. public void run() { writeToSomeFields(); doSomethingWithModifiedFields(); }

Barney Pitt
@barneypitt
I do this all the time, for example have a utility method which extracts red/green/blue values from pixels[getGlobalId()] into fields this.red, this.green, this.blue, and another utility method which combines this.red, this.green. this.blue into pixels[getGlobalId()]. And in between, invoke usually several methods which both read from and write to the fields.
Jeffrey Phillips Freeman
@freemo
@Pascal66 hi, just seeing this now, sorry for the delay. Glad to see others have helped you though
Helios85
@Helios85

Hi, I cannot get v2.0.0 validated in my Maven pom file which I use within an Eclipse project. It always comes up with "Missing artifact com.aparapi:aparapi:jar:2.0.0".

When I change it back to 1.10.0, everything works. Any help would be appreciated!

Jeffrey Phillips Freeman
@freemo
@Helios85 well the first step to diagnosing this is to not use eclipse so we can verify whats really going on. What happens when you try to build using maven directly
Helios85
@Helios85
@freemo Well, unfortunately I have never used Aparapi outside Eclipse, I don't know the mechanics how to build it directly under Windows 10.
Jeffrey Phillips Freeman
@freemo
just go into the root directory of your project and do mvn package
Helios85
@Helios85
I'll try it.
Helios85
@Helios85

I used the "cmd" command to enter the command line mode of Windows, then went into the root directory and issued "mvn package". This caused an error message "could not find mvn".

Should I use cygwin instead?

Jeffrey Phillips Freeman
@freemo
ok so you dont even have maven installed
sounds like you need to install it
Helios85
@Helios85
Yes, I will install it and then try again. This means that Maven inside Eclipse is different from the Maven file that can be downloaded.
Jeffrey Phillips Freeman
@freemo
so it would seem
Helios85
@Helios85

I installed Maven, issued mvn package and got "Build Success".

Hmm. So it works with stand-alone Maven but doesn't work with the M2Eclipse Maven plug-in. Strange!

This Problem occurs only with v2.0.0, when I Change back to v1.10.0, the problem disappears.
Jeffrey Phillips Freeman
@freemo
sounds like an eclipse issue then
it is odd its specific to 2.0.0
but the error doesnt tell us much
might need to get help fromt he eclipse guys until you figure out what the issue is
Helios85
@Helios85
I've got it to run with 2.0.0! I deleted all Maven repositories (the source and javadoc files), then Eclipse downloaded everything again and now it works.
Hungry Blue Dev
@hungrybluedev
@grfrost Hey man sorry for the late reply. I fixed it myself and you're right. I still needed one loop for the k-based sum. I'm glad to say that the performance improvement (especially for n=1000) is spectacular. I got 30 s per CPU multiplication vs 0.3 s on GPU.
Jeffrey Phillips Freeman
@freemo
@Helios85 great!
Spidz67
@Spidz67
Hello. I have installed everything needed to run java programs using Aparapi. But now my problem is creating a basic java program that runs. Can someone please provide me with a basic java program/file that has everything that is needed for it to run successfully. Or explain to me what I need to do please.
Jeffrey Phillips Freeman
@freemo
@Spidz67 the aparapi-examples repo should give you what you need
thejdc
@thejdc
Hello all! Fairly new to Java, but extremely new to Aparapi. What is 'range' and 'group size'? Does group size affect the utilization of the GPU? I've searched through the webpage but can't seem to find an explanation for these terms.
Jeffrey Phillips Freeman
@freemo
@thejdc its the work-group size, a generic GPU concept... here is a link, first hit, that touched on it a bit: https://software.intel.com/en-us/forums/opencl/topic/536555
thejdc
@thejdc
@freemo Thanks for the link, definitely helps out!
Jeffrey Phillips Freeman
@freemo
@thejdc happy to help