Skip to content

Commit

Permalink
[ROCm] work around compiler issue for IGammaKernel.cu (#50970)
Browse files Browse the repository at this point in the history
Summary:
Add const to static variable inside `__host__ __device__` function.

Pull Request resolved: #50970

Reviewed By: izdeby

Differential Revision: D26081478

Pulled By: heitorschueroff

fbshipit-source-id: 77cf145f7e0570359aa00aec4c8b82c950815f81
  • Loading branch information
jeffdaily authored and facebook-github-bot committed Jan 27, 2021
1 parent b604940 commit 0a4bc72
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions aten/src/ATen/native/cuda/IGammaKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ __host__ __device__ scalar_t _igam_helper_fac(scalar_t a, scalar_t x) {

using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
accscalar_t ax, fac, res, num, numfac;
static accscalar_t MAXLOG = std::is_same<accscalar_t,double>::value ?
static const accscalar_t MAXLOG = std::is_same<accscalar_t,double>::value ?
7.09782712893383996843E2 : 88.72283905206835;
static accscalar_t EXP1 = 2.718281828459045;
static accscalar_t lanczos_g = 6.024680040776729583740234375;
static const accscalar_t EXP1 = 2.718281828459045;
static const accscalar_t lanczos_g = 6.024680040776729583740234375;

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

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

int i;
accscalar_t ans, ax, c, r;
Expand Down Expand Up @@ -191,8 +191,8 @@ __host__ __device__ scalar_t _igamc_helper_series(scalar_t a, scalar_t x) {
accscalar_t fac = 1;
accscalar_t sum = 0;
accscalar_t term, logx;
static accscalar_t MAXITER = 2000;
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
static const int MAXITER = 2000;
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
1.11022302462515654042E-16 : 5.9604644775390625E-8;

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

int k, n, sgn;
int maxpow = 0;
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
1.11022302462515654042E-16 : 5.9604644775390625E-8;
accscalar_t lambda = x / a;
accscalar_t sigma = (x - a) / a;
Expand Down Expand Up @@ -309,12 +309,12 @@ __host__ __device__ scalar_t _igamc_helper_continued_fraction(scalar_t a, scalar
int i;
accscalar_t ans, ax, c, yc, r, t, y, z;
accscalar_t pk, pkm1, pkm2, qk, qkm1, qkm2;
int MAXITER = 2000;
static accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
static const int MAXITER = 2000;
static const accscalar_t MACHEP = std::is_same<accscalar_t, double>::value ?
1.11022302462515654042E-16 : 5.9604644775390625E-8;
static accscalar_t BIG = std::is_same<accscalar_t,double>::value ?
static const accscalar_t BIG = std::is_same<accscalar_t,double>::value ?
4.503599627370496e15 : 16777216.;
static accscalar_t BIGINV = std::is_same<accscalar_t,double>::value ?
static const accscalar_t BIGINV = std::is_same<accscalar_t,double>::value ?
2.22044604925031308085e-16 : 5.9604644775390625E-8;

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

static accscalar_t SMALL = 20.0;
static accscalar_t LARGE = 200.0;
static accscalar_t SMALLRATIO = 0.3;
static accscalar_t LARGERATIO = 4.5;
static const accscalar_t SMALL = 20.0;
static const accscalar_t LARGE = 200.0;
static const accscalar_t SMALLRATIO = 0.3;
static const accscalar_t LARGERATIO = 4.5;

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

using accscalar_t = at::acc_type<scalar_t, /*is_cuda=*/true>;
accscalar_t absxma_a;
static accscalar_t SMALL = 20.0;
static accscalar_t LARGE = 200.0;
static accscalar_t SMALLRATIO = 0.3;
static accscalar_t LARGERATIO = 4.5;
static const accscalar_t SMALL = 20.0;
static const accscalar_t LARGE = 200.0;
static const accscalar_t SMALLRATIO = 0.3;
static const accscalar_t LARGERATIO = 4.5;

// boundary values following SciPy
if ((x < 0) || (a < 0)) {
Expand Down

0 comments on commit 0a4bc72

Please sign in to comment.