Skip to content

Commit bda49c0

Browse files
committed
Merge branch 'develop'
2 parents 98e896d + c265ccc commit bda49c0

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

pynamic-pyMPI-2.6a1/so_generator.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def generate_c_file(file_prefix_in, my_id, num_functions, call_depth, extern, ut
199199
f.close()
200200

201201
# compile a .c file into a Python-usable .so file
202-
def compile_file(file_prefix, i, num_utility_files, include_dir, CC):
202+
def compile_file(file_prefix, num_module_files, num_utility_files, include_dir, CC):
203203
filename = file_prefix + '.c'
204204
cwd = os.getcwd()
205205
outfile = file_prefix + '.so'
@@ -208,6 +208,9 @@ def compile_file(file_prefix, i, num_utility_files, include_dir, CC):
208208
else:
209209
command = '%s -g -fPIC -shared' %(CC)
210210
if file_prefix.find('module') != -1:
211+
if file_prefix.find('begin') != -1:
212+
for i in range(num_module_files):
213+
command += ' -lmodule' + str(i)
211214
command += ' -I%s' %(include_dir)
212215
command += ' -Wl,-rpath=' + cwd + ' -L' + cwd
213216
for i in range(num_utility_files):
@@ -260,6 +263,7 @@ def barrier(self):
260263
"""
261264
f.write(text)
262265

266+
f.write('import libmodulebegin\n')
263267
for i in range(num_files):
264268
f.write('import libmodule' + str(i) + '\n')
265269
f.write('import libmodulefinal\n')
@@ -274,6 +278,7 @@ def barrier(self):
274278
"""
275279
f.write(text)
276280

281+
f.write('libmodulebegin.begin_break_here()\n')
277282
for i in range(num_files):
278283
f.write('libmodule' + str(i) + '.libmodule' + str(i) + '_entry()\n')
279284
f.write('libmodulefinal.break_here()\n')
@@ -332,7 +337,7 @@ def run_so_generator(num_files, avg_num_functions, call_depth, extern, seed, see
332337
for p,d,f in os.walk('./'):
333338
if p == './':
334339
for file in f:
335-
if (file.find('libmodule') != -1 or file.find('libutility') != -1 or file.find('pynamic.h') != -1) and file.find('libmodulefinal.c') == -1:
340+
if (file.find('libmodule') != -1 or file.find('libutility') != -1 or file.find('pynamic.h') != -1) and file.find('libmodulefinal.c') == -1 and file.find('libmodulebegin.c') == -1:
336341
os.remove(file)
337342

338343
if extern:
@@ -372,6 +377,7 @@ def run_so_generator(num_files, avg_num_functions, call_depth, extern, seed, see
372377
for i in range(num_utility_files):
373378
command = 'ar cru libpynamic.a %s' %(file_prefix+str(i)+'.o')
374379
run_command(command)
380+
pynamic_header_file.write('void initlibmodulebegin();\n')
375381
for i in range(num_files - num_utility_files):
376382
pynamic_header_file.write('void initlibmodule%d();\n' %(i))
377383
pynamic_header_file.write('void initlibmodulefinal();\n')
@@ -390,6 +396,10 @@ def run_so_generator(num_files, avg_num_functions, call_depth, extern, seed, see
390396
command = 'ranlib libpynamic.a'
391397
run_command(command)
392398

399+
compile_file("libmodulebegin", num_files - num_utility_files, 0, include_dir, CC)
400+
command = 'ar cru libpynamic.a libmodulebegin.o'
401+
run_command(command)
402+
393403
f = open("pyMPI_initialize.c", "r")
394404
lines = f.readlines()
395405
f.close()
@@ -399,6 +409,7 @@ def run_so_generator(num_files, avg_num_functions, call_depth, extern, seed, see
399409
if line.find('pyMPI_Macros.h') != -1:
400410
f.write('#include "pynamic.h"\n')
401411
if line.find('PyImport_AppendInittab') != -1:
412+
f.write(' PyImport_AppendInittab("libmodulebegin", initlibmodulebegin);\n')
402413
for i in range(num_files - num_utility_files):
403414
f.write(' PyImport_AppendInittab("libmodule%d", initlibmodule%d);\n' %(i, i))
404415
f.write(' PyImport_AppendInittab("libmodulefinal", initlibmodulefinal);\n')

pynamic.README

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# FILE: pynamic.README
33
#
44
# Updates:
5+
# Feb 26 2018 GLL: Allow parallel builds with -j option
6+
# updated config.guess (to work for ppc64le)
57
# Apr 29 2014 GLL: Renamed pynamic-bigexe to pynamic-bigexe-pyMPI
68
# create pynamic-bigexe-sdb-pyMPI
79
# added libmodulefinal with break_here function
@@ -96,56 +98,62 @@
9698
% cd pynamic-pyMPI-2.6a1
9799
% config_pynamic.py
98100

99-
It will print out options and arguments:
101+
USAGE:
102+
config_pynamic.py <num_files> <avg_num_functions> [options] [-c <configure_options>]
100103

101-
--------------------------------------------------------
102-
USAGE:
103-
config_pynamic.py <num_files> <avg_num_functions> [options] [-c <configure_options>]
104+
<num_files> = total number of shared objects to produce
105+
<avg_num_functions> = average number of functions per shared object
106+
107+
OPTIONS:
104108

105-
<num_files> = total number of shared objects to produce
106-
<avg_num_functions> = average number of functions per shared object
109+
-c <configure_options>
110+
pass the whitespace separated list of <configure_options> to configure
111+
when building pyMPI. All args after -c are sent to configure and not
112+
interpreted by Pynamic
107113

108-
OPTIONS:
114+
-b
115+
generate the pynamic-bigexe-pyMPI and pynamic-bigexe-sdb-pyMPI executables
109116

110-
-c <configure_options>
111-
pass the whitespace separated list of <configure_options> to configure
112-
when building pyMPI. All args after -c are sent to configure and not
113-
interpreted by Pynamic
117+
-d <call_depth>
118+
maximum Pynamic call stack depth, default = 10
114119

115-
-b
116-
generate the pynamic-bigexe-pyMPI and pynamic-bigexe-sdb-pyMPI executables
120+
-e
121+
enables external functions to call across modules
117122

118-
-d <call_depth>
119-
maximum Pynamic call stack depth, default = 10
123+
-i <python_include_dir>
124+
add <python_include_dir> when compiling modules
120125

121-
-e
122-
enables external functions to call across modules
126+
-j <num_processes>
127+
build in parallel with a max of <num_processes> processes
123128

124-
-i <python_include_dir>
125-
add <python_include_dir> when compiling modules
129+
-n <length>
130+
add <length> characters to the function names
126131

127-
-n <length>
128-
add <length> characters to the function names
132+
-p
133+
add a print statement to every generated function
129134

130-
-p
131-
add a print statement to every generated function
135+
-s <random_seed>
136+
seed to the random number generator
132137

133-
-s <random_seed>
134-
seed to the random number generator
138+
-u <num_utility_mods> <avg_num_u_functions>
139+
create <num_utility_mods> math library-like utility modules
140+
with an average of <avg_num_u_functions> functions
141+
NOTE: Number of python modules = <num_files> - <avg_num_u_functions>
135142

136-
-u <num_utility_mods> <avg_num_u_functions>
137-
create <num_utility_mods> math library-like utility modules
138-
with an average of <avg_num_u_functions> functions
139-
NOTE: Number of python modules = <num_files> - <avg_num_u_functions>
143+
--with-cc=<command>
144+
use the C compiler located at <command> to build Pynamic modules.
145+
146+
--with-python=<command>
147+
use the python located at <command> to build Pynamic modules. Will
148+
also be passed to the pyMPI configure script.
140149

141-
--with-cc=<command>
142-
use the C compiler located at <command> to build Pynamic modules.
143150

144-
--with-python=<command>
145-
use the python located at <command> to build Pynamic modules. Will
146-
also be passed to the pyMPI configure script.
147151
--------------------------------------------------------
148152

153+
Building a large number of shared objects may take a long time, in
154+
which case it is advised to compiler those files in parallel using
155+
the -j option, setting the value to the number of cores on the node.
156+
149157
Options and arguments are provided so that a tester can model certain
150158
static properties of a Python-based scientific applications.
151159
For example, if the tester wants to model a code that has

0 commit comments

Comments
 (0)