Skip to content

Commit

Permalink
cuda: ignore nmodes input for type 3 (#580)
Browse files Browse the repository at this point in the history
Since we don't use this, no need to check if it's valid.
  • Loading branch information
janden authored Oct 18, 2024
1 parent efae920 commit bc4ddf9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cuda/cufinufft.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include <cufinufft.h>
#include <cufinufft/impl.h>

inline bool is_invalid_mode_array(int dim, const int64_t *modes64, int32_t modes32[3]) {
inline bool is_invalid_mode_array(int type, int dim, const int64_t *modes64,

This comment has been minimized.

Copy link
@DiamonDinoia

DiamonDinoia Oct 18, 2024

Collaborator

we just need to make sure that if the user passes modes=NULL everything is fine.

int32_t modes32[3]) {
if (type == 3) {
modes32[0] = modes32[1] = modes32[2] = 1;
return false;
}

int64_t tot_size = 1;
for (int i = 0; i < dim; ++i) {
if (modes64[i] > std::numeric_limits<int32_t>::max()) return true;
Expand All @@ -28,7 +34,9 @@ int cufinufftf_makeplan(int type, int dim, const int64_t *nmodes, int iflag, int
}

int nmodes32[3];
if (is_invalid_mode_array(dim, nmodes, nmodes32)) return FINUFFT_ERR_NDATA_NOTVALID;
if (is_invalid_mode_array(type, dim, nmodes, nmodes32)) {
return FINUFFT_ERR_NDATA_NOTVALID;
}

return cufinufft_makeplan_impl(type, dim, nmodes32, iflag, ntransf, tol,
(cufinufft_plan_t<float> **)d_plan_ptr, opts);
Expand All @@ -42,7 +50,9 @@ int cufinufft_makeplan(int type, int dim, const int64_t *nmodes, int iflag, int
}

int nmodes32[3];
if (is_invalid_mode_array(dim, nmodes, nmodes32)) return FINUFFT_ERR_NDATA_NOTVALID;
if (is_invalid_mode_array(type, dim, nmodes, nmodes32)) {
return FINUFFT_ERR_NDATA_NOTVALID;
}

return cufinufft_makeplan_impl(type, dim, nmodes32, iflag, ntransf, tol,
(cufinufft_plan_t<double> **)d_plan_ptr, opts);
Expand Down

0 comments on commit bc4ddf9

Please sign in to comment.