Skip to content

Proper error handling in the native code and Java wrapper.#10

Merged
umar456 merged 10 commits into
arrayfire:masterfrom
ShadyBoukhary:master
Jul 22, 2019
Merged

Proper error handling in the native code and Java wrapper.#10
umar456 merged 10 commits into
arrayfire:masterfrom
ShadyBoukhary:master

Conversation

@ShadyBoukhary

@ShadyBoukhary ShadyBoukhary commented Jul 17, 2019

Copy link
Copy Markdown
Member
  • Added error handling in the native code and Java wrapper
  • When af_err > 0, the native code throws a JavaException containing the error code, message, and and the stack trace including the native code.
  • The native code populates an ArrayFireException present in the Java wrapper.
  • The native code converts all C++ exceptions in the native code to proper Java exceptions that are thrown when the native code returns.
  • Added identity array creation
  • Formatted files and fixed a leak in the HelloWorld example

@umar456 umar456 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super excited about this update. I know you are still working on updating the API. Made a couple of notes that can be addressed in the future.


static {
@SuppressWarnings("serial")
final Map<Integer, String> map = new HashMap<>() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch would be better here don't you think?

Comment thread src/arith.cpp
dim_t dims[4]; \
af_dtype ty = f32; \
AF_CHECK(af_get_dims(dims + 0, dims + 1, dims + 2, dims + 3, ARRAY(a))); \
AF_CHECK(af_get_type(&ty, ARRAY(a))); \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds strange. I thought ArrayFire could handle this internally. Looks like its there from earlier and its formatted.

Comment thread examples/HelloWorld.java
Array C = new Array();

// Do vector addition on the device
Arith.add(C, A, B);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its going to be difficult to figure out where each of the functions are defined. I think it may be better to put everything in the ArrayFire class instead of in these other classes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that too. You basically have to guess which class the method would be in

@umar456
umar456 merged commit 5ff457b into arrayfire:master Jul 22, 2019
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

Successfully merging this pull request may close these issues.

2 participants