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

NullPointerException #6

Closed
lidijaf opened this issue Jul 17, 2014 · 7 comments
Closed

NullPointerException #6

lidijaf opened this issue Jul 17, 2014 · 7 comments

Comments

@lidijaf
Copy link

lidijaf commented Jul 17, 2014

A new problem, hopefully the last thing that prevents running nbody successfully. When called outside of nbody function, the energy function behaves as expected, but when called inside nbody, it gives a NullPointerException.

@lidijaf
Copy link
Author

lidijaf commented Jul 22, 2014

Finally, after a week of trying, I figured out where the problem is. It is the operation:
diag(mag)<-0
We already noticed some staging time errors due to immutable objects issues, and we just ignored them, as the program worked. Well, it did not work properly. Our matrix is immutable, so we cannot change it. If we do so, we get stage time errors, and there is no code generated for the problematic regions, so we have NullPointerException.
The solution is obvious: when it comes to the diag function, I need to find the name of the matrix (RSymbol) in my env, based on the value passed as argument. For now, that works. Then, I need to get a mutable copy of the matrix, and update it. Still ok. Finally, I should update the env with my new matrix and the old name, as: env=env.updated(name, newMatr).
But this update does nothing, the matrix remains unchanged, so I'm still struggling with this... @lidijaf

@lidijaf
Copy link
Author

lidijaf commented Jul 22, 2014

I solved the problem with updating the env map, by creating an immutable copy of matrix before putting it to env. Still, there are stage time problems...

@lidijaf
Copy link
Author

lidijaf commented Jul 22, 2014

My best guess is that there is a same problem with vector update, so the next step is to work out vector updates.

@lidijaf
Copy link
Author

lidijaf commented Jul 28, 2014

It turns out that each part of nbodies works alone, but not as a whole. There exist a set of problems (not really errors, just not the best solutions). Now vector update and matrix diagonal update are resolved. Still, the return function call gives the following staging error: "Violated ordering of effects". I still don't know what does it mean, but I hope I'l figure it out soon.

@lidijaf
Copy link
Author

lidijaf commented Jul 28, 2014

Interesting fact here: stanford-ppl/Delite#25
It describes a similar problem, due to OptiML bug, so it seems that my problem is not the return itself, but accessing a vector, that was updated. I need some workaround for this.

@lidijaf
Copy link
Author

lidijaf commented Jul 30, 2014

So, I solved the vector update issue, now it works fine, but of course this is not the end. It appeared that my approach with function call won't work, because I save the state of env before function body and later I set the env back to that state. That is not good if the function body actually updates some global value. So now, there are two possibilities:

  1. when updating a vector, check if it is super assignment, and update a global env, that was saved before the body of a function
  2. after the function body, retain only those elements in env, that were present in the state before function body.
    Both approaches give me Violated ordering of effects error, so I need a quick workaround to overcome this bug.

@lidijaf
Copy link
Author

lidijaf commented Nov 20, 2014

fixed by update

@lidijaf lidijaf closed this as completed Nov 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant