Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/include/flang/Optimizer/Builder/IntrinsicCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct IntrinsicLibrary {
mlir::Value genAnint(mlir::Type, llvm::ArrayRef<mlir::Value>);
fir::ExtendedValue genAny(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
mlir::Value genAtanpi(mlir::Type, llvm::ArrayRef<mlir::Value>);
mlir::Value genAtomicAdd(mlir::Type, llvm::ArrayRef<mlir::Value>);
fir::ExtendedValue
genCommandArgumentCount(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
mlir::Value genAsind(mlir::Type, llvm::ArrayRef<mlir::Value>);
Expand Down
10 changes: 10 additions & 0 deletions flang/lib/Optimizer/Builder/IntrinsicCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static constexpr IntrinsicHandler handlers[]{
{"atan2pi", &I::genAtanpi},
{"atand", &I::genAtand},
{"atanpi", &I::genAtanpi},
{"atomicaddd", &I::genAtomicAdd, {}, /*isElemental=*/false},
{"bessel_jn",
&I::genBesselJn,
{{{"n1", asValue}, {"n2", asValue}, {"x", asValue}}},
Expand Down Expand Up @@ -2574,6 +2575,15 @@ mlir::Value IntrinsicLibrary::genAtanpi(mlir::Type resultType,
return builder.create<mlir::arith::MulFOp>(loc, atan, factor);
}

mlir::Value IntrinsicLibrary::genAtomicAdd(mlir::Type resultType,
llvm::ArrayRef<mlir::Value> args) {
assert(args.size() == 2);
llvm::errs() << "In genAtomicAdd\n";
return builder.create<mlir::LLVM::AtomicRMWOp>(
loc, mlir::LLVM::AtomicBinOp::add, args[0], args[1],
mlir::LLVM::AtomicOrdering::seq_cst);
}

// ASSOCIATED
fir::ExtendedValue
IntrinsicLibrary::genAssociated(mlir::Type resultType,
Expand Down
35 changes: 34 additions & 1 deletion flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,38 @@ attributes(device) subroutine threadfence_system()
end function
end interface
public :: __fadd_ru


interface
attributes(device) real*8 function atomicaddd(address, val)
real*8, intent(inout) :: address
real*8 :: val
end function
end interface
public :: atomicaddd


!interface atomicadd
! attributes(device) pure integer function atomicaddi(address, val)
!!dir$ ignore_tkr (rd) address, (d) val
! integer, intent(inout) :: address
! integer, value :: val
! end function
! attributes(device) pure real function atomicaddf(address, val)
!!dir$ ignore_tkr (rd) address, (d) val
! real, intent(inout) :: address
! real, value :: val
! end function
! attributes(device) pure real*8 function atomicaddd(address, val)
!!dir$ ignore_tkr (rd) address, (d) val
! real*8, intent(inout) :: address
! real*8, value :: val
! end function
! attributes(device) pure integer(8) function atomicaddul(address, val)
!!dir$ ignore_tkr (rd) address, (dk) val
! integer(8), intent(inout) :: address
! integer(8), value :: val
! end function
!end interface
!public :: atomicadd

end module
Loading