Skip to content

vmagnin/coarray_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A Buddhabrot computed with co_sum() and saved in a PPM file

For the moment, this repository contains only one example (but you may also be interested by exploring_coarrays).

ppm_coarray_buddhabrot.f90 is a CLI program drawing a Buddhabrot in a portable pixmap binary format (PPM) file, a very basic uncompressed image file format. Each Fortran image is computing its own Buddhabrot, and they are finally summed using the co_sum() collective subroutine. The process is therefore very similar to what is done in astrophotography.

Compiling and executing

GFortran>=16.0

Starting from version 16, GFortran supports natively coarrays using shared memory mulithreading on single node machines:

$ gfortran -Ofast -march=native -mtune=native -fcoarray=lib ppm_coarray_buddhabrot.f90 -lcaf_shmem && ./a.out

You can force the number of images (8 for example) with:

$ export GFORTRAN_NUM_IMAGES=8

The -lcaf_shmem is necessary until a -fcoarray=shared option is added in a later GFortran release.

GFortran<16

You needed to install OpenCoarrays and type that command (8 images here):

$ caf -Ofast -march=native -mtune=native ppm_coarray_buddhabrot.f90 && cafrun -n 8 ./a.out

Intel ifx

$ ifx -Ofast -coarray ppm_coarray_buddhabrot.f90 && ./a.out

The number of images can be set with the option -coarray-num-images=8.

Flang

Flang 22.1 offers an experimental support for coarrays with the option -fcoarray.

TODO

  • The loop computing z(k) could be stopped by exit when we escape the computing window containing the whole Mandelbrot set.
  • We could use the symmetry of the Buddhabrot to improve computing.
  • We could add colours instead of grey levels.

License

Distributed under the MIT license.

References

About

Modern Fortran examples using parallel features like coarrays, collective subroutines, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors