Skip to content

Commit

Permalink
Merge pull request #39 from gicmo/nrm2osx
Browse files Browse the repository at this point in the history
[OSX] Fix crash in nrm2 tests
  • Loading branch information
Kent Knox committed Jun 19, 2014
2 parents 68cbd37 + c87d8c6 commit f2de5e7
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/tests/correctness/blas-lapack.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,20 @@ void zdscal( int n, double alpha, doublecomplex *x, int incx)

float sdot( int n, float *x, int incx, float *y, int incy)
{
#ifdef __APPLE__
return cblas_sdot(n, x, incx, y, incy);
#else
return sdot_(&n, x, &incx, y, &incy);
#endif
}

double ddot( int n, double *x, int incx, double *y, int incy)
{
#ifdef __APPLE__
return cblas_ddot(n, x, incx, y, incy);
#else
return ddot_(&n, x, &incx, y, &incy);
#endif
}

complex cdotu( int n, complex *x, int incx, complex *y, int incy)
Expand Down Expand Up @@ -840,42 +848,94 @@ int izamax( int n, doublecomplex *x, int incx)

float snrm2( int n, float *x, int incx)
{
#ifdef __APPLE__
//On OSX passing negative values for incx can lead to a
//a crash, so we catch it here (cf. Github issue #37).
if (n < 1 || incx < 1) {
return 0;
}
return cblas_snrm2(n, x, incx);
#else
return snrm2_(&n, x, &incx);
#endif
}

double dnrm2( int n, double *x, int incx)
{
#ifdef __APPLE__
//On OSX passing negative values for incx can lead to a
//a crash, so we catch it here (cf. Github issue #37).
if (n < 1 || incx < 1) {
return 0;
}
return cblas_dnrm2(n, x, incx);
#else
return dnrm2_(&n, x, &incx);
#endif
}

float scnrm2( int n, complex *x, int incx)
{
#ifdef __APPLE__
//On OSX passing negative values for incx can lead to a
//a crash, so we catch it here (cf. Github issue #37).
if (n < 1 || incx < 1) {
return 0;
}
return cblas_scnrm2(n, x, incx);
#else
return scnrm2_(&n, x, &incx);
#endif
}

double dznrm2( int n, doublecomplex *x, int incx)
{
#ifdef __APPLE__
//On OSX passing negative values for incx can lead to a
//a crash, so we catch it here (cf. Github issue #37).
if (n < 1 || incx < 1) {
return 0;
}
return cblas_dznrm2(n, x, incx);
#else
return dznrm2_(&n, x, &incx);
#endif
}

float sasum( int n, float *x, int incx)
{
#ifdef __APPLE__
return cblas_sasum(n, x, incx);
#else
return sasum_(&n, x, &incx);
#endif
}

double dasum( int n, double *x, int incx)
{
#ifdef __APPLE__
return cblas_dasum(n, x, incx);
#else
return dasum_(&n, x, &incx);
#endif
}

float scasum( int n, complex *x, int incx)
{
#ifdef __APPLE__
return cblas_scasum(n, x, incx);
#else
return scasum_(&n, x, &incx);
#endif
}

double dzasum( int n, doublecomplex *x, int incx)
{
#ifdef __APPLE__
return cblas_dzasum(n, x, incx);
#else
return dzasum_(&n, x, &incx);
#endif
}

#endif

0 comments on commit f2de5e7

Please sign in to comment.