AMPI: Add fsglobals (filesystem) and pipglobals (Process-in-Process) privatization...
[charm.git] / tests / ampi / privatization / Makefile
1 -include ../../common.mk
2 -include ../../../include/conv-mach-opt.mak
3 AMPICC=../../../bin/ampicxx $(OPTS)
4 AMPIF90=../../../bin/ampif90 $(OPTS)
5
6
7 LANGUAGES := \
8   cxx \
9   f90 \
10
11
12 # for constructing individual build rules
13 VARIANTS := \
14   control \
15   swapglobals \
16   tlsglobals \
17   roseomptlsglobals \
18   fsglobals \
19   pipglobals \
20
21
22 # for determining `all`, `test` rules
23 CANDIDATES := \
24   swapglobals \
25   tlsglobals \
26
27 ifeq (1,$(CMK_SUPPORTS_FSGLOBALS))
28   CANDIDATES += fsglobals
29 endif
30 ifeq (1,$(CMK_SUPPORTS_PIPGLOBALS))
31   CANDIDATES += pipglobals
32 endif
33
34
35 # Define what options to pass to charmc for each method.
36 $(foreach i,$(VARIANTS),$(foreach j,$(LANGUAGES),$(eval OPTS_$j_$i := -$i)))
37 OPTS_cxx_control :=
38 OPTS_f90_control :=
39 OPTS_f90_tlsglobals += -fopenmp
40
41 # Define the features that each privatization method supports.
42 FEATURES_cxx_control := migration staticvars sharedlib dynamiclib
43 FEATURES_cxx_swapglobals := migration
44 FEATURES_cxx_tlsglobals := migration staticvars sharedlib
45 FEATURES_cxx_roseomptlsglobals := migration staticvars sharedlib
46 FEATURES_cxx_fsglobals := staticvars
47 FEATURES_cxx_pipglobals := staticvars sharedlib
48
49
50 # Determine which methods to test in the current environment and target.
51 TARGETS :=
52
53 define TEST_TARGET_AVAILABILITY
54   AMPICC_OUTPUT_$1 := $$(shell $$(AMPICC) -print-building-blocks $$(OPTS_cxx_$1) 2>&1)
55   ifeq (,$$(findstring Error:,$$(AMPICC_OUTPUT_$1)))
56     ifeq (,$$(findstring Warning: -$1,$$(AMPICC_OUTPUT_$1)))
57       TARGETS += cxx-$1
58     endif
59   endif
60
61   AMPIF90_OUTPUT_$1 := $$(shell $$(AMPIF90) -print-building-blocks $$(OPTS_f90_$1) 2>&1)
62   ifeq (,$$(findstring Error:,$$(AMPIF90_OUTPUT_$1)))
63     ifeq (,$$(findstring Warning: -$1,$$(AMPIF90_OUTPUT_$1)))
64       TARGETS += f90-$1
65     endif
66   endif
67 endef
68
69 $(foreach i,$(CANDIDATES),$(eval $(call TEST_TARGET_AVAILABILITY,$i)))
70
71
72 EMPTY_MESSAGE := "No privatization methods supported for current AMPI target."
73
74 all: $(foreach i,$(TARGETS),$i)
75 ifeq (,$(TARGETS))
76         @echo $(EMPTY_MESSAGE)
77 endif
78 test: $(foreach i,$(TARGETS),test-$i)
79 ifeq (,$(TARGETS))
80         @echo $(EMPTY_MESSAGE)
81 endif
82
83 everything: $(foreach i,$(VARIANTS),$(foreach j,$(LANGUAGES),$j-$i))
84 test-everything: $(foreach i,$(VARIANTS),$(foreach j,$(LANGUAGES),test-$j-$i))
85
86
87 add_if_contains = $(subst $2,$3,$(findstring $2,$1))
88
89 define VARIANT_RULES
90
91 $1: $$(foreach j,$$(LANGUAGES),$$j-$1)
92
93 # link
94 cxx-$1: $1-test.o $1-test-cxx.o cxx-$1-other-object.o | libcxx-$1-static-library.a $$(call add_if_contains,$$(FEATURES_cxx_$1),sharedlib,libcxx-$1-shared-library.so) $$(call add_if_contains,$$(FEATURES_cxx_$1),dynamiclib,libcxx-$1-shared-library-dynamic.so)
95         $$(AMPICC) -o $$@ $$(OPTS_cxx_$1) $$^ -balancer RotateLB -rpath-origin -L. -lcxx-$1-static-library $$(call add_if_contains,$$(FEATURES_cxx_$1),sharedlib,-lcxx-$1-shared-library) $$(call add_if_contains,$$(FEATURES_cxx_$1),dynamiclib,-ldl)
96
97 f90-$1: $1-test.o $1-test-f90.o
98         $$(AMPIF90) -o $$@ $$(OPTS_f90_$1) $$^ -balancer RotateLB
99
100 libcxx-$1-%.so: cxx-$1-%-so.o
101         $$(AMPICC) -o $$@ $$(OPTS_cxx_$1) -shared -standalone $$<
102
103 libcxx-$1-%.a: cxx-$1-%.o
104         ar cr $$@ $$^
105         ranlib $$@
106
107 $1-%.o cxx-$1-%.o: %.C
108         $$(AMPICC) -o $$@ $$(OPTS_cxx_$1) -Dtest_using_$1 -Dprivatization_method=$1 $$(foreach i,$$(FEATURES_cxx_$1),-Dtest_$$i) -c $$<
109
110 $1-%-so.o cxx-$1-%-so.o: %.C
111         $$(AMPICC) -o $$@ $$(OPTS_cxx_$1) -Dtest_using_$1 -Dprivatization_method=$1 $$(foreach i,$$(FEATURES_cxx_$1),-Dtest_$$i) -shared -c $$<
112
113 $1-%.o f90-$1-%.o: %.f90
114         $$(AMPIF90) -o $$@ $$(OPTS_f90_$1) -c $$<
115
116 # test
117 test-cxx-$1: cxx-$1
118         $$(call run, ./cxx-$1 +p1 +vp2 )
119         $$(call run, ./cxx-$1 +p1 +vp4 )
120         $$(call run, ./cxx-$1 +p2 +vp2 )
121         $$(call run, ./cxx-$1 +p2 +vp4 )
122
123 test-f90-$1: f90-$1
124         $$(call run, ./f90-$1 +p1 +vp2 )
125         $$(call run, ./f90-$1 +p1 +vp4 )
126         $$(call run, ./f90-$1 +p2 +vp2 )
127         $$(call run, ./f90-$1 +p2 +vp4 )
128
129 test-$1: $$(foreach j,$$(LANGUAGES),test-$$j-$1)
130
131 endef
132
133 $(foreach i,$(VARIANTS),$(eval $(call VARIANT_RULES,$i)))
134
135 # overrides
136 tlsglobals-test-f90.o: test-f90-tlsglobals.f90
137         $(AMPIF90) -o $@ $(OPTS_f90_tlsglobals) -c $<
138
139
140 FUNCPTR_SHIM_SUFFIX := .user
141
142 clean:
143         rm -f *.o *.a *.so *.mod $(foreach i,$(VARIANTS),$(foreach j,$(LANGUAGES),$(strip $j-$i $(wildcard $j-$i$(FUNCPTR_SHIM_SUFFIX)*)))) charmrun ampirun
144
145 .SUFFIXES:
146 .PHONY: all test everything test-everything $(foreach i,$(VARIANTS),$(foreach j,$(LANGUAGES),test-$j-$i) test-$i $i)