Skip to content

Commit 1f2070b

Browse files
slight changes to PYFFTW_AVAILABLE mechanics
1 parent 412a8c0 commit 1f2070b

File tree

5 files changed

+41
-37
lines changed

5 files changed

+41
-37
lines changed

choreo/cython/_NBodySyst.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ try:
6868
except:
6969
MKL_FFT_AVAILABLE = False
7070

71-
from choreo.cython.optional_pyfftw cimport pyfftw, PYFFTW_AVAILABLE
72-
from choreo.cython.optional_pyfftw import p_pyfftw
71+
from choreo.cython.optional_pyfftw cimport pyfftw
72+
from choreo.cython.optional_pyfftw import p_pyfftw, PYFFTW_AVAILABLE
7373

7474
cdef int USE_SCIPY_FFT = 0
7575
cdef int USE_MKL_FFT = 1
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cimport choreo.cython.pyfftw_fake as pyfftw
22
import choreo.cython.pyfftw_fake as p_pyfftw
3-
cdef bint PYFFTW_AVAILABLE = False
3+
PYFFTW_AVAILABLE = False
4+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
cimport pyfftw
22
import pyfftw as p_pyfftw
3-
cdef bint PYFFTW_AVAILABLE = True
3+
PYFFTW_AVAILABLE = False

choreo/find_new.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import choreo.scipy_plus
1717
from choreo.cython._ActionSym import ActionSym
1818

19+
import warnings
20+
from choreo.cython.optional_pyfftw import PYFFTW_AVAILABLE
21+
if PYFFTW_AVAILABLE:
22+
import pyfftw
23+
1924
def Find_Choreo(
2025
*,
2126
geodim,
@@ -925,15 +930,15 @@ def Check_Duplicates(NBS, segmpos, params, hash_dict, action_dict, store_folder,
925930

926931
return False, None
927932

928-
try:
929-
import pyfftw
933+
def wisdom_filename_divide(filename):
934+
root, ext = os.path.splitext(filename)
935+
return [root+"_"+prec+ext for prec in ['d','f','l']]
930936

931-
def wisdom_filename_divide(filename):
932-
root, ext = os.path.splitext(filename)
933-
return [root+"_"+prec+ext for prec in ['d','f','l']]
934-
935-
def Load_wisdom_file(DP_Wisdom_file):
936-
937+
def Load_wisdom_file(DP_Wisdom_file):
938+
939+
if not(PYFFTW_AVAILABLE):
940+
warnings.warn("The package pyfftw could not be loaded. Please check your local install.")
941+
else:
937942
wis_list = []
938943

939944
for i, filename in enumerate(wisdom_filename_divide(DP_Wisdom_file)):
@@ -946,14 +951,14 @@ def Load_wisdom_file(DP_Wisdom_file):
946951

947952
wis_list.append(wis)
948953

949-
pyfftw.import_wisdom(wis_list)
950-
951-
def Write_wisdom_file(DP_Wisdom_file):
954+
pyfftw.import_wisdom(wis_list)
955+
956+
def Write_wisdom_file(DP_Wisdom_file):
957+
if not(PYFFTW_AVAILABLE):
958+
warnings.warn("The package pyfftw could not be loaded. Please check your local install.")
959+
else:
952960
wis = pyfftw.export_wisdom()
953961

954962
for i, filename in enumerate(wisdom_filename_divide(DP_Wisdom_file)):
955963
with open(filename, 'wb') as f:
956964
f.write(wis[i])
957-
958-
except:
959-
pass

setup.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@
101101

102102
break
103103

104-
# extra_compile_args_std = ["-O0","-march=native", "-fopenmp", "-lm", *ignore_warnings_args]
105-
# extra_compile_args_safe = ["-O0", "-fopenmp", "-lm", *ignore_warnings_args]
106-
# extra_link_args = ["-fopenmp", "-lm",]
104+
extra_compile_args_std = ["-O0","-march=native", "-fopenmp", "-lm", *ignore_warnings_args]
105+
extra_compile_args_safe = ["-O0", "-fopenmp", "-lm", *ignore_warnings_args]
106+
extra_link_args = ["-fopenmp", "-lm",]
107107

108-
extra_compile_args_std = ["-Ofast", "-march=native", "-fopenmp", "-lm", "-flto", *ignore_warnings_args]
109-
extra_compile_args_safe = ["-O3", "-fopenmp", "-lm", "-flto", *ignore_warnings_args]
110-
extra_link_args = ["-fopenmp", "-lm", "-flto", *ignore_warnings_args]
108+
# extra_compile_args_std = ["-Ofast", "-march=native", "-fopenmp", "-lm", "-flto", *ignore_warnings_args]
109+
# extra_compile_args_safe = ["-O3", "-fopenmp", "-lm", "-flto", *ignore_warnings_args]
110+
# extra_link_args = ["-fopenmp", "-lm", "-flto", *ignore_warnings_args]
111111

112112
cython_extnames.append("choreo.cython.funs_parallel")
113113
cython_safemath_needed.append(False)
@@ -130,13 +130,11 @@
130130
pyfftw_pxd_str = """
131131
cimport pyfftw
132132
import pyfftw as p_pyfftw
133-
cdef bint PYFFTW_AVAILABLE
134133
"""
135134
else:
136135
pyfftw_pxd_str = """
137136
cimport choreo.cython.pyfftw_fake as pyfftw
138137
import choreo.cython.pyfftw_fake as p_pyfftw
139-
cdef bint PYFFTW_AVAILABLE
140138
"""
141139
with open("choreo/cython/optional_pyfftw.pxd", "w") as text_file:
142140
text_file.write(pyfftw_pxd_str)
@@ -156,17 +154,17 @@
156154
}
157155

158156
#### Profiler only ####
159-
# profile_compiler_directives = {
160-
# 'profile': True,
161-
# 'linetrace': True,
162-
# 'binding': True,
163-
# }
164-
# compiler_directives.update(profile_compiler_directives)
165-
# profile_define_macros = [
166-
# ('CYTHON_TRACE', '1') ,
167-
# ('CYTHON_TRACE_NOGIL', '1') ,
168-
# ]
169-
# define_macros.extend(profile_define_macros)
157+
profile_compiler_directives = {
158+
'profile': True,
159+
'linetrace': True,
160+
'binding': True,
161+
}
162+
compiler_directives.update(profile_compiler_directives)
163+
profile_define_macros = [
164+
('CYTHON_TRACE', '1') ,
165+
('CYTHON_TRACE_NOGIL', '1') ,
166+
]
167+
define_macros.extend(profile_define_macros)
170168

171169
include_dirs = [
172170
numpy.get_include() ,

0 commit comments

Comments
 (0)