Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plug-in not found: junion #6

Open
mambastudio opened this issue Sep 8, 2019 · 5 comments
Open

plug-in not found: junion #6

mambastudio opened this issue Sep 8, 2019 · 5 comments

Comments

@mambastudio
Copy link

mambastudio commented Sep 8, 2019

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
Copy link
Author

mambastudio commented Sep 8, 2019

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
Copy link
Author

mambastudio commented Sep 9, 2019

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

@TehLeo
Copy link
Owner

TehLeo commented Sep 11, 2019

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));

@mambastudio
Copy link
Author

mambastudio commented Sep 13, 2019

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.

@TehLeo
Copy link
Owner

TehLeo commented Sep 13, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants