Skip to content

Conversation

@ViralBShah
Copy link
Member

Julia native Amos implementation. Passes all tests and should be as fast as the fortran implementation.

@KristofferC
Copy link
Member

Perhaps the script that did the conversion should be committed as well? Not sure how much it matters but perhaps @inbounds could be used in the loops? How is the compilation time for these longish functions?

@ViralBShah
Copy link
Member Author

ViralBShah commented Sep 10, 2017

The script no longer works. It is julia 0.3, I think. I had to edit a couple of small things in the generated code. The script and the original fortran and julia codes are on the f-jl-translated branch in this repo.

Compile times are pretty ok. I think it adds maybe 5 seconds to Pkg.test.

@ViralBShah
Copy link
Member Author

There isn't much in the way of array access here, and given that the time matches the fortran times, I suspect not much is to be gained from @inbounds.

ZP::Float64 = zero(Float64)
ZSQ::Float64 = zero(Float64)
begin
GLN[Int32(1)] = 0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be moved outside the function.

@staticfloat
Copy link
Contributor

staticfloat commented Sep 10, 2017

This is pretty unreadable stuff. Is there any hope of maintaining or understanding this if we import undocumented, autotranslated code like this?

@staticfloat
Copy link
Contributor

To be clear, I like the idea of native Julia implementations of these kinds of things, but I fear we're really going to shoot ourself in the foot here in the long run by losing all the comments and knowledge embedded in the existing Amos codebase. I argue the Fortran code of e.g. zbesi is much more readable than the equivalent Julia code in this PR.

@ViralBShah
Copy link
Member Author

I think it is about as unreadable as the original fortran code. The library has not changed in ages, so there is no upstream benefit.

@ViralBShah
Copy link
Member Author

ViralBShah commented Sep 10, 2017

We could insert URLs in the auto-translated code to the original fortran codebase. I would say that this julia translation has received more eyeballs already than the original fortran code (in context of those of us maintaining this).

@staticfloat
Copy link
Contributor

If we could maintain the original comments, I think that would be enough to give us a hope of maintaining/debugging this. How did you generate this?

@ViralBShah
Copy link
Member Author

ViralBShah commented Sep 10, 2017

This was already pre-generated by @nolta - See my comments above. Getting the comments in would mean updating the parser code. Extracting the top level comments and sticking those in should be easy with some script. But, if we want to retain all the inline comments as well, that may need to get the original parser code working again - perhaps in an older version of Julia. That may be non-trivial effort.

@simonbyrne
Copy link
Member

simonbyrne commented Sep 12, 2017

I agree that the comments are probably necessary for this to be maintainable.

It would also be nice if we could replace some of the @gotos with if/else and for/while loops, similar to what emscripten does: https://github.com/kripken/emscripten/blob/master/docs/paper.pdf

@ViralBShah
Copy link
Member Author

I am happy to try and get the comments in. I don't think I want to muck too much further about the @gotos though.

If there is general agreement about merging this with comments, I would do it. But I don't wish to spend much more time than that.

@KristofferC
Copy link
Member

Why not just see this as a "compiled" version without any hope maintaining it i.e the code is the Fortran code and this is the compilation target?

@staticfloat
Copy link
Contributor

staticfloat commented Sep 12, 2017 via email

@ViralBShah
Copy link
Member Author

ViralBShah commented Sep 12, 2017

There has been no change to the fortran code in years. I am not sure I understand why we want to hang on to it. In case we want to change the fortran code, we can directly edit the julia code going forward.

In any case, I don't think that openspecfun is a good library to have. It is an accidental library with stuff we have stuck in that did not have a good natural place otherwise. There is very little chance it will receive any meaningful contributions. Perhaps it doesn't need it.

However, I do see that people are not very comfortable with this direction, and I will drop this effort.

@ViralBShah ViralBShah closed this Sep 12, 2017
@simonbyrne
Copy link
Member

I still think we should do the translation, just that it should be maintainable (which I acknowledge is probably more work than is possible at the moment).

@ararslan
Copy link
Member

Let's keep this native-amos branch around and we can always revisit this later. Thanks for the effort here, Viral. This will be a good starting point whenever this is picked up again.

A good GSoC project for next year might be to reimplement these algorithms (and perhaps Faddeeva as well) natively in Julia, as was done this year with rem2pi.

@ViralBShah
Copy link
Member Author

Yes, if we want a maintainable Julia code, we should write Julian implementations, rather than tweaking the code translator here. Agree could be a good GSoC project.

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.

7 participants