ACC-supported is_nan routines

I have a function that calls ieee_is_nan() that I would like to accelerate.
Unfortunately I get this error:
“Accelerator restriction: call to ‘ieee_is_nanr4’ with no acc routine information”

Is there any way around this? I could move the NaN checks elsewhere, but that’s not optimal - ideally I’d like to check for NaN within the accelerated loops.

Hi sp1,

We do have an open RFE to add support for ieee_is_nan on the device (TPR#26259) but this has not been implemented as of yet. I’ve added your request to it.

Unfortunately, we don’t have a work around for you so you’ll need to move the checks elsewhere.


Hi sp1,

I was playing with this a bit more. One potential work around is to write a C routine that can then call the C99 “isnan” routine on the device. Something like:

#include <accelmath.h>

#pragma acc routine seq
int isnanf_c_ (float val) {
   return isnan(val);

The add an interface in the Fortran code:

        function isnanf_c(val)
!$acc routine(isnanf_c) seq
         integer :: isnanf_c
         real, value :: val
        end function isnanf_c
      end interface

Finally, replace “ieee_is_nan” with calls to “isnanf_c”. I haven’t thoroughly tested it other than in a simple program, but might be worth a try.