Skip to content

Commit 86c3ef4

Browse files
committed
work around compiler issue for IGammaKernel.cu
Add const to static variable inside __host__ __device__ function.
1 parent dd1c2a0 commit 86c3ef4

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

aten/src/ATen/native/cuda/IGammaKernel.cu

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ __host__ __device__ scalar_t _igam_helper_fac(scalar_t a, scalar_t x) {
121121

122122
using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
123123
accscalar_t ax, fac, res, num, numfac;
124-
static accscalar_t MAXLOG = std::is_same<accscalar_t,double>::value ?
124+
static const accscalar_t MAXLOG = std::is_same<accscalar_t,double>::value ?
125125
7.09782712893383996843E2 : 88.72283905206835;
126-
static accscalar_t EXP1 = 2.718281828459045;
127-
static accscalar_t lanczos_g = 6.024680040776729583740234375;
126+
static const accscalar_t EXP1 = 2.718281828459045;
127+
static const accscalar_t lanczos_g = 6.024680040776729583740234375;
128128

129129
if (::fabs(a - x) > 0.4 * ::fabs(a)) {
130130
ax = a * ::log(x) - x - ::lgamma(a);
@@ -153,9 +153,9 @@ __host__ __device__ scalar_t _igam_helper_series(scalar_t a, scalar_t x) {
153153
// Compute igam using DLMF 8.11.4. [igam1]
154154

155155
using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
156-
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
156+
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
157157
1.11022302462515654042E-16 : 5.9604644775390625E-8;
158-
static int MAXITER = 2000;
158+
static const int MAXITER = 2000;
159159

160160
int i;
161161
accscalar_t ans, ax, c, r;
@@ -191,8 +191,8 @@ __host__ __device__ scalar_t _igamc_helper_series(scalar_t a, scalar_t x) {
191191
accscalar_t fac = 1;
192192
accscalar_t sum = 0;
193193
accscalar_t term, logx;
194-
static accscalar_t MAXITER = 2000;
195-
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
194+
static const int MAXITER = 2000;
195+
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
196196
1.11022302462515654042E-16 : 5.9604644775390625E-8;
197197

198198
for (n = 1; n < MAXITER; n++) {
@@ -243,7 +243,7 @@ __host__ __device__ scalar_t _igam_helper_asymptotic_series(scalar_t a, scalar_t
243243

244244
int k, n, sgn;
245245
int maxpow = 0;
246-
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
246+
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
247247
1.11022302462515654042E-16 : 5.9604644775390625E-8;
248248
accscalar_t lambda = x / a;
249249
accscalar_t sigma = (x - a) / a;
@@ -309,12 +309,12 @@ __host__ __device__ scalar_t _igamc_helper_continued_fraction(scalar_t a, scalar
309309
int i;
310310
accscalar_t ans, ax, c, yc, r, t, y, z;
311311
accscalar_t pk, pkm1, pkm2, qk, qkm1, qkm2;
312-
int MAXITER = 2000;
313-
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
312+
static const int MAXITER = 2000;
313+
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
314314
1.11022302462515654042E-16 : 5.9604644775390625E-8;
315-
static accscalar_t BIG = std::is_same<accscalar_t,double>::value ?
315+
static const accscalar_t BIG = std::is_same<accscalar_t,double>::value ?
316316
4.503599627370496e15 : 16777216.;
317-
static accscalar_t BIGINV = std::is_same<accscalar_t,double>::value ?
317+
static const accscalar_t BIGINV = std::is_same<accscalar_t,double>::value ?
318318
2.22044604925031308085e-16 : 5.9604644775390625E-8;
319319

320320
ax = _igam_helper_fac(a, x);
@@ -380,10 +380,10 @@ __noinline__ __host__ __device__ scalar_t calc_igammac(scalar_t a, scalar_t x) {
380380
using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
381381
accscalar_t absxma_a;
382382

383-
static accscalar_t SMALL = 20.0;
384-
static accscalar_t LARGE = 200.0;
385-
static accscalar_t SMALLRATIO = 0.3;
386-
static accscalar_t LARGERATIO = 4.5;
383+
static const accscalar_t SMALL = 20.0;
384+
static const accscalar_t LARGE = 200.0;
385+
static const accscalar_t SMALLRATIO = 0.3;
386+
static const accscalar_t LARGERATIO = 4.5;
387387

388388
if ((x < 0) || (a < 0)) {
389389
// out of defined-region of the function
@@ -462,10 +462,10 @@ __noinline__ __host__ __device__ scalar_t calc_igamma(scalar_t a, scalar_t x) {
462462

463463
using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
464464
accscalar_t absxma_a;
465-
static accscalar_t SMALL = 20.0;
466-
static accscalar_t LARGE = 200.0;
467-
static accscalar_t SMALLRATIO = 0.3;
468-
static accscalar_t LARGERATIO = 4.5;
465+
static const accscalar_t SMALL = 20.0;
466+
static const accscalar_t LARGE = 200.0;
467+
static const accscalar_t SMALLRATIO = 0.3;
468+
static const accscalar_t LARGERATIO = 4.5;
469469

470470
// boundary values following SciPy
471471
if ((x < 0) || (a < 0)) {

0 commit comments

Comments
 (0)