Skip to content

Commit

Permalink
Merge pull request #22 from paklui/bidir
Browse files Browse the repository at this point in the history
Add bi-directional bcast as option
  • Loading branch information
reger-men authored Sep 2, 2022
2 parents fe0c948 + b72fcca commit 0cc18d3
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ src/pgesv/HPL_pdupdateNT.cpp
src/pgesv/HPL_pdupdateNN.cpp src/pgesv/HPL_pdupdateTN.cpp src/pgesv/HPL_pdupdateTT.cpp
src/pgesv/HPL_pdupdateTN.cpp src/pgesv/HPL_pdupdateTT.cpp
src/pauxil/HPL_pwarn.cpp src/comm/HPL_bcast.cpp src/comm/HPL_blong.cpp
src/comm/HPL_blonM.cpp src/comm/HPL_1ring.cpp src/comm/HPL_2ring.cpp
src/comm/HPL_blonM.cpp src/comm/HPL_bidir.cpp src/comm/HPL_1ring.cpp src/comm/HPL_2ring.cpp
src/comm/HPL_1rinM.cpp src/comm/HPL_2rinM.cpp src/comm/HPL_packL.cpp
src/comm/HPL_sdrv.cpp src/comm/HPL_send.cpp src/pgesv/HPL_pdlaswp00N.cpp
src/comm/HPL_recv.cpp src/grid/HPL_reduce.cpp src/comm/HPL_binit.cpp
Expand Down
7 changes: 6 additions & 1 deletion include/hpl_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ typedef enum
HPL_2RING_M = 404, /* Increasing 2-ring (modified) */
HPL_BLONG = 405, /* long broadcast */
HPL_BLONG_M = 406, /* long broadcast (modified) */
HPL_IBCAST = 407 /* default bcast in MPI */
HPL_IBCAST = 407, /* default bcast in MPI */
HPL_BIDIR = 408, /* bidirectional */
} HPL_T_TOP;
/*
* ---------------------------------------------------------------------
Expand Down Expand Up @@ -160,6 +161,10 @@ int HPL_binit_blonM STDC_ARGS( ( HPL_T_panel * ) );
int HPL_bcast_blonM STDC_ARGS( ( HPL_T_panel *, int * ) );
int HPL_bwait_blonM STDC_ARGS( ( HPL_T_panel * ) );

int HPL_binit_bidir STDC_ARGS( ( HPL_T_panel * ) );
int HPL_bcast_bidir STDC_ARGS( ( HPL_T_panel *, int * ) );
int HPL_bwait_bidir STDC_ARGS( ( HPL_T_panel * ) );

#endif
/*
* End of hpl_comm.h
Expand Down
4 changes: 3 additions & 1 deletion makes/Make.comm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ INCdep = \
#
HPL_comobj = \
HPL_1ring.o HPL_1rinM.o HPL_2ring.o \
HPL_2rinM.o HPL_blong.o HPL_blonM.o \
HPL_2rinM.o HPL_blong.o HPL_bidir.o HPL_blonM.o \
HPL_packL.o HPL_copyL.o HPL_binit.o \
HPL_bcast.o HPL_bwait.o HPL_send.o \
HPL_recv.o HPL_sdrv.o
Expand Down Expand Up @@ -84,6 +84,8 @@ HPL_2rinM.o : ../HPL_2rinM.cpp $(INCdep)
$(CC) -o $@ -c $(CCFLAGS) ../HPL_2rinM.cpp
HPL_blong.o : ../HPL_blong.cpp $(INCdep)
$(CC) -o $@ -c $(CCFLAGS) ../HPL_blong.cpp
HPL_bidir.o : ../HPL_bidir.cpp $(INCdep)
$(CC) -o $@ -c $(CCFLAGS) ../HPL_bidir.cpp
HPL_blonM.o : ../HPL_blonM.cpp $(INCdep)
$(CC) -o $@ -c $(CCFLAGS) ../HPL_blonM.cpp
HPL_packL.o : ../HPL_packL.cpp $(INCdep)
Expand Down
4 changes: 2 additions & 2 deletions scripts/config/HPL_8GPU.dat
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ HPL.out output file name (if any)
2 NDIVs
1 # of recursive panel fact.
2 RFACTs (0=left, 1=Crout, 2=Right)
1 # of broadcast
6 BCASTs (0=1rg,1=1rM,2=2rg,3=2rM,4=Lng,5=LnM,6=ibcast)
8 # of broadcast
6 BCASTs (0=1rg,1=1rM,2=2rg,3=2rM,4=Lng,5=LnM,6=ibcast,7=BiDir)
1 # of lookahead depth
1 DEPTHs (>=0)
1 SWAP (0=bin-exch,1=long,2=mix)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ blas/HPL_dscal.c blas/HPL_dtrsm.c blas/HPL_dtrsv.c blas/HPL_idamax.c \
blas/HPL_dgemv.c blas/HPL_dscal.c blas/HPL_daxpy.c \
blas/HPL_dcopy.c blas/HPL_dgemm.c blas/HPL_dgemv.c blas/HPL_dger.c \
comm/HPL_sdrv.c comm/HPL_send.c comm/HPL_recv.c comm/HPL_bcast.c \
comm/HPL_binit.c comm/HPL_bwait.c comm/HPL_blong.c comm/HPL_1ring.c \
comm/HPL_binit.c comm/HPL_bwait.c comm/HPL_blong.c comm/HPL_bidir.c comm/HPL_1ring.c \
comm/HPL_1rinM.c comm/HPL_2rinM.c comm/HPL_2ring.c comm/HPL_blonM.c comm/HPL_packL.c \
grid/HPL_reduce.c grid/HPL_sum.c grid/HPL_grid_info.c grid/HPL_grid_init.c \
grid/HPL_all_reduce.c grid/HPL_broadcast.c grid/HPL_grid_exit.c grid/HPL_max.c \
Expand Down
9 changes: 8 additions & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ am_libhpl_a_OBJECTS = auxil/HPL_dlatcpy.$(OBJEXT) \
comm/HPL_recv.$(OBJEXT) comm/HPL_bcast.$(OBJEXT) \
comm/HPL_binit.$(OBJEXT) comm/HPL_bwait.$(OBJEXT) \
comm/HPL_blong.$(OBJEXT) comm/HPL_1ring.$(OBJEXT) \
comm/HPL_bidir.$(OBJEXT) \
comm/HPL_1rinM.$(OBJEXT) comm/HPL_2rinM.$(OBJEXT) \
comm/HPL_2ring.$(OBJEXT) comm/HPL_blonM.$(OBJEXT) \
comm/HPL_packL.$(OBJEXT) grid/HPL_reduce.$(OBJEXT) \
Expand Down Expand Up @@ -229,6 +230,7 @@ am__depfiles_remade = auxil/$(DEPDIR)/HPL_dlacpy.Po \
comm/$(DEPDIR)/HPL_2rinM.Po comm/$(DEPDIR)/HPL_2ring.Po \
comm/$(DEPDIR)/HPL_bcast.Po comm/$(DEPDIR)/HPL_binit.Po \
comm/$(DEPDIR)/HPL_blonM.Po comm/$(DEPDIR)/HPL_blong.Po \
comm/$(DEPDIR)/HPL_bidir.Po \
comm/$(DEPDIR)/HPL_bwait.Po comm/$(DEPDIR)/HPL_packL.Po \
comm/$(DEPDIR)/HPL_recv.Po comm/$(DEPDIR)/HPL_sdrv.Po \
comm/$(DEPDIR)/HPL_send.Po grid/$(DEPDIR)/HPL_all_reduce.Po \
Expand Down Expand Up @@ -428,7 +430,7 @@ blas/HPL_dscal.c blas/HPL_dtrsm.c blas/HPL_dtrsv.c blas/HPL_idamax.c \
blas/HPL_dgemv.c blas/HPL_dscal.c blas/HPL_daxpy.c \
blas/HPL_dcopy.c blas/HPL_dgemm.c blas/HPL_dgemv.c blas/HPL_dger.c \
comm/HPL_sdrv.c comm/HPL_send.c comm/HPL_recv.c comm/HPL_bcast.c \
comm/HPL_binit.c comm/HPL_bwait.c comm/HPL_blong.c comm/HPL_1ring.c \
comm/HPL_binit.c comm/HPL_bwait.c comm/HPL_blong.c comm/HPL_bidir.c comm/HPL_1ring.c \
comm/HPL_1rinM.c comm/HPL_2rinM.c comm/HPL_2ring.c comm/HPL_blonM.c comm/HPL_packL.c \
grid/HPL_reduce.c grid/HPL_sum.c grid/HPL_grid_info.c grid/HPL_grid_init.c \
grid/HPL_all_reduce.c grid/HPL_broadcast.c grid/HPL_grid_exit.c grid/HPL_max.c \
Expand Down Expand Up @@ -583,6 +585,8 @@ comm/HPL_bwait.$(OBJEXT): comm/$(am__dirstamp) \
comm/$(DEPDIR)/$(am__dirstamp)
comm/HPL_blong.$(OBJEXT): comm/$(am__dirstamp) \
comm/$(DEPDIR)/$(am__dirstamp)
comm/HPL_bidir.$(OBJEXT): comm/$(am__dirstamp) \
comm/$(DEPDIR)/$(am__dirstamp)
comm/HPL_1ring.$(OBJEXT): comm/$(am__dirstamp) \
comm/$(DEPDIR)/$(am__dirstamp)
comm/HPL_1rinM.$(OBJEXT): comm/$(am__dirstamp) \
Expand Down Expand Up @@ -818,6 +822,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_binit.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_blonM.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_blong.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_bidir.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_bwait.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_packL.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@comm/$(DEPDIR)/HPL_recv.Po@am__quote@ # am--include-marker
Expand Down Expand Up @@ -1086,6 +1091,7 @@ distclean: distclean-am
-rm -f comm/$(DEPDIR)/HPL_binit.Po
-rm -f comm/$(DEPDIR)/HPL_blonM.Po
-rm -f comm/$(DEPDIR)/HPL_blong.Po
-rm -f comm/$(DEPDIR)/HPL_bidir.Po
-rm -f comm/$(DEPDIR)/HPL_bwait.Po
-rm -f comm/$(DEPDIR)/HPL_packL.Po
-rm -f comm/$(DEPDIR)/HPL_recv.Po
Expand Down Expand Up @@ -1233,6 +1239,7 @@ maintainer-clean: maintainer-clean-am
-rm -f comm/$(DEPDIR)/HPL_binit.Po
-rm -f comm/$(DEPDIR)/HPL_blonM.Po
-rm -f comm/$(DEPDIR)/HPL_blong.Po
-rm -f comm/$(DEPDIR)/HPL_bidir.Po
-rm -f comm/$(DEPDIR)/HPL_bwait.Po
-rm -f comm/$(DEPDIR)/HPL_packL.Po
-rm -f comm/$(DEPDIR)/HPL_recv.Po
Expand Down
1 change: 1 addition & 0 deletions src/comm/HPL_bcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int HPL_bcast
case HPL_BLONG_M : ierr = HPL_bcast_blonM( PANEL, IFLAG ); break;
case HPL_BLONG : ierr = HPL_bcast_blong( PANEL, IFLAG ); break;
case HPL_IBCAST : ierr = HPL_BE_bcast_ibcast( PANEL, IFLAG, HPL_TR); break;
case HPL_BIDIR : ierr = HPL_bcast_bidir( PANEL, IFLAG ); break;
default : ierr = HPL_SUCCESS;
}

Expand Down
250 changes: 250 additions & 0 deletions src/comm/HPL_bidir.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
/*
* -- High Performance Computing Linpack Benchmark (HPL)
* HPL - 2.3 - December 2, 2018
* Antoine P. Petitet
* University of Tennessee, Knoxville
* Innovative Computing Laboratory
* (C) Copyright 2000-2008 All Rights Reserved
*
* -- Copyright notice and Licensing terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgement:
* This product includes software developed at the University of
* Tennessee, Knoxville, Innovative Computing Laboratory.
*
* 4. The name of the University, the name of the Laboratory, or the
* names of its contributors may not be used to endorse or promote
* products derived from this software without specific written
* permission.
*
* -- Disclaimer:
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ---------------------------------------------------------------------
*/
/*
* Include files
*/
#include "hpl.h"

