Skip to content

Commit 20feca4

Browse files
authored
[flang][cuda] Allow ieee_arithmetic on the device (llvm#131930)
- Allow ieee_arithmetic on the device - Add ignore_tkr(d) to ieee_is_finite
1 parent ade22fc commit 20feca4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

flang/lib/Semantics/check-cuda.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ struct DeviceExprChecker
8282
}
8383
}
8484
}
85+
const Symbol &ultimate{sym->GetUltimate()};
86+
const Scope &scope{ultimate.owner()};
87+
const Symbol *mod{scope.IsModule() ? scope.symbol() : nullptr};
88+
// Allow ieee_arithmetic module functions to be called on the device.
89+
// TODO: Check for unsupported ieee_arithmetic on the device.
90+
if (mod && mod->name() == "ieee_arithmetic") {
91+
return {};
92+
}
8593
} else if (x.GetSpecificIntrinsic()) {
8694
// TODO(CUDA): Check for unsupported intrinsics here
8795
return {};

flang/module/ieee_arithmetic.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ end subroutine ieee_get_underflow_mode_l##GKIND;
339339
#define IEEE_IS_FINITE_R(XKIND) \
340340
elemental logical function ieee_is_finite_a##XKIND(x); \
341341
real(XKIND), intent(in) :: x; \
342+
!dir$ ignore_tkr(d) x; \
342343
end function ieee_is_finite_a##XKIND;
343344
interface ieee_is_finite
344345
SPECIFICS_R(IEEE_IS_FINITE_R)

flang/test/Semantics/cuf09.cuf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,15 @@ subroutine host1()
209209
a(i) = a(i) + a(j) - 34.0
210210
end do
211211
end
212+
213+
subroutine ieee_test
214+
use ieee_arithmetic
215+
216+
real(8), device :: y(100)
217+
logical(4), managed :: ll(100)
218+
219+
!$cuf kernel do(1)<<<*,*>>>
220+
do i = 1, 100
221+
ll(i) = ieee_is_finite(y(i)) ! allow ieee_arithmetic functions on the device.
222+
end do
223+
end subroutine

0 commit comments

Comments
 (0)