CNES / aviso-fes

FES is the last version of the FES (Finite Element Solution) tide model.
https://cnes.github.io/aviso-fes
BSD 3-Clause "New" or "Revised" License
59 stars 24 forks source link

Speeding up libfes: Is libfes thread-safe? #5

Closed ezaron closed 2 years ago

ezaron commented 2 years ago

Hi Frederic:

Do you think libfes can be called from multiple threads in the same program? I have to speed it up, and I am considering to use openmp-enabled threading. My plan is to call fes_new to get a unique handle for each thread. Do you expect this will work?

I don't have much experience with C-language coding, so I tried to write a Julia-language wrapper for libfes. I encountered a rather opaque error, though, "ReadOnlyMemoryError". Do you have much experience with Julia? I wonder if you would consider writing a short example to demonstrate calling libfes from Julia.

-Ed

ezaron commented 2 years ago

Thanks very much! One last question: I am not terribly proficient with cmake. How would I control the compilation flags for libfes? Specifically, I would like to build the library with "-O3 -march=native".

fbriol commented 2 years ago

Be aware the library is not thread-safe. It was written a long time ago and optimized to handle altimeter tracks. At that time it was not necessary to make parallel calculations.

For SWOT we have developed another module in C++ which is multi-threaded. I'll look at what can be done or taken from this module. I will keep you informed.

For CMAKE in the chapter Building & Installing of the file INSTALL.md you have the list of options that you can provide to configure CMAKE. In your case, you have to write:

cmake .. -DBUILD_SHARED_LIBS =on -DCMAKE_CXX_FLAGS="-O3 -march=native"

ezaron commented 2 years ago

Thank you.

fbriol commented 2 years ago

You can find in this GitHub repository, a version of the FES prediction code written entirely in Julia (my first Julia Project) and compatible with its multi-threaded mode. I have taken all the test cases from the C library to make sure that the prediction is correct. I tested the code with the FES2014 grids. I didn't do any performance testing. Let me know if it works better than the C code. On this page, I have added a usage example and the configuration for FES2014.