Skip to content

Commit

Permalink
Fix openmp detection on setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Dec 19, 2014
1 parent 8d811e5 commit 0781f6a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions setup.py
Expand Up @@ -68,13 +68,15 @@ def check_for_openmp():
filename = r'test.c'
file = open(filename, 'wt', 1)
file.write(
"#include <omp.h>\n"
"#include <stdio.h>\n"
"int main() {\n"
"#pragma omp parallel\n"
"printf(\"Hello from thread %d, nthreads %d\\n\","
"omp_get_thread_num(), omp_get_num_threads());\n"
"}"
"""
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d",
omp_get_thread_num(), omp_get_num_threads());
}
"""
)
with open(os.devnull, 'w') as fnull:
exit_code = subprocess.call([compiler, '-fopenmp', filename],
Expand Down Expand Up @@ -110,18 +112,21 @@ def check_for_openmp():
"MurmurHash3"])

EXTRA_COMPILE_ARGS = ['-O3', ]
EXTRA_LINK_ARGS = []

if sys.platform == 'darwin':
# force 64bit only builds
EXTRA_COMPILE_ARGS.extend(['-arch', 'x86_64'])

if check_for_openmp():
EXTRA_COMPILE_ARGS.extend(['-fopenmp'])
EXTRA_LINK_ARGS.extend(['-fopenmp'])

EXTENSION_MOD_DICT = \
{
"sources": SOURCES,
"extra_compile_args": EXTRA_COMPILE_ARGS,
"extra_link_args": EXTRA_LINK_ARGS,
"depends": BUILD_DEPENDS,
"language": "c++",
"define_macros": [("VERSION", versioneer.get_version()), ],
Expand Down

1 comment on commit 0781f6a

@mr-c
Copy link
Contributor

@mr-c mr-c commented on 0781f6a Dec 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really appreciate that you are including this.

Please sign in to comment.