Skip to content

Commit 13c6da2

Browse files
authored
Merge pull request #47 from score-p/issue-46
Fixes #46 . OPARI defines his own `.opari2_init.c`. Unfortunately, it does not allow an as easy usage as `scorep-config`. However, adding the required definitions manually seems to work.
2 parents d403351 + 522eeb4 commit 13c6da2

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

scorep/helper.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ def add_to_ld_library_path(path):
5252
":" + os.environ["LD_LIBRARY_PATH"]
5353

5454

55-
def generate_ld_preload(scorep_config):
56-
"""
57-
This functions generate a string that needs to be passed to $LD_PRELOAD.
58-
After this sting is passed, the tracing needs to be restarted with this $LD_PRELOAD in env.
59-
60-
@return ld_preload string which needs to be passed to LD_PRELOAD
61-
"""
62-
63-
(_, preload, _) = call(["scorep-config"] +
64-
scorep_config + ["--user", "--preload-libs"])
65-
return preload
66-
67-
6855
def generate_compile_deps(config=[]):
6956
"""
7057
Generates the data needed for compilation.

scorep/subsystem.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import scorep.helper
88

99

10-
def gen_subsystem_lib_name():
10+
def generate_subsystem_lib_name():
1111
"""
1212
generate the name for the subsystem lib.
1313
"""
@@ -16,6 +16,19 @@ def gen_subsystem_lib_name():
1616
return mpi_lib_name
1717

1818

19+
def generate_ld_preload(scorep_config):
20+
"""
21+
This functions generate a string that needs to be passed to $LD_PRELOAD.
22+
After this sting is passed, the tracing needs to be restarted with this $LD_PRELOAD in env.
23+
24+
@return ld_preload string which needs to be passed to LD_PRELOAD
25+
"""
26+
27+
(_, preload, _) = scorep.helper.call(
28+
["scorep-config"] + scorep_config + ["--user", "--preload-libs"])
29+
return preload
30+
31+
1932
def generate_subsystem_code(config=[]):
2033
"""
2134
Generates the data needed to be preloaded.
@@ -45,6 +58,13 @@ def generate(scorep_config, keep_files=False):
4558
(include, lib, lib_dir, macro,
4659
linker_flags_tmp) = scorep.helper.generate_compile_deps(scorep_config)
4760
scorep_adapter_init = generate_subsystem_code(scorep_config)
61+
if ("-lscorep_adapter_opari2_mgmt" in lib):
62+
scorep_adapter_init += "\n"
63+
scorep_adapter_init += "/* OPARI dependencies */\n"
64+
scorep_adapter_init += "void POMP2_Init_regions(){}\n"
65+
scorep_adapter_init += "size_t POMP2_Get_num_regions(){return 0;};\n"
66+
scorep_adapter_init += "void POMP2_USER_Init_regions(){};\n"
67+
scorep_adapter_init += "size_t POMP2_USER_Get_num_regions(){return 0;};\n"
4868

4969
# add -Wl,-no-as-needed to tell the compiler that we really want to link these. Actually this sould be default.
5070
# as distutils adds extra args at the very end we need to add all the libs
@@ -62,7 +82,7 @@ def generate(scorep_config, keep_files=False):
6282
with open(temp_dir + "/scorep_init.c", "w") as f:
6383
f.write(scorep_adapter_init)
6484

65-
subsystem_lib_name = gen_subsystem_lib_name()
85+
subsystem_lib_name = generate_subsystem_lib_name()
6686

6787
cc = distutils.ccompiler.new_compiler()
6888
compiled_subsystem = cc.compile(
@@ -97,7 +117,7 @@ def init_environment(scorep_config=[], keep_files=False):
97117

98118
subsystem_lib_name, temp_dir = scorep.subsystem.generate(
99119
scorep_config, keep_files)
100-
scorep_ld_preload = scorep.helper.generate_ld_preload(scorep_config)
120+
scorep_ld_preload = generate_ld_preload(scorep_config)
101121

102122
scorep.helper.add_to_ld_library_path(temp_dir)
103123

0 commit comments

Comments
 (0)