Skip to content

Commit

Permalink
added DFT examples for RankBenchmark_tensor_Driver and RankBenchmark_…
Browse files Browse the repository at this point in the history
…Driver
  • Loading branch information
liuyangzhuan committed Dec 21, 2023
1 parent 37fc1a8 commit a95db6c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 25 deletions.
52 changes: 39 additions & 13 deletions EXAMPLE/RankBenchmark_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ subroutine Zelem_User(m,n,value,quant)
complex(kind=8)::value
integer ii

real(kind=8)::pos_o(3),pos_s(3), dist, waven
real(kind=8)::pos_o(100),pos_s(100), dist, waven, dotp

select TYPE(quant)
type is (quant_app)
pos_o = quant%locations_m(:,m)
pos_s = quant%locations_n(:,n)
dist = sqrt(sum((pos_o-pos_s)**2d0))
waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist

if(quant%tst==4)then
pos_o(1:quant%Ndim) = quant%locations_m(:,m)
pos_s(1:quant%Ndim) = quant%locations_n(:,n)
dotp = dot_product(pos_o(1:quant%Ndim),pos_s(1:quant%Ndim))
value = EXP(-2*BPACK_pi*BPACK_junit*dotp)
else
pos_o(1:quant%Ndim) = quant%locations_m(:,m)
pos_s(1:quant%Ndim) = quant%locations_n(:,n)
dist = sqrt(sum((pos_o-pos_s)**2d0))
waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist
endif
class default
write(*,*)"unexpected type"
stop
Expand Down Expand Up @@ -111,7 +117,7 @@ PROGRAM ButterflyPACK_RankBenchmark
type(quant_app),target::quant
type(z_Bmatrix),target::bmat
integer,allocatable:: groupmembers(:)
integer nmpi, Nperdim, dims(3), inds(3)
integer nmpi, Nperdim, dim_i, dims(100), inds(100)
integer level,Maxlevel,m,n
type(z_proctree),target::ptree
integer,allocatable::Permutation(:)
Expand Down Expand Up @@ -172,6 +178,10 @@ PROGRAM ButterflyPACK_RankBenchmark
read(strings1,*)quant%tst
elseif(trim(strings)=='--wavelen')then
read(strings1,*)quant%wavelen
elseif(trim(strings)=='--ndim_FIO')then
read(strings1,*)quant%Ndim
elseif(trim(strings)=='--N_FIO')then
read(strings1,*)Nperdim
else
if(ptree%MyID==Main_ID)write(*,*)'ignoring unknown quant: ', trim(strings)
endif
Expand All @@ -192,11 +202,6 @@ PROGRAM ButterflyPACK_RankBenchmark



call z_PrintOptions(option,ptree)




!******************************************************************************!
! Read a full non-square matrix and do a BF compression

Expand Down Expand Up @@ -277,10 +282,31 @@ PROGRAM ButterflyPACK_RankBenchmark
quant%locations_n(2,n)=jj*ds
quant%locations_n(3,n)=kk*ds
enddo
elseif(quant%tst==4)then ! DFT
quant%Nunk_m = Nperdim**quant%Ndim
quant%Nunk_n = Nperdim**quant%Ndim
allocate(quant%locations_m(quant%Ndim,quant%Nunk_m))
allocate(quant%locations_n(quant%Ndim,quant%Nunk_n))
dims = Nperdim
do m=1,quant%Nunk_m
call z_SingleIndexToMultiIndex(quant%Ndim,dims, m, inds)
do dim_i=1,quant%Ndim
quant%locations_m(dim_i,m)=inds(dim_i)-1
enddo
enddo
do n=1,quant%Nunk_n
call z_SingleIndexToMultiIndex(quant%Ndim,dims, n, inds)
do dim_i=1,quant%Ndim
quant%locations_n(dim_i,n)=dble(inds(dim_i)-1)/Nperdim
enddo
enddo
endif



call z_PrintOptions(option,ptree)


if(ptree%MyID==Main_ID)then
write (*,*) ''
write (*,*) 'RankBenchmark computing'
Expand Down
34 changes: 28 additions & 6 deletions EXAMPLE/RankBenchmark_tensor_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subroutine Zelem_MD_User(Ndim, m,n,value,quant)
complex(kind=8)::value
integer ii, dim_i

real(kind=8)::pos_o(Ndim),pos_s(Ndim), dist, waven
real(kind=8)::pos_o(Ndim),pos_s(Ndim), dist, waven, dotp

select TYPE(quant)
type is (quant_app)
Expand All @@ -43,17 +43,23 @@ subroutine Zelem_MD_User(Ndim, m,n,value,quant)
enddo
if(quant%tst==1)then
dist = sqrt(sum((pos_o-pos_s)**2d0))
waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist
elseif(quant%tst==2)then
dist = sqrt(sum((pos_o-pos_s)**2d0) + quant%zdist**2d0)
waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist
elseif(quant%tst==3)then
dist = sqrt(sum((pos_o-pos_s)**2d0))
waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist
elseif(quant%tst==4)then
dotp = dot_product(pos_o,pos_s)
value = EXP(-2*BPACK_pi*BPACK_junit*dotp)
else
write(*,*)'tst unknown'
endif