#ifdef HPL_NO_MPI_DATATYPE /* The user insists to not use MPI types */
#ifndef HPL_COPY_L /* and also want to avoid the copy of L ... */
#define HPL_COPY_L /* well, sorry, can not do that: force the copy */
#endif
#endif

#ifdef ROCM
#define L2ptr PANEL->dL2
#else
#define L2ptr PANEL->L2
#endif

#ifdef STDC_HEADERS
int HPL_binit_bidir
(
HPL_T_panel * PANEL
)
#else
int HPL_binit_bidir( PANEL )
HPL_T_panel * PANEL;
#endif
{
#ifdef HPL_USE_MPI_DATATYPE
/*
* .. Local Variables ..
*/
int ierr;
#endif
/* ..
* .. Executable Statements ..
*/
if( PANEL == NULL ) { return( HPL_SUCCESS ); }
if( PANEL->grid->npcol <= 1 ) { return( HPL_SUCCESS ); }
#ifdef HPL_USE_MPI_DATATYPE
#ifdef HPL_COPY_L
/*
* Copy the panel into a contiguous buffer
*/
HPL_copyL( PANEL );
#endif
/*
* Create the MPI user-defined data type
*/
ierr = HPL_packL( PANEL, 0, PANEL->len, 0 );

return( ( ierr == MPI_SUCCESS ? HPL_SUCCESS : HPL_FAILURE ) );
#else
/*
* Force the copy of the panel into a contiguous buffer
*/
HPL_copyL( PANEL );

return( HPL_SUCCESS );
#endif
}

