Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

determine the compiler by scorep #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ Then simply run
```
pip install .
```

## Using non default Compilers

Usually, Python uses the compiler provided by `cc`. For the initialisation of the subsystem, the compiler is determined by calling Score-P. However, there is no way I am aware of to force the compiler during installation, expect by specifying the `CC` environment variable.

So if you are planning to use non-default Compiler like Intel, please install the bindings using:

```
CC=`scorep-config --cc` CXX=`scorep-config --cxx` pip install .
```


# Use

To trace the full script you need to run
Expand Down
4 changes: 3 additions & 1 deletion scorep/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def generate_compile_deps(config=[]):
(_, libs, _) = call(scorep_config + ["--libs"])
(_, mgmt_libs, _) = call(scorep_config + ["--mgmt-libs"])
(_, cflags, _) = call(scorep_config + ["--cflags"])
(_, cc, _) = call(scorep_config + ["--cc"])
(_, cxx, _) = call(scorep_config + ["--cxx"])

libs = " " + libs + " " + mgmt_libs
ldflags = " " + ldflags
Expand All @@ -104,4 +106,4 @@ def remove_space1(x): return x[1:]

macro = list(map(lambda x: tuple([x, 1]), macro))

return (include, lib, lib_dir, macro, linker_flags)
return (include, lib, lib_dir, macro, linker_flags, cc, cxx)
12 changes: 8 additions & 4 deletions scorep/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate(scorep_config, keep_files=False):
"""

(include, lib, lib_dir, macro,
linker_flags_tmp) = scorep.helper.generate_compile_deps(scorep_config)
linker_flags_tmp, cc, cxx) = scorep.helper.generate_compile_deps(scorep_config)
scorep_adapter_init = generate_subsystem_code(scorep_config)

# add -Wl,-no-as-needed to tell the compiler that we really want to link these. Actually this sould be default.
Expand All @@ -67,10 +67,13 @@ def generate(scorep_config, keep_files=False):

subsystem_lib_name = gen_subsystem_lib_name()

cc = distutils.ccompiler.new_compiler()
compiled_subsystem = cc.compile(
compiler = distutils.ccompiler.new_compiler()

# distutils UnixCCompiler as of python 3.7 simply doens not care about compiler, thats why we need to set compiler_so.
compiler.set_executables(compiler=cc, compiler_cxx=cxx, compiler_so=cc)
compiled_subsystem = compiler.compile(
[temp_dir + "/scorep_init.c"], output_dir=temp_dir)
cc.link(
compiler.link(
"scorep_init_mpi",
objects=compiled_subsystem,
output_filename=subsystem_lib_name,
Expand All @@ -93,3 +96,4 @@ def clean_up(keep_files=True):
else:
if ("SCOREP_PYTHON_BINDINGS_TEMP_DIR" in os.environ) and (os.environ["SCOREP_PYTHON_BINDINGS_TEMP_DIR"] != ""):
shutil.rmtree(os.environ["SCOREP_PYTHON_BINDINGS_TEMP_DIR"])

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup, Extension
import scorep.helper

(include, lib, lib_dir, macro, linker_flags) = scorep.helper.generate_compile_deps()
(include, lib, lib_dir, macro, linker_flags, cc, cxx) = scorep.helper.generate_compile_deps()


cmodules = []
Expand All @@ -14,7 +14,7 @@

setup(
name='scorep',
version='1.0',
version='1.2',
description='This is a scorep tracing package for python',
author='Andreas Gocht',
author_email='[email protected]',
Expand Down