44from pySDC .helpers .stats_helper import get_sorted
55from pySDC .projects .GPU .configs .base_config import get_config
66from pySDC .projects .GPU .etc .generate_jobscript import write_jobscript , PROJECT_PATH
7- from pySDC .helpers .plot_helper import setup_mpl , figsize_by_journal
8-
9- setup_mpl ()
7+ from pySDC .helpers .plot_helper import figsize_by_journal
108
119
1210class ScalingConfig (object ):
@@ -22,7 +20,6 @@ class ScalingConfig(object):
2220 max_steps_space = None
2321 max_steps_space_weak = None
2422 sbatch_options = []
25- max_nodes = 9999
2623
2724 def __init__ (self , space_time_parallel ):
2825 if space_time_parallel in ['False' , False ]:
@@ -34,30 +31,19 @@ def get_resolution_and_tasks(self, strong, i):
3431 if strong :
3532 return self .base_resolution , [1 , self ._tasks_time , 2 ** i ]
3633 else :
37- return self .base_resolution_weak * int (self ._tasks_time ** (1.0 / self .ndim )) * (2 ** i ), [
38- 1 ,
39- self ._tasks_time ,
40- (2 * self .ndim ) ** i ,
41- ]
34+ return self .base_resolution_weak * (2 ** i ), [1 , self ._tasks_time , (2 * self .ndim ) ** i ]
4235
4336 def run_scaling_test (self , strong = True ):
4437 max_steps = self .max_steps_space if strong else self .max_steps_space_weak
4538 for i in range (max_steps ):
4639 res , procs = self .get_resolution_and_tasks (strong , i )
4740
48- _nodes = np .prod (procs ) // self .tasks_per_node
49- if _nodes > self .max_nodes :
50- break
51-
52- sbatch_options = [
53- f'-n { np .prod (procs )} ' ,
54- f'-p { self .partition } ' ,
55- f'--tasks-per-node={ self .tasks_per_node } ' ,
56- ] + self .sbatch_options
57- srun_options = [f'--tasks-per-node={ self .tasks_per_node } ' ]
41+ sbatch_options = [f'-n { np .prod (procs )} ' , f'-p { self .partition } ' ] + self .sbatch_options
5842 if self .useGPU :
59- srun_options + = ['--cpus-per-task=4' , '--gpus-per-task=1' ]
43+ srun_options = ['--cpus-per-task=4' , '--gpus-per-task=1' ] + self . sbatch_options
6044 sbatch_options += ['--cpus-per-task=4' , '--gpus-per-task=1' ]
45+ else :
46+ srun_options = []
6147
6248 procs = ('' .join (f'{ me } /' for me in procs ))[:- 1 ]
6349 command = f'run_experiment.py --mode=run --res={ res } --config={ self .config } --procs={ procs } '
@@ -67,8 +53,10 @@ def run_scaling_test(self, strong=True):
6753
6854 write_jobscript (sbatch_options , srun_options , command , self .cluster )
6955
70- def plot_scaling_test (self , strong , ax , plot_ideal = False , ** plotting_params ): # pragma: no cover
56+ def plot_scaling_test (self , strong , ax , plot_ideal = False , plot_range = False , ** plotting_params ): # pragma: no cover
7157 timings = {}
58+ max_timings = []
59+ min_timings = []
7260
7361 max_steps = self .max_steps_space if strong else self .max_steps_space_weak
7462 for i in range (max_steps ):
@@ -84,20 +72,27 @@ def plot_scaling_test(self, strong, ax, plot_ideal=False, **plotting_params): #
8472 stats = pickle .load (file )
8573
8674 timing_step = get_sorted (stats , type = 'timing_step' )
87- timings [np .prod (procs ) / self .tasks_per_node ] = np .mean ([me [1 ] for me in timing_step ])
75+
76+ key = np .prod (procs ) / self .tasks_per_node
77+ timings [key ] = np .mean ([me [1 ] for me in timing_step ])
78+ max_timings += [np .max ([me [1 ] for me in timing_step ]) - timings [key ]]
79+ min_timings += [timings [key ] - np .min ([me [1 ] for me in timing_step ])]
8880 except FileNotFoundError :
8981 pass
9082
9183 if plot_ideal :
92- if strong :
93- ax .loglog (
94- timings .keys (),
95- list (timings .values ())[0 ] * list (timings .keys ())[0 ] / np .array (list (timings .keys ())),
96- ls = '--' ,
97- color = 'grey' ,
98- label = 'ideal' ,
99- )
100- ax .loglog (timings .keys (), timings .values (), ** plotting_params )
84+ ax .loglog (
85+ timings .keys (),
86+ list (timings .values ())[0 ] * list (timings .keys ())[0 ] / np .array (list (timings .keys ())),
87+ ls = '--' ,
88+ color = 'grey' ,
89+ label = 'ideal' ,
90+ )
91+ if plot_range :
92+ yerr = [min_timings , max_timings ]
93+ ax .errorbar (timings .keys (), timings .values (), yerr = yerr , ** plotting_params )
94+ else :
95+ ax .loglog (timings .keys (), timings .values (), ** plotting_params )
10196 ax .set_xlabel (r'$N_\mathrm{nodes}$' )
10297 ax .set_ylabel (r'$t_\mathrm{step}$' )
10398
@@ -106,61 +101,108 @@ class CPUConfig(ScalingConfig):
106101 cluster = 'jusuf'
107102 partition = 'batch'
108103 tasks_per_node = 16
109- max_nodes = 144
104+ sbatch_options = [ '--tasks-per-node=16' ]
110105
111106
112107class GPUConfig (ScalingConfig ):
113108 cluster = 'booster'
114109 partition = 'booster'
115110 tasks_per_node = 4
116111 useGPU = True
117- max_nodes = 936
118112
119113
120114class GrayScottSpaceScalingCPU (CPUConfig , ScalingConfig ):
121- base_resolution = 8192
122- base_resolution_weak = 512
115+ base_resolution = 4096
116+ base_resolution_weak = 256
123117 config = 'GS_scaling'
124- max_steps_space = 11
125- max_steps_space_weak = 11
126- tasks_time = 4
127- sbatch_options = ['--time=3:30:00' ]
118+ max_steps_space = 10
119+ max_steps_space_weak = 6
120+ tasks_time = 3
128121
129122
130123class GrayScottSpaceScalingGPU (GPUConfig , ScalingConfig ):
131- base_resolution_weak = 1024
132- base_resolution = 8192
124+ base_resolution_weak = 256 * 2
125+ base_resolution = 4096
133126 config = 'GS_scaling'
134- max_steps_space = 7
135- max_steps_space_weak = 5
127+ max_steps_space = 6
128+ max_steps_space_weak = 4
129+ tasks_time = 3
130+
131+
132+ class RayleighBenardSpaceScalingCPU (CPUConfig , ScalingConfig ):
133+ base_resolution = 1024
134+ base_resolution_weak = 256
135+ config = 'RBC_scaling'
136+ max_steps_space = 10
137+ max_steps_space_weak = 6
138+ tasks_time = 4
139+
140+
141+ class RayleighBenardSpaceScalingGPU (GPUConfig , ScalingConfig ):
142+ base_resolution = 1024
143+ base_resolution_weak = 256 * 2
144+ config = 'RBC_scaling'
145+ max_steps_space = 6
146+ max_steps_space_weak = 4
147+ tasks_time = 4
148+
149+
150+ class RayleighBenardDedalusComparison (CPUConfig , ScalingConfig ):
151+ base_resolution = 256
152+ config = 'RBC_Tibo'
153+ max_steps_space = 6
154+ tasks_time = 4
155+
156+
157+ class RayleighBenardDedalusComparisonGPU (GPUConfig , ScalingConfig ):
158+ base_resolution_weak = 256
159+ base_resolution = 256
160+ config = 'RBC_Tibo'
161+ max_steps_space = 4
162+ max_steps_space_weak = 4
136163 tasks_time = 4
137- max_nodes = 64
138164
139165
140166def plot_scalings (strong , problem , kwargs ): # pragma: no cover
141- if problem == 'GS' :
142- fig , ax = plt .subplots (figsize = figsize_by_journal ('JSC_beamer' , 1 , 0.45 ))
167+ plottings_params = [
168+ {'plot_ideal' : strong , 'marker' : 'x' , 'label' : 'CPU space parallel' },
169+ {'marker' : '>' , 'label' : 'CPU space time parallel' },
170+ {'marker' : '^' , 'label' : 'GPU space parallel' },
171+ {'marker' : 'o' , 'label' : 'GPU space time parallel' },
172+ ]
173+ fig , ax = plt .subplots (figsize = figsize_by_journal ('JSC_beamer' , 1 , 0.45 ))
143174
144- plottings_params = [
145- {'plot_ideal' : True , 'marker' : 'x' , 'label' : 'CPU space parallel' },
146- {'marker' : '>' , 'label' : 'CPU space time parallel' },
147- {'marker' : '^' , 'label' : 'GPU space parallel' },
148- {'marker' : '<' , 'label' : 'GPU space time parallel' },
149- ]
175+ if problem == 'GS' :
150176 configs = [
151177 GrayScottSpaceScalingCPU (space_time_parallel = False ),
152178 GrayScottSpaceScalingCPU (space_time_parallel = True ),
153179 GrayScottSpaceScalingGPU (space_time_parallel = False ),
154180 GrayScottSpaceScalingGPU (space_time_parallel = True ),
155181 ]
182+ elif problem == 'RBC' :
183+ configs = [
184+ RayleighBenardSpaceScalingCPU (space_time_parallel = False ),
185+ RayleighBenardSpaceScalingCPU (space_time_parallel = True ),
186+ RayleighBenardSpaceScalingGPU (space_time_parallel = False ),
187+ RayleighBenardSpaceScalingGPU (space_time_parallel = True ),
188+ ]
189+ elif problem == 'RBC_dedalus' :
190+ configs = [
191+ RayleighBenardDedalusComparison (space_time_parallel = False ),
192+ RayleighBenardDedalusComparison (space_time_parallel = True ),
193+ RayleighBenardDedalusComparisonGPU (space_time_parallel = False ),
194+ RayleighBenardDedalusComparisonGPU (space_time_parallel = True ),
195+ ]
156196
157- for config , params in zip (configs , plottings_params ):
158- config .plot_scaling_test (strong = strong , ax = ax , ** params )
159- ax .legend (frameon = False )
160- fig .savefig (f'{ PROJECT_PATH } /plots/{ "strong" if strong else "weak" } _scaling_{ problem } .pdf' , bbox_inches = 'tight' )
161197 else :
162198 raise NotImplementedError
163199
200+ for config , params in zip (configs , plottings_params ):
201+ config .plot_scaling_test (strong = strong , ax = ax , ** params )
202+ ax .legend (frameon = False )
203+ plt .show ()
204+ fig .savefig (f'{ PROJECT_PATH } /plots/{ "strong" if strong else "weak" } _scaling_{ problem } .pdf' , bbox_inches = 'tight' )
205+
164206
165207if __name__ == '__main__' :
166208 import argparse
@@ -181,6 +223,16 @@ def plot_scalings(strong, problem, kwargs): # pragma: no cover
181223 configClass = GrayScottSpaceScalingCPU
182224 else :
183225 configClass = GrayScottSpaceScalingGPU
226+ elif args .problem == 'RBC' :
227+ if args .XPU == 'CPU' :
228+ configClass = RayleighBenardSpaceScalingCPU
229+ else :
230+ configClass = RayleighBenardSpaceScalingGPU
231+ elif args .problem == 'RBC_dedalus' :
232+ if args .XPU == 'CPU' :
233+ configClass = RayleighBenardDedalusComparison
234+ else :
235+ configClass = RayleighBenardDedalusComparisonGPU
184236 else :
185237 raise NotImplementedError (f'Don\' t know problem { args .problem !r} ' )
186238
0 commit comments