#ifdef HPL_USE_MPI_DATATYPE

#define _M_BUFF PANEL->buffers[0]
#define _M_COUNT PANEL->counts[0]
#define _M_TYPE PANEL->dtypes[0]

#else

#define _M_BUFF (void *)(L2ptr)
#define _M_COUNT PANEL->len
#define _M_TYPE MPI_DOUBLE

#endif

int recv_from_bi(int id, int np, int root, int prev, int next);
int send_to_bi(int id, int np, int root, int prev, int next);

#ifdef STDC_HEADERS
int HPL_bcast_bidir
(
HPL_T_panel * PANEL,
int * IFLAG
)
#else
int HPL_bcast_bidir( PANEL, IFLAG )
HPL_T_panel * PANEL;
int * IFLAG;
#endif
{
/*
* .. Local Variables ..
*/
MPI_Comm comm;
int ierr, go, next, msgid, partner, rank,
roo2, root, size;
/* ..
* .. Executable Statements ..
*/
if( PANEL == NULL ) { *IFLAG = HPL_SUCCESS; return( HPL_SUCCESS ); }
if( ( size = PANEL->grid->npcol ) <= 1 )
{ *IFLAG = HPL_SUCCESS; return( HPL_SUCCESS ); }
/*
* Cast phase: root process send to its right neighbor and mid-process.
* If I am not the root process, probe for message. If the message is
* there, then receive it, and if I am not the last process of both
* rings, then forward it to the next. Otherwise, inform the caller that
* the panel has still not been received.
*/
rank = PANEL->grid->mycol; comm = PANEL->grid->row_comm;
root = PANEL->pcol; msgid = PANEL->msgid;
int prev = (rank - 1 + size) % size;
next = (rank + 1) % size;

if( rank == root )
{
ierr = MPI_Send( _M_BUFF, _M_COUNT, _M_TYPE, next, msgid, comm );
if( ( ierr == MPI_SUCCESS ) && ( size > 2 ) )
{
ierr = MPI_Send( _M_BUFF, _M_COUNT, _M_TYPE, prev, msgid,
comm );
}
}
else
{
partner = recv_from_bi(rank, size, root, prev, next);

ierr = MPI_Iprobe( partner, msgid, comm, &go, &PANEL->status[0] );

if( ierr == MPI_SUCCESS )
{
if( go != 0 )
{
ierr = MPI_Recv( _M_BUFF, _M_COUNT, _M_TYPE, partner, msgid,
comm, &PANEL->status[0] );
int si = send_to_bi(rank, size, root, prev, next);
if( ( ierr == MPI_SUCCESS ) &&
(si >= 0) )
{
ierr = MPI_Send( _M_BUFF, _M_COUNT, _M_TYPE, next, msgid,
comm );
}
}
else { *IFLAG = HPL_KEEP_TESTING; return( *IFLAG ); }
}
}
/*
* If the message was received and being forwarded, return HPL_SUCCESS.
* If an error occured in an MPI call, return HPL_FAILURE.
*/
*IFLAG = ( ierr == MPI_SUCCESS ? HPL_SUCCESS : HPL_FAILURE );

return( *IFLAG );
}

