forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
FIRFIR language relatedFIR language relatedOptimizeroptimization pass(es) relatedoptimization pass(es) relatedcodegenconversion of FIR/MLIR to LLVM IRconversion of FIR/MLIR to LLVM IR
Description
Avoiding malloc/free altogether would be even better, but not always doable.
The following is an example of code that calls malloc & free [as an implementation of fir.allocmem and fir.freemem] to implement the WHERE functionality.
This is another performance enhancement found when investigating performance of the SNAP application.
Here's an example:
program m
implicit none
REAL(8), ALLOCATABLE, DIMENSION(:,:,:,:) :: qim
integer(4) :: nang, noct,nx, ny, ng
integer(4) :: ll
real(8) :: total
real :: time_start
real :: time_end
nx = 40
ny = 40
noct = 6
ng = 18
print *, "Total size = ", nx * ny * noct * ng * 8
ALLOCATE(qim(nx,ny,noct,ng))
qim = 1.0
total = 0.0
call CPU_TIME(time_start)
do ll = 1, 20000
where (qim >= 1.0) qim = 1.0
end do
total = sum(qim)
call CPU_TIME(time_end)
print "(A, F6.3)", " Time taken (s): ", time_end - time_start
print *, total * 8, " This should match total size"
end program m
Metadata
Metadata
Assignees
Labels
FIRFIR language relatedFIR language relatedOptimizeroptimization pass(es) relatedoptimization pass(es) relatedcodegenconversion of FIR/MLIR to LLVM IRconversion of FIR/MLIR to LLVM IR