Skip to content

Commit 7e1f87c

Browse files
authored
Merge pull request #422 from stan-dev/bugfix/261-cpp-opts
Remove cpp option whitelist
2 parents ea0f3f2 + 7460901 commit 7e1f87c

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

cmdstanpy/compiler_opts.py

+4-20
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@
4040
'version',
4141
]
4242

43-
CPP_OPTS = [
44-
'STAN_OPENCL',
45-
'OPENCL_DEVICE_ID',
46-
'OPENCL_PLATFORM_ID',
47-
'STAN_MPI',
48-
'STAN_THREADS',
49-
]
50-
5143

5244
class CompilerOptions:
5345
"""
@@ -151,18 +143,10 @@ def validate_cpp_opts(self) -> None:
151143
"""
152144
if self._cpp_options is None:
153145
return
154-
if (
155-
'OPENCL_DEVICE_ID' in self._cpp_options.keys()
156-
or 'OPENCL_PLATFORM_ID' in self._cpp_options.keys()
157-
):
158-
self._cpp_options['STAN_OPENCL'] = 'TRUE'
159-
160-
for key, val in self._cpp_options.items():
161-
if key not in CPP_OPTS:
162-
raise ValueError(
163-
'unknown CmdStan makefile option: {}'.format(key)
164-
)
165-
if key in ['OPENCL_DEVICE_ID', 'OPENCL_PLATFORM_ID']:
146+
for key in ['OPENCL_DEVICE_ID', 'OPENCL_PLATFORM_ID']:
147+
if key in self._cpp_options:
148+
self._cpp_options['STAN_OPENCL'] = 'TRUE'
149+
val = self._cpp_options[key]
166150
if not isinstance(val, int) or val < 0:
167151
raise ValueError(
168152
'{} must be a non-negative integer value,'

test/test_compiler_opts.py

-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ def test_opts_cpp(self):
121121
opts.validate()
122122
self.assertEqual(opts.compose(), ['STAN_MPI=TRUE'])
123123

124-
cpp_opts['STAN_BAD'] = 'TRUE'
125-
opts = CompilerOptions(cpp_options=cpp_opts)
126-
with self.assertRaises(ValueError):
127-
opts.validate()
128-
129124
def test_opts_cpp_opencl(self):
130125
cpp_opts = {'OPENCL_DEVICE_ID': 1}
131126
opts = CompilerOptions(cpp_options=cpp_opts)

0 commit comments

Comments
 (0)