junion icon indicating copy to clipboard operation
junion copied to clipboard

plug-in not found: junion

Open mambastudio opened this issue 5 years ago • 5 comments

JUnion configuration on netbeans 8.2 is okay after importing junion.jar as library. Unable to run a simple application since netbeans cannot run a simple program setting a struct array. Error shown is:

ant -f C:\\Users\\user\\Documents\\NetBeansProjects\\JUnionTest -Djavac.includes=juniontest/JUnionTest.java -Dnb.internal.action.name=run.single -Drun.class=juniontest.JUnionTest run-single init: Deleting: C:\Users\user\Documents\NetBeansProjects\JUnionTest\build\built-jar.properties deps-jar: Updating property file: C:\Users\user\Documents\NetBeansProjects\JUnionTest\build\built-jar.properties Compiling 1 source file to C:\Users\user\Documents\NetBeansProjects\JUnionTest\build\classes plug-in not found: junion compile-single: run-single: Exception in thread "main" java.lang.NullPointerException at juniontest.JUnionTest.main(JUnionTest.java:23) C:\Users\user\Documents\NetBeansProjects\JUnionTest\nbproject\build-impl.xml:1051: The following error occurred while executing this line: C:\Users\user\Documents\NetBeansProjects\JUnionTest\nbproject\build-impl.xml:805: Java returned: 1 BUILD FAILED (total time: 0 seconds)

mambastudio avatar Sep 08 '19 19:09 mambastudio

I was able to resolve, in which I didn't include junionc.jar. Netbeans wasn't finding the plugin. Anyway, this seems like a lovely library. I'll experiment with my OpenCL ray tracer. I'm using jocl library from JOCL .

I've been running through issues with out of memory exceptions with full type class approach due to object heap issues, yet the objects (class form) I'm using for opencl in java contain only primitives and my 4GB laptop is kinda sweating a lot with that. And with Chrome eating all the ram. A nightmare.

By the way, Valhalla has progressed a lot of late. I noticed they showcased a jdk containing Valhalla, and the memory consumption by primitive objects has been reduced by half! Amazing times ahead.

mambastudio avatar Sep 08 '19 20:09 mambastudio

It seems junion isn't working. A simple struct that is sent to opencl and modified, returned data seemed jumbled up. As I had thought, the struct is compatible if layout is represented by one type variables.

typedef struct { float4 a; float4 b; float4 c; } Particle

but not struct with different type variables

typedef struct { float a; int b; float4 c; } Particle

mambastudio avatar Sep 09 '19 15:09 mambastudio

As far as I understand, you would like for the Java junion struct to have the same memory representation as a struct in C/C++?

If that is the case, in junion you have to use Manual alignment, otherwise the junion compiler, by default is free to realign the actual in-memory representation as it sees fit to minimize memory usage.

A structure with manual alignment (and representation) is defined by the annotation @Struct(autopad=false) As a requirement, all the fields have to be aligned. Check out https://tehleo.github.io/junion/features.html under Manual alignment section for more information.

For debugging purposes you can also print the layout of a struct with: System.out.println(Mem.layoutString(MyStruct.class));

TehLeo avatar Sep 11 '19 12:09 TehLeo

Thank you TehLeo. Much appreciated. I figured out the issue. Apparently, OpenCL is interesting. A struct in OpenCL should be aligned in a way that struct size must be multiples of maximum datatype size. If the largest is float4 (16 bytes) and the subsequent datatype is an int, then I need to pad by 12 bytes since (4 bytes (int) + 12 bytes (3 floats) = 16 bytes). The alignment of the structs I created with JUnion before didn't map well to OpenCL due to that reason. Therefore, by just correcting that, all things reflected well between CPU and GPU. Amazing.

I'll do more experiment with the library.

mambastudio avatar Sep 13 '19 16:09 mambastudio

Thank you for reply. I'm glad that helped resolve the problem. 🙂

TehLeo avatar Sep 13 '19 21:09 TehLeo