-
Notifications
You must be signed in to change notification settings - Fork 279
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
Fix GCC 5 Builds #2939
Fix GCC 5 Builds #2939
Changes from all commits
17242bd
9e85549
ff5eb22
2cf6649
116f820
688ecc2
09187c1
bd6c0f2
92e25a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import glob | ||
import os | ||
import sys | ||
from collections import defaultdict | ||
from distutils.ccompiler import get_default_compiler | ||
from distutils.version import LooseVersion | ||
|
||
|
@@ -36,20 +37,24 @@ | |
with open("README.md") as file: | ||
long_description = file.read() | ||
|
||
if check_for_openmp(): | ||
omp_args = ["-fopenmp"] | ||
else: | ||
omp_args = [] | ||
CPP14_CONFIG = defaultdict( | ||
lambda: ["-std=c++14"], {"unix": ["-std=c++14"], "msvc": ["/std:c++14"]} | ||
) | ||
CPP03_CONFIG = defaultdict( | ||
lambda: ["-std=c++03"], {"unix": ["-std=c++03"], "msvc": ["/std:c++03"]} | ||
) | ||
|
||
_COMPILER = get_default_compiler() | ||
|
||
omp_args, _ = check_for_openmp() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are distinguishing between compile and link flags inside |
||
|
||
if os.name == "nt": | ||
std_libs = [] | ||
else: | ||
std_libs = ["m"] | ||
|
||
if get_default_compiler() == "msvc": | ||
CPP14_FLAG = ["/std:c++14"] | ||
else: | ||
CPP14_FLAG = ["--std=c++14"] | ||
CPP14_FLAG = CPP14_CONFIG[_COMPILER] | ||
CPP03_FLAG = CPP03_CONFIG[_COMPILER] | ||
|
||
cythonize_aliases = { | ||
"LIB_DIR": "yt/utilities/lib/", | ||
|
@@ -65,6 +70,7 @@ | |
"FIXED_INTERP": "yt/utilities/lib/fixed_interpolator.cpp", | ||
"ARTIO_SOURCE": glob.glob("yt/frontends/artio/artio_headers/*.c"), | ||
"CPP14_FLAG": CPP14_FLAG, | ||
"CPP03_FLAG": CPP03_FLAG, | ||
ax3l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
lib_exts = [ | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,6 @@ | ||||||||||||||||
# distutils: language = c++ | ||||||||||||||||
# distutils: extra_compile_args = CPP14_FLAG | ||||||||||||||||
# distutils: extra_link_args = CPP14_FLAG | ||||||||||||||||
""" | ||||||||||||||||
Field Interpolation Tables | ||||||||||||||||
|
||||||||||||||||
|
@@ -8,12 +11,19 @@ Field Interpolation Tables | |||||||||||||||
|
||||||||||||||||
cimport cython | ||||||||||||||||
cimport numpy as np | ||||||||||||||||
from libc.math cimport isnormal | ||||||||||||||||
from libc.stdlib cimport malloc | ||||||||||||||||
|
||||||||||||||||
from yt.utilities.lib.fp_utils cimport fabs, fclip, fmax, fmin, iclip, imax, imin | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
cdef extern from "<cmath>" namespace "std": | ||||||||||||||||
bint isnormal(double x) nogil | ||||||||||||||||
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: for some reason, Visual Studio doesn't happy about this. However, if we replace by
Suggested change
or
Suggested change
it compiles. |
||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
cdef extern from "platform_dep_math.hpp": | ||||||||||||||||
bint __isnormal(double) nogil | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
cdef struct FieldInterpolationTable: | ||||||||||||||||
# Note that we make an assumption about retaining a reference to values | ||||||||||||||||
# externally. | ||||||||||||||||
|
@@ -58,7 +68,7 @@ cdef inline np.float64_t FIT_get_value(const FieldInterpolationTable *fit, | |||||||||||||||
cdef np.float64_t dd, dout | ||||||||||||||||
cdef int bin_id | ||||||||||||||||
if dvs[fit.field_id] >= fit.bounds[1] or dvs[fit.field_id] <= fit.bounds[0]: return 0.0 | ||||||||||||||||
if not isnormal(dvs[fit.field_id]): return 0.0 | ||||||||||||||||
if not __isnormal(dvs[fit.field_id]): return 0.0 | ||||||||||||||||
bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin) | ||||||||||||||||
bin_id = iclip(bin_id, 0, fit.nbins-2) | ||||||||||||||||
|
||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,4 @@ double erf(double x) | |
#include <stdint.h> | ||
#include "alloca.h" | ||
#include <math.h> | ||
#endif | ||
|
||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
This file provides a compatibility layout between MSVC, and different version of GCC. | ||
|
||
MSVC does not define isnormal in the std:: namespace, so we cannot import it from <cmath>, but from <math.h> instead. | ||
However with GCC-5, there is a clash between the definition of isnormal in <math.h> and using C++14, so we need to import from cmath instead. | ||
*/ | ||
|
||
#if _MSC_VER | ||
#include <math.h> | ||
inline bool __isnormal(double x) { | ||
return isnormal(x); | ||
} | ||
#else | ||
#include <cmath> | ||
inline bool __isnormal(double x) { | ||
return std::isnormal(x); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's used anywhere. At least
git grep
doesn't show anything. If I'm not missing anything, let's not add things that might be used, but are not.