Skip to content

Commit

Permalink
release the GIL explicitly when calling the kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
reuterk committed Jun 11, 2018
1 parent 8540914 commit b3ede24
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
27 changes: 14 additions & 13 deletions cadishi/kernel/c_cudh.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cdef extern from "c_cudh.h":
int *mask_ptr,
double *box_ptr,
int box_type_id,
const config & cfg)
const config & cfg) nogil


def get_num_cuda_devices():
Expand Down Expand Up @@ -94,16 +94,17 @@ def histograms(np.ndarray r_ptr,
cfg.set_gpu_algorithm(algorithm)

cdef int exit_status
exit_status = histograms_gpu(<np_tuple3d_t*> r_ptr.data,
<int> n_tot,
<int*> nel_ptr.data,
<int> n_El,
<stdint.uint64_t*> histo_ptr.data,
<int> n_bins,
<int> n_Hij,
<double> r_max,
<int*> mask_ptr.data,
<double*> box_ptr.data,
<int> box_type_id,
cfg)
with nogil:
exit_status = histograms_gpu(<np_tuple3d_t*> r_ptr.data,
<int> n_tot,
<int*> nel_ptr.data,
<int> n_El,
<stdint.uint64_t*> histo_ptr.data,
<int> n_bins,
<int> n_Hij,
<double> r_max,
<int*> mask_ptr.data,
<double*> box_ptr.data,
<int> box_type_id,
cfg)
return exit_status
25 changes: 13 additions & 12 deletions cadishi/kernel/c_pydh.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cdef extern from "c_pydh.h":
int *mask_ptr,
double *box_ptr,
int box_type_id,
const config & cfg)
const config & cfg) nogil

int distances_cpu( np_tuple3d_t *r_ptr,
int n_tot,
Expand Down Expand Up @@ -90,17 +90,18 @@ def histograms(np.ndarray r_ptr,
cfg.set_cpu_blocksize(blocksize)

cdef int exit_status
exit_status = histograms_cpu(<np_tuple3d_t*> r_ptr.data,
<int> n_tot,
<int*> nel_ptr.data,
<int> n_El,
<stdint.uint64_t *> histo_ptr.data,
<int> n_bins,
<double> r_max,
<int*> mask_ptr.data,
<double*> box_ptr.data,
<int> box_type_id,
cfg)
with nogil:
exit_status = histograms_cpu(<np_tuple3d_t*> r_ptr.data,
<int> n_tot,
<int*> nel_ptr.data,
<int> n_El,
<stdint.uint64_t *> histo_ptr.data,
<int> n_bins,
<double> r_max,
<int*> mask_ptr.data,
<double*> box_ptr.data,
<int> box_type_id,
cfg)
return exit_status


Expand Down

0 comments on commit b3ede24

Please sign in to comment.