waven=2*BPACK_pi/quant%wavelen
value = EXP(-BPACK_junit*waven*dist)/dist

class default
write(*,*)"unexpected type"
stop
Expand Down Expand Up @@ -187,6 +193,10 @@ PROGRAM ButterflyPACK_RankBenchmark
read(strings1,*)quant%tst
elseif(trim(strings)=='--wavelen')then
read(strings1,*)quant%wavelen
elseif(trim(strings)=='--ndim_FIO')then
read(strings1,*)quant%Ndim
elseif(trim(strings)=='--N_FIO')then
read(strings1,*)Nperdim
else
if(ptree%MyID==Main_ID)write(*,*)'ignoring unknown quant: ', trim(strings)
endif
Expand All @@ -206,12 +216,10 @@ PROGRAM ButterflyPACK_RankBenchmark
enddo



call z_PrintOptions(option,ptree)




!******************************************************************************!
! Read a full non-square matrix and do a BF compression

Expand Down Expand Up @@ -277,6 +285,20 @@ PROGRAM ButterflyPACK_RankBenchmark
quant%locations_n(2,n)=n*ds
quant%locations_n(3,n)=n*ds
enddo

elseif(quant%tst==4)then ! DFT
allocate(quant%Nunk_m(quant%Ndim))
allocate(quant%Nunk_n(quant%Ndim))
quant%Nunk_m = Nperdim
quant%Nunk_n = Nperdim
allocate(quant%locations_m(quant%Ndim,Nperdim))
allocate(quant%locations_n(quant%Ndim,Nperdim))
do m=1,Nperdim
quant%locations_m(:,m)=m-1
enddo
do n=1,Nperdim
quant%locations_n(:,n)=dble(n-1)/Nperdim
enddo
endif

allocate(Nunk_m_loc(quant%Ndim))
Expand Down
20 changes: 14 additions & 6 deletions example_scripts/runit_osx_ventura_tr4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ fi
tol=1e-6
export OMP_NUM_THREADS=4

$MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 3 --wavelen 0.015625 -option --nmin_leaf 8 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 1.0 --sample_para_outer 1.0 --fastsample_tensor 2 | tee a.out_tensor_3d_green
$MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben -quant --tst 3 --wavelen 0.015625 -option --nmin_leaf 8 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 2.0 --sample_para_outer 2.0 | tee a.out_matrix_3d_green
############## 3D seperated cubes
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 3 --wavelen 0.015625 -option --nmin_leaf 8 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 1.0 --sample_para_outer 1.0 --fastsample_tensor 2 | tee a.out_tensor_3d_green
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben -quant --tst 3 --wavelen 0.015625 -option --nmin_leaf 8 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 2.0 --sample_para_outer 2.0 | tee a.out_matrix_3d_green



# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 0.8 --sample_para_outer 0.8 --fastsample_tensor 2 | tee a.out_tensor
# # $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 1.0 --sample_para_outer 1.0 --fastsample_tensor 1 | tee a.out_tensor
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 0.8 --sample_para_outer 0.8 | tee a.out_tensor
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 64 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --pat_comp 3 --sample_para 2.0 --sample_para_outer 2.0 | tee a.out_matrix
############## 2D parallel plates
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 0.8 --sample_para_outer 0.8 --fastsample_tensor 2 | tee a.out_tensor_2d_green
# # $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 1.0 --sample_para_outer 1.0 --fastsample_tensor 1 | tee a.out_tensor_2d_green
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --sample_para 0.8 --sample_para_outer 0.8 | tee a.out_tensor_2d_green
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben -quant --tst 2 --wavelen 0.0156 -option --nmin_leaf 64 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --pat_comp 3 --sample_para 2.0 --sample_para_outer 2.0 | tee a.out_matrix_2d_green


############## DFT
tol=1e-3
# $MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben -quant --tst 4 --ndim_FIO 4 --N_FIO 8 -option --nmin_leaf 64 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --pat_comp 3 --sample_para 2.0 --sample_para_outer 2.0 | tee a.out_matrix_DFT
$MPIRUN --allow-run-as-root -n 4 ../build/EXAMPLE/frankben_t -quant --tst 4 --ndim_FIO 6 --N_FIO 8 -option --nmin_leaf 8 --xyzsort 1 --lrlevel 100 --verbosity 1 --tol_comp $tol --pat_comp 3 --sample_para 2.0 --sample_para_outer 2.0 --fastsample_tensor 2 | tee a.out_tensor_DFT

0 comments on commit a95db6c

Please sign in to comment.