Skip to content

Commit

Permalink
disable RandomRutherford on GPU, current Ei algorithm is too slow
Browse files Browse the repository at this point in the history
Signed-off-by: Szymon Lopaciuk <[email protected]>
  • Loading branch information
szymonlopaciuk committed Feb 21, 2023
1 parent 5840adf commit 6d0570d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test_random_gen_ruth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def ruth_PDF(t, A, B):
rB = 53.50625
iterations = 20

@for_all_test_contexts
@for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
def test_random_generation(test_context):

part = xp.Particles(_context=test_context, p0c=6.5e12, x=[1,2,3])
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self, **kwargs):
np.allclose(hstgm[:-10], ruth[:-10], rtol=5e-2, atol=1)


@for_all_test_contexts
@for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
def test_direct_sampling(test_context):
n_seeds = 3
n_samples = 3e6
Expand Down
4 changes: 4 additions & 0 deletions xtrack/random/random_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ def __init__(self, **kwargs):
kwargs.setdefault('upper_val', 1.)
kwargs.setdefault('A', 0.)
kwargs.setdefault('B', 0.)

super().__init__(**kwargs)

if not isinstance(self._context, xo.ContextCpu):
raise ValueError('Rutherford random generator is not currently supported on GPU.')

def set_parameters(self, A, B, lower_val, upper_val):
self.compile_kernels(only_if_needed=True)
context = self._buffer.context
Expand Down

0 comments on commit 6d0570d

Please sign in to comment.