Skip to content

Conversation

rouson
Copy link
Collaborator

@rouson rouson commented Sep 28, 2025

This PR includes the commit(s) from PR #234. The current PR edits the README.md file to include instructions for parallel runs of neural-fortran with the LLVM flang-new compiler and the Caffeine parallel runtime library.

fixes modern-fortran#233

Pure functions get_activation_by_name and get_optimizer_by_name
construct polymorphic function results.  Removing `pure` enables
building with the LLVM flang-new compiler.

Although Fortran 2003 allowed pure functions with allocatable
polymorphic results, subsequent standards disallowed such functions.
Using this Fortran 2003 feature blocks building with the LLVM and NAG
compilers and likely will block building with future versions of
gfortran once GCC issue 78640 has been fixed.  (See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78640.)

TODO: A subsequent error still blocks building with NAG, which this
commit does not address.
This commit adds instructions for building and running
neural-fortran (specifcally the test suite) using the experimental
multi-image capabilities of LLVM flang 22 + the Caffeine parallel
runtime library as an alternative to gfortran + OpenCoarrays.
@rouson rouson requested a review from milancurcic September 28, 2025 20:52
@rouson
Copy link
Collaborator Author

rouson commented Sep 28, 2025

On macOS with Caffeine and its GASNet prerequisite installed in .local/lib, the command below launches the neural-fortran test suite with two executing images and it appears that 2 of 27 tests fail so I'm marking this PR as "Draft". The two failure messages are incorrect updated weights.. failedandtest_linear2d_layer: One or more tests failed.`, each of which prints twice -- presumably indicating failure on both images.

GASNET_PSHM_NODES=2 \
  fpm test \ 
  --compiler flang-new \
  --flag "-O3 -fcoarray -DPARALLEL" \
  --link-flag "-lcaffeine -lgasnet-smp-seq -L~/.local/lib"
Project is up to date
test_dense_layer: All tests passed.
test_dense_layer: All tests passed.
test_optimizers: All tests passed.
test_optimizers: All tests passed.
test_multihead_attention_layer: All tests passed.
test_multihead_attention_layer: All tests passed.
test_input1d_layer: All tests passed.
test_input1d_layer: All tests passed.
test_parametric_activation: All tests passed.
test_parametric_activation: All tests passed.
test_conv2d_layer: All tests passed.
test_conv2d_layer: All tests passed.
test_maxpool2d_layer: All tests passed.
test_maxpool2d_layer: All tests passed.
test_dropout_layer: All tests passed.
test_dropout_layer: All tests passed.
test_input3d_layer: All tests passed.
test_input3d_layer: All tests passed.
test_flatten_layer: All tests passed.
test_flatten_layer: All tests passed.
test_reshape_layer: All tests passed.
test_reshape_layer: All tests passed.
test_conv2d_network: All tests passed.
test_conv2d_network: All tests passed.
test_reshape2d_layer: All tests passed.
test_reshape2d_layer: All tests passed.
test_metrics: All tests passed.
test_metrics: All tests passed.
test_loss: All tests passed.
test_loss: All tests passed.
incorrect updated weights.. failed
incorrect updated weights.. failed
test_linear2d_layer: One or more tests failed.
test_linear2d_layer: One or more tests failed.
Fortran STOPFortran STOP: code 1
: code 1


IEEE arithmetic exceptions signaled:IEEE arithmetic exceptions signaled: INEXACT INEXACT

test_conv1d_network: All tests passed.
test_conv1d_network: All tests passed.
test_layernorm_layer: All tests passed.
test_layernorm_layer: All tests passed.
test_locally_connected2d_layer: All tests passed.
test_locally_connected2d_layer: All tests passed.
test_get_set_network_params: All tests passed.
test_get_set_network_params: All tests passed.
test_embedding_layer: All tests passed.
test_embedding_layer: All tests passed.
test_conv1d_layer: All tests passed.
test_conv1d_layer: All tests passed.
test_maxpool1d_layer: All tests passed.
test_maxpool1d_layer: All tests passed.
test_dense_network: All tests passed.
test_dense_network: All tests passed.
test_insert_flatten: All tests passed.
test_insert_flatten: All tests passed.
test_input2d_layer: All tests passed.
test_input2d_layer: All tests passed.

@milancurcic
Copy link
Member

We can look into it but my bet is it's nothing to do with parallel stuff; the test itself may be not portable to flang, it came in after I played with flang last.

@rouson
Copy link
Collaborator Author

rouson commented Sep 29, 2025

@milancurcic correct: a single-image run fails with flang/Caffeine so I agree it's a porting issue.

See all papers that cite it
[here](https://scholar.google.com/scholar?cites=7315840714744905948).

https://github.com/BerkeleyLab/julienne/blob/e9f7ea8069206bfc4abf6a9e6dbbd7d07bda075a/doc/parallel-testing-with-flang.md
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to put this here? It seems out of context

@rouson rouson marked this pull request as draft September 29, 2025 18:28
@rouson rouson mentioned this pull request Sep 29, 2025
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