33#ifndef __STDC_CONSTANT_MACROS
34#define __STDC_CONSTANT_MACROS
36#ifndef __STDC_LIMIT_MACROS
37#define __STDC_LIMIT_MACROS
48#include "CombBLAS/CombBLAS.h"
132 param.ifilename =
"";
133 param.isInputMM =
false;
134 param.ofilename =
"";
140 param.remove_isolated =
false;
141 param.randpermute = 0;
144 param.inflation = 0.0;
147 param.prunelimit = 1.0/10000.0;
149 param.recover_num = 1400;
150 param.recover_pct = .9;
151 param.kselectVersion = 1;
152 param.preprune =
false;
158 param.perProcessMem = 0;
159 param.isDoublePrecision =
true;
160 param.is64bInt =
true;
169 runinfo <<
"\n======================================" <<
endl;
170 runinfo <<
"Running HipMCL with the parameters: " <<
endl;
171 runinfo <<
"======================================" <<
endl;
174 runinfo <<
" input file type: " ;
185 runinfo <<
" Remove isolated vertices? : ";
190 runinfo <<
" Randomly permute vertices? : ";
201 runinfo <<
" Apply prune/select/recovery before the first iteration? : ";
217 runinfo <<
" Memory avilable per process: ";
220 if(
param.isDoublePrecision)
runinfo <<
"Using double precision floating point" <<
endl;
221 else runinfo <<
"Using single precision floating point" <<
endl;
223 else runinfo <<
"Using 32 bit local indexing" <<
endl;
226 runinfo <<
" Show matrices after major steps? : ";
229 runinfo <<
"======================================" <<
endl;
235 for (
int i = 1; i <
argc; i++)
240 else if (
strcmp(
argv[i],
"--matrix-market")==0){
241 param.isInputMM =
true;
249 else if (
strcmp(
argv[i],
"--remove-isolated")==0){
250 param.remove_isolated =
true;
252 else if (
strcmp(
argv[i],
"--tournament-select")==0){
253 param.kselectVersion = 1;
255 else if (
strcmp(
argv[i],
"--quick-select")==0){
256 param.kselectVersion = 2;
274 if(
param.recover_pct>1)
param.recover_pct/=100.00;
282 param.preprune =
true;
293 else if (
strcmp(
argv[i],
"-per-process-mem")==0) {
296 else if (
strcmp(
argv[i],
"--single-precision")==0) {
297 param.isDoublePrecision =
false;
299 else if (
strcmp(
argv[i],
"--32bit-local-index")==0) {
300 param.is64bInt =
false;
304 if(
param.ofilename==
"")
306 param.ofilename =
param.ifilename +
".hipmcl";
316 runinfo <<
"Usage: ./hipmcl -M <input filename> -I <inlfation> (required)" <<
endl;
318 runinfo <<
"======================================" <<
endl;
320 runinfo <<
"======================================" <<
endl;
325 runinfo <<
" -M <input file name (labeled triples format)> (mandatory)" <<
endl;
326 runinfo <<
" --matrix-market : if provided, the input file is in the matrix market format (default: the file is in labeled triples format)" <<
endl;
327 runinfo <<
" -base <index of the first vertex in the matrix market file, 0|1> (default: 1) " <<
endl;
328 runinfo <<
" -o <output filename> (default: input_file_name.hipmcl )" <<
endl;
331 runinfo <<
"-I <inflation> (mandatory)\n";
334 runinfo <<
" -rand <randomly permute vertices> (default:0)\n";
335 runinfo <<
" --remove-isolated : if provided, remove isolated vertices (default: don't remove isolated vertices)\n";
339 runinfo <<
" -p <cutoff> (default: 1/10000)\n";
340 runinfo <<
" -R <recovery number> (default: 1400)\n";
341 runinfo <<
" -pct <recovery pct> (default: 90)\n";
342 runinfo <<
" -S <selection number> (default: 1100)\n";
343 runinfo <<
" --preprune : if provided, apply prune/select/recovery before the first iteration (needed when dense columns are present) (default: don't preprune. However, if the average nonzero per column is larger than max{S,R}, prepruning is still applied by default)\n";
346 runinfo <<
" -layers <number of layers> (default:1)\n";
347 runinfo <<
" -compute <1 or 2> (default:1)\n";
348 runinfo <<
" -phases <number of phases> (default:1)\n";
349 runinfo <<
" -per-process-mem <memory (GB) available per process> (default:0, number of phases is not estimated)\n";
350 runinfo <<
" --single-precision (if not provided, use double precision floating point numbers)\n" <<
endl;
351 runinfo <<
" --32bit-local-index (if not provided, use 64 bit indexing for vertex ids)\n" <<
endl;
354 runinfo <<
" --show: show information about matrices after major steps (default: do not show matrices)" <<
endl;
358 runinfo <<
"======================================" <<
endl;
360 runinfo <<
"======================================" <<
endl;
361 runinfo <<
"Example with with a graph in labeled triples format on a laptop with 8GB memory and 8 cores:\nexport OMP_NUM_THREADS=8\nbin/hipmcl -M data/sevenvertexgraph.txt -I 2 -per-process-mem 8" <<
endl;
362 runinfo <<
"Same as above with 4 processes and 2 theaded per process cores:\nexport OMP_NUM_THREADS=2\nmpirun -np 4 bin/hipmcl -M data/sevenvertexgraph.txt -I 2 -per-process-mem 2" <<
endl;
363 runinfo <<
"Example with a graph in matrix market format:\nbin/hipmcl -M data/sevenvertex.mtx --matrix-market -base 1 -I 2 -per-process-mem 8" <<
endl;
365 runinfo <<
"Example on the NERSC/Cori system with 16 nodes, 4 process per node and 16 threads per process: \nsrun -N 16 -n 64 -c 16 bin/hipmcl -M data/hep-th.mtx --matrix-market -base 1 -per-process-mem 27 -o hep-th.hipmcl" <<
endl;
372template <
typename IT,
typename NT,
typename DER>
389template <
typename IT,
typename NT,
typename DER>
397template <
typename IT,
typename NT,
typename DER>
401 std::shared_ptr< SpParMat<IT, NT, DER> >
ALayer =
A3D.GetLayerMat();
407template <
typename IT,
typename NT,
typename DER>
423template <
typename IT,
typename NT,
typename DER>
427 std::shared_ptr< SpParMat<IT, NT, DER> >
ALayer =
A3D.GetLayerMat();
446template <
typename IT,
typename NT,
typename DER>
452template <
typename IT,
typename NT,
typename DER>
456 std::shared_ptr< SpParMat<IT, NT, DER> >
ALayer =
A3D.GetLayerMat();
463template <
typename IT,
typename NT,
typename DER>
476template <
typename IT,
typename NT,
typename DER>
496template <
typename IT,
typename NT,
typename DER>
500 if(
A.getnrow() ==
A.getncol())
503 p.iota(
A.getnrow(), 0);
514template <
typename IT,
typename NT,
typename DER>
517 if(
param.remove_isolated)
520 if(
param.randpermute)
537 param.preprune =
true;
541 SpParHelper::Print(
"Applying the prune/select/recovery logic before the first iteration\n\n");
559 if(
param.layers > 1) {
567 if(
param.layers > 1) {
573 if(
param.layers == 1){
574 A =
MemEfficientSpGEMM<PTFF, NT, DER>(
A,
A,
param.phases,
param.prunelimit, (
IT)
param.select, (
IT)
param.recover_num,
param.recover_pct,
param.kselectVersion, 1,
param.perProcessMem);
584 param.kselectVersion,
590 if(
param.layers == 1){
655 if(
param.layers == 1){
656 cout <<
"================detailed timing==================" <<
endl;
668 cout <<
"=================================================" <<
endl;
671 cout <<
"================detailed timing==================" <<
endl;
687 cout <<
"=================================================" <<
endl;
699template <
typename IT,
typename NT,
typename DER>
711template <
typename GIT,
typename LIT,
typename NT>
739 GIT nnz =
A.getnnz();
741 outs <<
"Number of vertices: " <<
nv <<
" number of edges: "<< nnz <<
endl;
784 s2 <<
"=================================================\n" <<
endl ;
796 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
821 if(
param.ifilename==
"" ||
param.inflation == 0.0)
832 if(
param.perProcessMem==0)
836 cout <<
"******** Number of phases will not be estimated as -per-process-mem option is not supplied. It is highly recommended that you provide -per-process-mem option for large-scale runs. *********** " <<
endl;
841 if(
param.isDoublePrecision)
848 else if(
param.is64bInt)
double mcl_localspgemmtime
double mcl_multiwaymergetime
double mcl_prunecolumntime
double mcl3d_symbolictime
void ShowParam(HipMCLParam ¶m)
double mcl3d_SUMMAmergetime
void RandPermute(SpParMat< IT, NT, DER > &A, HipMCLParam ¶m)
double cblas_transvectime
void MakeColStochastic(SpParMat< IT, NT, DER > &A)
double cblas_localspmvtime
void ProcessParam(int argc, char *argv[], HipMCLParam ¶m)
void InitParam(HipMCLParam ¶m)
FullyDistVec< IT, IT > HipMCL(SpParMat< IT, NT, DER > &A, HipMCLParam ¶m)
double cblas_allgathertime
double cblas_alltoalltime
void AdjustLoops(SpParMat< IT, NT, DER > &A)
double mcl3d_reductiontime
double mcl3d_conversiontime
void RemoveIsolated(SpParMat< IT, NT, DER > &A, HipMCLParam ¶m)
void Inflate(SpParMat< IT, NT, DER > &A, double power)
void MakeColStochastic3D(SpParMat3D< IT, NT, DER > &A3D)
NT Chaos(SpParMat< IT, NT, DER > &A)
double mcl3d_localspgemmtime
void MainBody(HipMCLParam ¶m)
NT Chaos3D(SpParMat3D< IT, NT, DER > &A3D)
void Inflate3D(SpParMat3D< IT, NT, DER > &A3D, double power)
double cblas_mergeconttime
FullyDistVec< IT, IT > Interpret(SpParMat< IT, NT, DER > &A)
static void Print(const std::string &s)
void MCLPruneRecoverySelect(SpParMat< IT, NT, DER > &A, NT hardThreshold, IT selectNum, IT recoverNum, NT recoverPct, int kselectVersion)
void WriteMCLClusters(std::string ofName, FullyDistVec< IT, IT > clustIdForVtx, FullyDistVec< IT, std::array< char, MAXVERTNAME > > vtxLabels)
void Symmetricize(PARMAT &A)
FullyDistVec< IT, IT > CC(SpParMat< IT, NT, DER > &A, IT &nCC)