Skip to content

Commit

Permalink
Merge branch 'cmsdy' (with madgraph5#968 and madgraph5#969 improvemen…
Browse files Browse the repository at this point in the history
…ts - but not yet the latest upstream/master) into cmsdyps

Fix conflicts in patch.common (NB: the 968/969 improvements are now in the OLD sample_get_x)
  • Loading branch information
valassi committed Aug 22, 2024
2 parents c9e0c1e + 3bdec2c commit a347f3f
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,94 @@ index e18ba7c03..d038f9159 100644
c************************************************************************
c Returns maxdim random numbers between 0 and 1, and the wgt
c associated with this set of points, and the iteration number
@@ -1240,7 +1250,20 @@ c
c Local
c
integer im, ip,ij,icount,it_warned
- double precision xbin_min,xbin_max,ddum(maxdim),xo,y
+ double precision xbin_min,xbin_max,ddum(maxdim),xo,y
+c
+c Local (performance optimization #969)
+c
+ integer xbinarraydim
+ parameter (xbinarraydim=maxdim*lmaxconfigs)
+ double precision xbin_min0_array(maxdim, lmaxconfigs)
+ double precision xbin_max1_array(maxdim, lmaxconfigs)
+ logical xbin_min0_saved(maxdim, lmaxconfigs)
+ logical xbin_max1_saved(maxdim, lmaxconfigs)
+ save xbin_min0_array, xbin_max1_array
+ save xbin_min0_saved, xbin_max1_saved
+ data xbin_min0_saved/xbinarraydim*.false./
+ data xbin_max1_saved/xbinarraydim*.false./
c
c External
c
@@ -1291,15 +1314,29 @@ c write(*,'(7f11.5)')(ddum(j)*real(ng),j=1,dim)
endif
if (ituple .eq. 1) then
c write(*,*) 'Getting variable',ipole,j,minvar(j,ipole)
- xbin_min = xbin(xmin,minvar(j,ipole))
- xbin_max = xbin(xmax,minvar(j,ipole))
- if (xbin_min .gt. xbin_max-1) then
-c write(*,'(a,4e15.4)') 'Bad limits',xbin_min,xbin_max,
-c & xmin,xmax
-c xbin_max=xbin_min+1d-10
- xbin_max = xbin(xmax,minvar(j,ipole))
- xbin_min = min(xbin(xmin,minvar(j,ipole)), xbin_max)
- endif
+
+ if(xmax.ne.1 .or. .not.xbin_max1_saved(j,ipole)) then
+ xbin_max = xbin(xmax, minvar(j,ipole))
+ if(xmax.eq.1) then
+ xbin_max1_array(j,ipole) = xbin_max
+ xbin_max1_saved(j,ipole) = .true.
+ endif
+ else
+ xbin_max = xbin_max1_array(j,ipole)
+ endif
+
+ if(xmin.ne.0 .or. .not.xbin_min0_saved(j,ipole)) then
+ xbin_min = xbin(xmin, minvar(j,ipole))
+ if (xbin_min .gt. xbin_max-1) then
+ xbin_min = min(xbin_min, xbin_max)
+ endif
+ if(xmin.eq.0) then
+ xbin_min0_array(j,ipole) = xbin_min
+ xbin_min0_saved(j,ipole) = .true.
+ endif
+ else
+ xbin_min = xbin_min0_array(j,ipole)
+ endif
c
c Line which allows us to keep choosing same x
c
@@ -1312,10 +1349,10 @@ c write(*,*) 'Reusing num',j,nzoom,tx(2,j)
call ntuple(ddum(j),max(xbin_min,dble(int(tx(2,j)))),
$ min(xbin_max,dble(int(tx(2,j))+1)),j,ipole)

- if(max(xbin_min,dble(int(tx(2,j)))).gt.
- $ min(xbin_max,dble(int(tx(2,j))+1))) then
+c if(max(xbin_min,dble(int(tx(2,j)))).gt.
+c $ min(xbin_max,dble(int(tx(2,j))+1))) then
c write(*,*) 'not good'
- endif
+c endif

c write(*,'(2i6,4e15.5)') nzoom,j,ddum(j),tx(2,j),
c $ max(xbin_min,dble(int(tx(2,j)))),
@@ -1389,10 +1426,10 @@ c
endif
icount=icount+1
endif
- if (x .lt. xmin .or. x .gt. xmax) then
+c if (x .lt. xmin .or. x .gt. xmax) then
c write(*,'(a,4i4,2f24.16,1e10.2)') 'Bad x',ij,int(xbin_min),ip,
c & int(xbin_max),xmin,x,xmax-xmin
- endif
+c endif

wgt = wgt * xo * dble(xbin_max-xbin_min)
c print*,'Returning x',ij,ipole,j,x
diff --git b/epochX/cudacpp/gg_tt.mad/Source/genps.inc a/epochX/cudacpp/gg_tt.mad/Source/genps.inc
index a59181c70..af7e0efbc 100644
--- b/epochX/cudacpp/gg_tt.mad/Source/genps.inc
Expand Down
57 changes: 42 additions & 15 deletions epochX/cudacpp/gg_tt.mad/Source/dsample.f
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,20 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
c Local
c
integer im, ip,ij,icount,it_warned
double precision xbin_min,xbin_max,ddum(maxdim),xo,y
double precision xbin_min,xbin_max,ddum(maxdim),xo,y
c
c Local (performance optimization #969)
c
integer xbinarraydim
parameter (xbinarraydim=maxdim*lmaxconfigs)
double precision xbin_min0_array(maxdim, lmaxconfigs)
double precision xbin_max1_array(maxdim, lmaxconfigs)
logical xbin_min0_saved(maxdim, lmaxconfigs)
logical xbin_max1_saved(maxdim, lmaxconfigs)
save xbin_min0_array, xbin_max1_array
save xbin_min0_saved, xbin_max1_saved
data xbin_min0_saved/xbinarraydim*.false./
data xbin_max1_saved/xbinarraydim*.false./
c
c External
c
Expand Down Expand Up @@ -1301,15 +1314,29 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
endif
if (ituple .eq. 1) then
c write(*,*) 'Getting variable',ipole,j,minvar(j,ipole)
xbin_min = xbin(xmin,minvar(j,ipole))
xbin_max = xbin(xmax,minvar(j,ipole))
if (xbin_min .gt. xbin_max-1) then
c write(*,'(a,4e15.4)') 'Bad limits',xbin_min,xbin_max,
c & xmin,xmax
c xbin_max=xbin_min+1d-10
xbin_max = xbin(xmax,minvar(j,ipole))
xbin_min = min(xbin(xmin,minvar(j,ipole)), xbin_max)
endif

if(xmax.ne.1 .or. .not.xbin_max1_saved(j,ipole)) then
xbin_max = xbin(xmax, minvar(j,ipole))
if(xmax.eq.1) then
xbin_max1_array(j,ipole) = xbin_max
xbin_max1_saved(j,ipole) = .true.
endif
else
xbin_max = xbin_max1_array(j,ipole)
endif

if(xmin.ne.0 .or. .not.xbin_min0_saved(j,ipole)) then
xbin_min = xbin(xmin, minvar(j,ipole))
if (xbin_min .gt. xbin_max-1) then
xbin_min = min(xbin_min, xbin_max)
endif
if(xmin.eq.0) then
xbin_min0_array(j,ipole) = xbin_min
xbin_min0_saved(j,ipole) = .true.
endif
else
xbin_min = xbin_min0_array(j,ipole)
endif
c
c Line which allows us to keep choosing same x
c
Expand All @@ -1322,10 +1349,10 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
call ntuple(ddum(j),max(xbin_min,dble(int(tx(2,j)))),
$ min(xbin_max,dble(int(tx(2,j))+1)),j,ipole)

if(max(xbin_min,dble(int(tx(2,j)))).gt.
$ min(xbin_max,dble(int(tx(2,j))+1))) then
c if(max(xbin_min,dble(int(tx(2,j)))).gt.
c $ min(xbin_max,dble(int(tx(2,j))+1))) then
c write(*,*) 'not good'
endif
c endif

c write(*,'(2i6,4e15.5)') nzoom,j,ddum(j),tx(2,j),
c $ max(xbin_min,dble(int(tx(2,j)))),
Expand Down Expand Up @@ -1399,10 +1426,10 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
endif
icount=icount+1
endif
if (x .lt. xmin .or. x .gt. xmax) then
c if (x .lt. xmin .or. x .gt. xmax) then
c write(*,'(a,4i4,2f24.16,1e10.2)') 'Bad x',ij,int(xbin_min),ip,
c & int(xbin_max),xmin,x,xmax-xmin
endif
c endif

wgt = wgt * xo * dble(xbin_max-xbin_min)
c print*,'Returning x',ij,ipole,j,x
Expand Down
57 changes: 42 additions & 15 deletions epochX/cudacpp/pp_dy3j.mad/Source/dsample.f
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,20 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
c Local
c
integer im, ip,ij,icount,it_warned
double precision xbin_min,xbin_max,ddum(maxdim),xo,y
double precision xbin_min,xbin_max,ddum(maxdim),xo,y
c
c Local (performance optimization #969)
c
integer xbinarraydim
parameter (xbinarraydim=maxdim*lmaxconfigs)
double precision xbin_min0_array(maxdim, lmaxconfigs)
double precision xbin_max1_array(maxdim, lmaxconfigs)
logical xbin_min0_saved(maxdim, lmaxconfigs)
logical xbin_max1_saved(maxdim, lmaxconfigs)
save xbin_min0_array, xbin_max1_array
save xbin_min0_saved, xbin_max1_saved
data xbin_min0_saved/xbinarraydim*.false./
data xbin_max1_saved/xbinarraydim*.false./
c
c External
c
Expand Down Expand Up @@ -1301,15 +1314,29 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
endif
if (ituple .eq. 1) then
c write(*,*) 'Getting variable',ipole,j,minvar(j,ipole)
xbin_min = xbin(xmin,minvar(j,ipole))
xbin_max = xbin(xmax,minvar(j,ipole))
if (xbin_min .gt. xbin_max-1) then
c write(*,'(a,4e15.4)') 'Bad limits',xbin_min,xbin_max,
c & xmin,xmax
c xbin_max=xbin_min+1d-10
xbin_max = xbin(xmax,minvar(j,ipole))
xbin_min = min(xbin(xmin,minvar(j,ipole)), xbin_max)
endif

if(xmax.ne.1 .or. .not.xbin_max1_saved(j,ipole)) then
xbin_max = xbin(xmax, minvar(j,ipole))
if(xmax.eq.1) then
xbin_max1_array(j,ipole) = xbin_max
xbin_max1_saved(j,ipole) = .true.
endif
else
xbin_max = xbin_max1_array(j,ipole)
endif

if(xmin.ne.0 .or. .not.xbin_min0_saved(j,ipole)) then
xbin_min = xbin(xmin, minvar(j,ipole))
if (xbin_min .gt. xbin_max-1) then
xbin_min = min(xbin_min, xbin_max)
endif
if(xmin.eq.0) then
xbin_min0_array(j,ipole) = xbin_min
xbin_min0_saved(j,ipole) = .true.
endif
else
xbin_min = xbin_min0_array(j,ipole)
endif
c
c Line which allows us to keep choosing same x
c
Expand All @@ -1322,10 +1349,10 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
call ntuple(ddum(j),max(xbin_min,dble(int(tx(2,j)))),
$ min(xbin_max,dble(int(tx(2,j))+1)),j,ipole)

if(max(xbin_min,dble(int(tx(2,j)))).gt.
$ min(xbin_max,dble(int(tx(2,j))+1))) then
c if(max(xbin_min,dble(int(tx(2,j)))).gt.
c $ min(xbin_max,dble(int(tx(2,j))+1))) then
c write(*,*) 'not good'
endif
c endif

c write(*,'(2i6,4e15.5)') nzoom,j,ddum(j),tx(2,j),
c $ max(xbin_min,dble(int(tx(2,j)))),
Expand Down Expand Up @@ -1399,10 +1426,10 @@ subroutine sample_get_x_old(wgt, x, j, ipole, xmin, xmax)
endif
icount=icount+1
endif
if (x .lt. xmin .or. x .gt. xmax) then
c if (x .lt. xmin .or. x .gt. xmax) then
c write(*,'(a,4i4,2f24.16,1e10.2)') 'Bad x',ij,int(xbin_min),ip,
c & int(xbin_max),xmin,x,xmax-xmin
endif
c endif

wgt = wgt * xo * dble(xbin_max-xbin_min)
c print*,'Returning x',ij,ipole,j,x
Expand Down
Binary file not shown.

0 comments on commit a347f3f

Please sign in to comment.