@@ -27,61 +27,65 @@ grow over time. Please submit bug reports and feature requests via our [Issues]
27
27
The "caf" script liberates the source code and workflow from explicit dependence on the
28
28
underlying compiler and communication library in the following ways:
29
29
30
- 1 . "caf" automatically embeds the relevant library path (e.g., libcaf_mpi.a) in the compile command.
31
- 2 . With a non-CAF compiler (including gfortran 4.9), "caf" supports a subset of CAF by replacing
32
- CAF statements with calls to procedures in the [ opencoarrays] module.
33
- 3 . With non-CAF compilers and non-gfortran CAF compilers, "caf" includes in the compile statement
34
- the .mod file that the CMake scripts install in the "mod" suddierctory of the installation path.
35
- This enables uers to access OpenCoarrays capabilities via use association (i.e. "use opencoarrays").
36
- To avoid inadvertent procedure name overloading with non-gfortra CAF compilers, we recommend using
37
- statements of the form "use opencoarrays, only : co_reduce" to reduce the number name classes.
38
- 4 . With a non-gfortran CAF compiler (e.g., Cray and Intel), "caf" extends the compiler's capabilities
39
- by providing features that are proposed for Fortran 2015 in the draft Technical Specification
40
- [ TS18508 Additional Parallel Features in Fortran] .
30
+ 1 . With an OpenCoarrays-aware (OCA) CAF compiler, the "caf" script passes the unmodified
31
+ source code to the underlying compiler with the necessary arguments for building a
32
+ CAF program, embedding the paths to OpenCoarrays libraries (e.g., libcaf_mpi.a) installed
33
+ in the "lib" subdirectory of the OpenCoarrays installation path. The "caf" script also
34
+ embeds the path to the relevant module file in the "mod" subdirectory of the installation
35
+ path (e.g., opencoarrays.mod). This supports use association with module entities via
36
+ `` use opencoarrays `` .
37
+ 2 . With a non-CAF compiler (including gfortran 4.9), "caf" supports a subset of CAF by
38
+ replacing CAF statements with calls to procedures in the [ opencoarrays module] before
39
+ passing the source code to the compiler.
40
+
41
+ When using GCC 4.9, we recommend using the ` use ` statement's "only" clause to
42
+ avoid inadvertent procedure name clashes between OpenCoarrays procedures and their
43
+ GCC counerparts. For example, use "use opencoarrays, only : co_reduce".
44
+
45
+ With a non-OCA and OCA CAF compilers, the extensions that "caf" imports include the collective
46
+ subroutines proposed for Fortran 2015 in the draft Technical Specification [ TS 18508]
47
+ _ Additional Parallel Features in Fortran_ .
41
48
42
49
The latter use case provides an opportunity to mix a compiler's CAF support with that of OpenCoarrays.
43
- For example, a non-gfortran CAF compiler might support all of a program's coarray square-bracket syntax,
44
- while OpenCoarrays supports the same program's calls to collective subrouine such as co_sum and co_reduce.
50
+ For example, a non-OCA CAF compiler, such as the Cray or Intel compilers, might support all of a
51
+ program's coarray square-bracket syntax, while OpenCoarrays supports the same program's calls to
52
+ collective subroutine such as ` co_sum ` and ` co_reduce ` .
45
53
46
54
<a name =" a-sample-basic-workflow " >
47
55
### A sample basic workflow ###
48
56
</a >
49
57
58
+ ## Compiling and Running with an OpenCoarrays-aware (OCA) CAF Compiler</a > ##
59
+
50
60
Inserting the "bin" directory of the chosen installation path into the user's PATH enables the following
51
61
CAF program compilation and execution workflow:
52
62
53
- $ cat sum_image_numbers.f90
54
- program main
55
- use iso_c_binding, only : c_int
56
- use iso_fortran_env, only : error_unit
57
- implicit none
58
- integer(c_int) :: tally
59
- tally = this_image() ! this image's contribution
60
- call co_sum(tally)
61
- verify: block
62
- integer(c_int) :: image
63
- if (tally/=[(image,image=1,num_images())]) then
64
- write(error_unit,'(a,i5)') "Incorrect tally on image ",this_image()
65
- error stop
66
- end if
67
- end block verify
68
- ! Wait for all images to pass the test
69
- sync all
70
- if (this_image()==1) print *,"Test passed"
71
- end program
72
-
73
- ```
74
- $ caf sum_image_numbers.f90
75
- $ caf sum_image_numbers.f90
76
- $ cafrun -np 4 ./sum_image_numbers
77
- Test passed.
78
- ```
79
- where "4" is the number of images to be launched at program start-up.
63
+ $ cat tally.f90
64
+ program main
65
+ use iso_c_binding, only : c_int
66
+ use iso_fortran_env, only : error_unit
67
+ implicit none
68
+ integer(c_int) :: tally
69
+ tally = this_image() ! this image's contribution
70
+ call co_sum(tally)
71
+ verify: block
72
+ integer(c_int) :: image
73
+ if (tally/=sum([(image,image=1,num_images())])) then
74
+ write(error_unit,'(a,i5)') "Incorrect tally on image ",this_image()
75
+ error stop
76
+ end if
77
+ end block verify
78
+ ! Wait for all images to pass the test
79
+ sync all
80
+ if (this_image()==1) print *,"Test passed"
81
+ end program
82
+ $ caf tally.f90 -o tally
83
+ $ cafrun -np 4 ./tally
84
+ Test passed
80
85
81
- <a name =" sample-advanced-workflow " >
82
- ### Sample advanced workflows</a > ###
86
+ where "4" is the number of images to be launched at program start-up.
83
87
84
- <a name="Extending a non-OCA CAF COmpiler
88
+ <a name="extending-a- non-oca- CAF-compiler"
85
89
## Extending a Non-OCA CAF Compiler</a > ##
86
90
87
91
To extend the capabilities of a non-OCA CAF compiler (e.g., the Intel or Cray compilers)
@@ -93,24 +97,23 @@ in the above example:
93
97
94
98
Then compile with the "caf" compiler wrapper and launch with "cafrun" program launcher.
95
99
96
- <a name =" compiling-without-caf " >
97
- ## Sample Advanced Workflow </a > ##
100
+ <a name =" sample-advanced-workflow " >
101
+ ### A sample advanced workflows </a > # ##
98
102
99
103
If the "caf" compiler wrapper cannot process the source code in question, invoke
100
104
the underlying communication library directly:
101
105
102
- mpif90 -fcoarray=lib -L/opt/opencoarrays/ hello .f90 \ -lcaf_mpi -o hello -I<OpenCoarrays-install-path>/mod
106
+ mpif90 -fcoarray=lib -L/opt/opencoarrays/ tally .f90 \ -lcaf_mpi -o htally -I<OpenCoarrays-install-path>/mod
103
107
104
108
and also run the program with the lower-level commnication library:
105
109
106
- mpirun -np <number-of-images> ./hello
107
-
110
+ mpirun -np <number-of-images> ./tally
108
111
109
112
110
113
[ Sourcery Store ] : http://www.sourceryinstitute.org/store
111
114
[ Virtualbox ] : http://www.virtualbox.org
112
115
[ Issues ] : https://github.com/sourceryinstitute/opencoarrays/issues
113
- [ opencoarrays ] : ./src/extensions/opencoarrays.F90
116
+ [ opencoarrays module ] : ./src/extensions/opencoarrays.F90
114
117
[ GCC ] : http://gcc.gnu.org
115
118
[ TS18508 Additional Parallel Features in Fortran ] : http://isotc.iso.org/livelink/livelink?func=ll&objId=17181227&objAction=Open
116
119
[ The caf compiler wrapper ] : #the-caf-compiler-wrapper
0 commit comments