#ifdef STDC_HEADERS
int HPL_bwait_bidir
(
HPL_T_panel * PANEL
)
#else
int HPL_bwait_bidir( PANEL )
HPL_T_panel * PANEL;
#endif
{
#ifdef HPL_USE_MPI_DATATYPE
/*
* .. Local Variables ..
*/
int ierr;
#endif
/* ..
* .. Executable Statements ..
*/
if( PANEL == NULL ) { return( HPL_SUCCESS ); }
if( PANEL->grid->npcol <= 1 ) { return( HPL_SUCCESS ); }
/*
* Release the arrays of request / status / data-types and buffers
*/
#ifdef HPL_USE_MPI_DATATYPE
ierr = MPI_Type_free( &PANEL->dtypes[0] );

return( ( ierr == MPI_SUCCESS ? HPL_SUCCESS : HPL_FAILURE ) );
#else
return( HPL_SUCCESS );
#endif
}

int send_to_bi(int id, int np, int root, int prev, int next)
{
int end = np / 2;
int tid = (id < root ? id + np - root : id - root);

if (tid < end) return next;
else if (tid > end + 1) return prev;
else return -1;
}

int recv_from_bi(int id, int np, int root, int prev, int next)
{
int end = np / 2;
int tid = (id < root ? id + np - root : id - root);
return (tid <= end ? prev : next);
}
1 change: 1 addition & 0 deletions src/comm/HPL_binit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ int HPL_binit
case HPL_BLONG_M : ierr = HPL_binit_blonM( PANEL ); break;
case HPL_BLONG : ierr = HPL_binit_blong( PANEL ); break;
case HPL_IBCAST : ierr = HPL_BE_binit_ibcast(PANEL, HPL_TR); break;
case HPL_BIDIR : ierr = HPL_binit_bidir( PANEL ); break;
default : ierr = HPL_SUCCESS;
}

Expand Down
Loading

0 comments on commit 0cc18d3

Please sign in to comment.