Skip to content

Commit 3efa84c

Browse files
committed
using const and restrict where possible
1 parent aabdb57 commit 3efa84c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/finufft/defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@
4343
#define FINUFFT_ALWAYS_INLINE __forceinline
4444
#define FINUFFT_NEVER_INLINE __declspec(noinline)
4545
#define FINUFFT_RESTRICT __restrict
46+
#define FINUFFT_UNREACHABLE __assume(0)
47+
4648
#elif defined(__GNUC__) || defined(__clang__)
4749
#define FINUFFT_ALWAYS_INLINE __attribute__((always_inline)) inline
4850
#define FINUFFT_NEVER_INLINE __attribute__((noinline))
4951
#define FINUFFT_RESTRICT __restrict__
52+
#define FINUFFT_UNREACHABLE __builtin_unreachable()
5053
#else
5154
#define FINUFFT_ALWAYS_INLINE inline
5255
#define FINUFFT_NEVER_INLINE
5356
#define FINUFFT_RESTRICT
57+
#define FINUFFT_UNREACHABLE
5458
#endif
5559

5660
// ------------- Library-wide algorithm parameter settings ----------------

src/spreadinterp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ FINUFFT_NEVER_INLINE static int interpSorted_kernel(
461461
static constexpr auto ns2 = ns * FLT(0.5); // half spread width, used as stencil shift
462462

463463
CNTime timer;
464-
int ndims = ndims_from_Ns(N1, N2, N3);
465-
int nthr = MY_OMP_GET_MAX_THREADS(); // guess # threads to use to interp
464+
const int ndims = ndims_from_Ns(N1, N2, N3);
465+
int nthr = MY_OMP_GET_MAX_THREADS(); // guess # threads to use to interp
466466
if (opts.nthreads > 0) nthr = opts.nthreads; // user override, now without limit
467467
#ifndef _OPENMP
468468
nthr = 1; // single-threaded lib must override user
@@ -533,6 +533,7 @@ FINUFFT_NEVER_INLINE static int interpSorted_kernel(
533533
N3);
534534
break;
535535
default: // can't get here
536+
FINUFFT_UNREACHABLE;
536537
break;
537538
}
538539
}

0 commit comments

Comments
 (0)