Skip to content

Commit

Permalink
Update ParMETIS third party software (#132)
Browse files Browse the repository at this point in the history
* Add gklib and copy over new code.

* Set int and real widths to 32, setting to 64 does not work.

* Add some READMEs.
  • Loading branch information
ktbolt authored Nov 7, 2023
1 parent 2cc45d6 commit 9ea0ec5
Show file tree
Hide file tree
Showing 201 changed files with 47,395 additions and 27,863 deletions.
1 change: 1 addition & 0 deletions Code/CMake/SimVascularInternals.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(SV_LIBS
THIRDPARTY_METIS_SVFSI
THIRDPARTY_PARMETIS_SVFSI
THIRDPARTY_GKLIB_SVFSI
THIRDPARTY_TETGEN
THIRDPARTY_TINYXML
THIRDPARTY_ZLIB
Expand Down
1 change: 1 addition & 0 deletions Code/CMake/SimVascularOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ option(SV_USE_NOTIMER "Use notimer" ON)
# Solver Build Options (Modules)
option(SV_USE_EIGEN_SVFSI "Use Eigen headers" ON)
option(SV_USE_METIS_SVFSI "Use metis_svfsi Library" ON)
option(SV_USE_GKLIB_SVFSI "Use GKlib_svfsi Library" ON)
option(SV_USE_PARMETIS_SVFSI "Use parmetis_svfsi Library" ON)
option(SV_USE_TETGEN "Use tetgen Library" ON)

Expand Down
8 changes: 8 additions & 0 deletions Code/CMake/SimVascularThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#-----------------------------------------------------------------------------
# GKLIB_SVFSI
if(SV_USE_GKLIB_SVFSI)
set(USE_GKLIB_SVFSI ON)
simvascular_third_party(gklib_svfsi)
# require to be built here
set(GKLIB__SVFSI_LIBRARY ${SV_LIB_THIRDPARTY_GKLIB_SVFSI_NAME})
endif()

# METIS_SVFSI
if(SV_USE_METIS_SVFSI)
set(USE_METIS_SVFSI ON)
Expand Down
10 changes: 5 additions & 5 deletions Code/Source/svFSI/SPLIT.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
#include"parmetislib.h"

int split_(int *nElptr, int *eNoNptr, int *eNoNbptr, int *IEN,
int *nPartsPtr, idxtype *iElmdist, float *iWgt, idxtype *part)
int *nPartsPtr, idx_t *iElmdist, float *iWgt, idx_t *part)
{

int i, e, a, nEl=*nElptr, eNoN=*eNoNptr, eNoNb=*eNoNbptr,
nparts, nTasks=*nPartsPtr, wgtflag, numflag, ncon, task,
ncommonnodes, options[10], *exRanks, nExRanks, *map, edgecut;

float ubvec[MAXNCON], *wgt;
idxtype *eptr, *eind, *elmdist;
idx_t *eptr, *eind, *elmdist;

map = (int *)malloc(nTasks*sizeof(int));
exRanks = (int *)malloc(nTasks*sizeof(int));
wgt = (float *)malloc(nTasks*sizeof(float));
elmdist = (idxtype *)malloc((nTasks+1)*sizeof(idxtype));
elmdist = (idx_t *)malloc((nTasks+1)*sizeof(idx_t));
MPI_Group newGrp, tmpGrp;
MPI_Comm comm;

Expand Down Expand Up @@ -92,8 +92,8 @@ int split_(int *nElptr, int *eNoNptr, int *eNoNbptr, int *IEN,
return -1;
}

eptr = (idxtype *)malloc((nEl+1)*sizeof(idxtype));
eind = (idxtype *)malloc(nEl*eNoN*sizeof(idxtype));
eptr = (idx_t *)malloc((nEl+1)*sizeof(idx_t));
eind = (idx_t *)malloc(nEl*eNoN*sizeof(idx_t));

for (e=0; e<=nEl; e++) {
eptr[e] = e*eNoN;
Expand Down
4 changes: 2 additions & 2 deletions Code/Source/svFSI/distribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void distribute(Simulation* simulation)
auto& com_mod = simulation->com_mod;
auto& cm = com_mod.cm;

#define n_debug_distribute
#define debug_distribute
#ifdef debug_distribute
DebugMsg dmsg(__func__, com_mod.cm.idcm());
dmsg.banner();
Expand Down Expand Up @@ -1434,7 +1434,7 @@ void part_msh(Simulation* simulation, int iM, mshType& lM, Vector<int>& gmtl, in
int num_proc = cm.np();
int task_id = cm.idcm();

#define n_dbg_part_msh
#define dbg_part_msh
#ifdef dbg_part_msh
DebugMsg dmsg(__func__, com_mod.cm.idcm());
dmsg.banner();
Expand Down
2 changes: 0 additions & 2 deletions Code/ThirdParty/README

This file was deleted.

18 changes: 18 additions & 0 deletions Code/ThirdParty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This directory contains the source for external applications used by svFSIplus. The applications are compiled and liked with svFSIplus.

Each application has its own license agreement.

Applications

eigen - A header-only application for matrix objects.

gklib_svfsi - A library used by METIS and ParMETIS applications.

metis_svfsi - The METIS mesh partitioning application used by ParMETIS.

parmetis_svfsi - The ParMETIS parallel mesh partitioning application.

tetgen - A mesh generatin application.

tinyxml - A header-only application used to read and write XML files.

1 change: 1 addition & 0 deletions Code/ThirdParty/gklib_svfsi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simvascular_third_party(gklib_svfsi)
5 changes: 5 additions & 0 deletions Code/ThirdParty/gklib_svfsi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

The GKlib library contains various helper routines used by METIS and ParMETIS.

The METIS-v5.1.1-DistDGL-0.5 version of the source was downloaded from https://github.com/KarypisLab/GKlib.

37 changes: 37 additions & 0 deletions Code/ThirdParty/gklib_svfsi/simvascular_gklib_svfsi.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*=========================================================================
*
* Copyright (c) 2014-2015 The Regents of the University of California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* 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 COPYRIGHT OWNER
* 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.
*
*=========================================================================*/

#ifndef __simvascular_GKlib_svfsi_svfsi_h
#define __simvascular_GKlib_svfsi_svfsi_h

# hardcoded to build, update if want to allow system version
#include <simvascular_GKlib_svfsi/METISLib/metis.h>

#endif
41 changes: 41 additions & 0 deletions Code/ThirdParty/gklib_svfsi/simvascular_gklib_svfsi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 2.8.8)

project(GKLIB_SVFSI)

#set default build type to relwithdebinfo, also sets flags O2 on linux
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
mark_as_advanced(CMAKE_BUILD_TYPE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(WIN32)
add_definitions("/Zi")
add_definitions("-DWINDOWS")
endif()

include_directories(./)
include_directories(${MPI_C_INCLUDE_PATH})

set(CSRCS b64.c blas.c cache.c csr.c error.c evaluate.c
fkvkselect.c fs.c getopt.c gk_util.c gkregex.c graph.c
htable.c io.c itemsets.c mcore.c memory.c pqueue.c
random.c rw.c seq.c sort.c string.c timers.c tokenizer.c
)

if(SV_USE_THIRDPARTY_SHARED_LIBRARIES)
add_library(${GKLIB_SVFSI_LIBRARY_NAME} SHARED ${CSRCS})
else()
add_library(${GKLIB_SVFSI_LIBRARY_NAME} STATIC ${CSRCS})
endif()

if(SV_INSTALL_LIBS)
install(TARGETS ${GKLIB_SVFSI_LIBRARY_NAME}
RUNTIME DESTINATION ${SV_INSTALL_RUNTIME_DIR} COMPONENT ThirdPartyExecutables
LIBRARY DESTINATION ${SV_INSTALL_LIBRARY_DIR} COMPONENT ThirdPartyLibraries
ARCHIVE DESTINATION ${SV_INSTALL_ARCHIVE_DIR} COMPONENT ThirdPartyLibraries)
endif()

85 changes: 85 additions & 0 deletions Code/ThirdParty/gklib_svfsi/simvascular_gklib_svfsi/GKlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* GKlib.h
*
* George's library of most frequently used routines
*
* $Id: GKlib.h 14866 2013-08-03 16:40:04Z karypis $
*
*/

#ifndef _GKLIB_H_
#define _GKLIB_H_ 1

#define GKMSPACE

#if defined(_MSC_VER)
#define __MSC__
#endif
#if defined(__ICC)
#define __ICC__
#endif


#include "gk_arch.h" /*!< This should be here, prior to the includes */


/*************************************************************************
* Header file inclusion section
**************************************************************************/
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <memory.h>
#include <errno.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <time.h>
#include <string.h>
#include <limits.h>
#include <signal.h>
#include <setjmp.h>
#include <assert.h>
#include <sys/stat.h>

#if defined(__WITHPCRE__)
#include <pcreposix.h>
#else
#if defined(USE_GKREGEX)
#include "gkregex.h"
#else
#include <regex.h>
#endif /* defined(USE_GKREGEX) */
#endif /* defined(__WITHPCRE__) */



#if defined(__OPENMP__)
#include <omp.h>
#endif




#include <gk_types.h>
#include <gk_struct.h>
#include <gk_externs.h>
#include <gk_defs.h>
#include <gk_macros.h>
#include <gk_getopt.h>

#include <gk_mksort.h>
#include <gk_mkblas.h>
#include <gk_mkmemory.h>
#include <gk_mkpqueue.h>
#include <gk_mkpqueue2.h>
#include <gk_mkrandom.h>
#include <gk_mkutils.h>

#include <gk_proto.h>


#endif /* GKlib.h */


95 changes: 95 additions & 0 deletions Code/ThirdParty/gklib_svfsi/simvascular_gklib_svfsi/b64.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*!
\file b64.c
\brief This file contains some simple 8bit-to-6bit encoding/deconding routines
Most of these routines are outdated and should be converted using glibc's equivalent
routines.
\date Started 2/22/05
\author George
\version\verbatim $Id: b64.c 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
\verbatim
$Copyright$
$License$
\endverbatim
*/


#include "GKlib.h"

#define B64OFFSET 48 /* This is the '0' number */


/******************************************************************************
* Encode 3 '8-bit' binary bytes as 4 '6-bit' characters
*******************************************************************************/
void encodeblock(unsigned char *in, unsigned char *out)
{
out[0] = (in[0] >> 2);
out[1] = (((in[0] & 0x03) << 4) | (in[1] >> 4));
out[2] = (((in[1] & 0x0f) << 2) | (in[2] >> 6));
out[3] = (in[2] & 0x3f);

out[0] += B64OFFSET;
out[1] += B64OFFSET;
out[2] += B64OFFSET;
out[3] += B64OFFSET;

// printf("%c %c %c %c %2x %2x %2x %2x %2x %2x %2x\n", out[0], out[1], out[2], out[3], out[0], out[1], out[2], out[3], in[0], in[1], in[2]);
}

/******************************************************************************
* Decode 4 '6-bit' characters into 3 '8-bit' binary bytes
*******************************************************************************/
void decodeblock(unsigned char *in, unsigned char *out)
{
in[0] -= B64OFFSET;
in[1] -= B64OFFSET;
in[2] -= B64OFFSET;
in[3] -= B64OFFSET;

out[0] = (in[0] << 2 | in[1] >> 4);
out[1] = (in[1] << 4 | in[2] >> 2);
out[2] = (in[2] << 6 | in[3]);
}


/******************************************************************************
* This function encodes an input array of bytes into a base64 encoding. Memory
* for the output array is assumed to have been allocated by the calling program
* and be sufficiently large. The output string is NULL terminated.
*******************************************************************************/
void GKEncodeBase64(int nbytes, unsigned char *inbuffer, unsigned char *outbuffer)
{
int i, j;

if (nbytes%3 != 0)
gk_errexit(SIGERR, "GKEncodeBase64: Input buffer size should be a multiple of 3! (%d)\n", nbytes);

for (j=0, i=0; i<nbytes; i+=3, j+=4)
encodeblock(inbuffer+i, outbuffer+j);

//printf("%d %d\n", nbytes, j);
outbuffer[j] = '\0';
}



/******************************************************************************
* This function decodes an input array of base64 characters into their actual
* 8-bit codes. Memory * for the output array is assumed to have been allocated
* by the calling program and be sufficiently large. The padding is discarded.
*******************************************************************************/
void GKDecodeBase64(int nbytes, unsigned char *inbuffer, unsigned char *outbuffer)
{
int i, j;

if (nbytes%4 != 0)
gk_errexit(SIGERR, "GKDecodeBase64: Input buffer size should be a multiple of 4! (%d)\n", nbytes);

for (j=0, i=0; i<nbytes; i+=4, j+=3)
decodeblock(inbuffer+i, outbuffer+j);
}

Loading

0 comments on commit 9ea0ec5

Please sign in to comment.