Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ci

on:
push:
paths:
- "**.c"
- "**.cmake"
- "**/CMakeLists.txt"
- ".github/workflows/ci.yml"
workflow_dispatch:

# avoid wasted runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

unix:

strategy:
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}
timeout-minutes: 5

steps:
- &mpi-linux
name: Install MPI (Linux)
if: ${{ runner.os == 'Linux' }}
run: sudo apt install libopenmpi-dev

- &mpi-macos
name: Install MPI (MacOS)
if: ${{ runner.os == 'macOS' }}
run: brew install open-mpi

- &checkout
uses: actions/checkout@v6

- run: cmake --workflow default

int64:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- *mpi-linux
- *checkout

- run: cmake --workflow int64
Empty file removed .gitmodules
Empty file.
76 changes: 46 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
cmake_minimum_required(VERSION 2.8)
project(ParMETIS C)
cmake_minimum_required(VERSION 3.21...4.3)

if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED ENV{CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug or Release")
endif()

# Search for MPI.
# GK commented this out as it seems to be creating problems
# include(FindMPI)
# if(NOT MPI_FOUND)
# message(FATAL_ERROR "mpi is not found")
# endif()
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_COMPILE_FLAGS}")
project(PARMETIS LANGUAGES C VERSION 1.0.0)

# --- need METIS first
include(GNUInstallDirs)
include(FetchContent)

# Prepare libraries.
if(SHARED)
set(ParMETIS_LIBRARY_TYPE SHARED)
else()
set(ParMETIS_LIBRARY_TYPE STATIC)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND PARMETIS_IS_TOP_LEVEL)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/local" CACHE PATH "install prefix" FORCE)
endif()

message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION} install prefix ${CMAKE_INSTALL_PREFIX}")

set(metis_url "https://github.com/scivision/METIS/archive/456244e99d7f0027706033d18bc1b3424d3507cc.tar.gz")
FetchContent_Declare(METIS URL ${metis_url})
FetchContent_MakeAvailable(METIS)

set(CMAKE_C_STANDARD 99)

add_compile_definitions(
"REALTYPEWIDTH=$<IF:$<BOOL:${REALTYPEWIDTH}>,${REALTYPEWIDTH},32>"
"IDXTYPEWIDTH=$<IF:$<BOOL:${IDXTYPEWIDTH}>,${IDXTYPEWIDTH},32>"
)

find_package(MPI REQUIRED)

include(./conf/gkbuild.cmake)

# List of paths that the compiler will search for header files.
# i.e., the -I equivalent
include_directories(include)
include_directories(${MPI_INCLUDE_PATH})
include_directories(${GKLIB_PATH}/include)
include_directories(${METIS_PATH}/include)
include_directories(${CMAKE_INSTALL_PREFIX}/include)

# List of paths that the compiler will search for library files.
# i.e., the -L equivalent
link_directories(${GKLIB_PATH}/lib)
link_directories(${METIS_PATH}/lib)
link_directories(${CMAKE_INSTALL_PREFIX}/lib)

# List of directories that cmake will look for CMakeLists.txt
add_subdirectory(include)
install(FILES include/parmetis.h TYPE INCLUDE)

add_library(parmetis)
target_include_directories(parmetis PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include;${PROJECT_SOURCE_DIR}/libparmetis;${metis_BINARY_DIR}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(parmetis PRIVATE MPI::MPI_C METIS::METIS)

if(SHARED)
target_link_libraries(parmetis PRIVATE metis GKlib)
endif()

add_library(PARMETIS::PARMETIS ALIAS parmetis)

install(TARGETS parmetis EXPORT ${PROJECT_NAME}-targets)

add_subdirectory(libparmetis)
add_subdirectory(programs)

# This is for testing during development and is not being distributed
#add_subdirectory(test)

include(cmake/install.cmake)

file(GENERATE OUTPUT .gitignore CONTENT "*")
56 changes: 56 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"version": 6,

"configurePresets": [
{
"name": "default",
"binaryDir": "build",
"installDir": "${fileDir}/build/local",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"REALTYPEWIDTH": "32",
"IDXTYPEWIDTH": "32"
}
},
{ "name": "int64", "inherits": "default",
"cacheVariables": {
"IDXTYPEWIDTH": "64"
}
}
],
"buildPresets": [
{ "name": "default", "configurePreset": "default", "jobs": 0 },
{ "name": "int64", "configurePreset": "int64", "inherits": "default" }
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true,
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false
}
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{ "type": "configure", "name": "default" },
{ "type": "build", "name": "default" }
]
},
{
"name": "int64",
"steps": [
{ "type": "configure", "name": "int64" },
{ "type": "build", "name": "int64" }
]
}
]
}
78 changes: 10 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,26 @@
# ParMETIS
# ParMETIS

ParMETIS is an MPI-based library for partitioning graphs, partitioning finite element meshes,
and producing fill reducing orderings for sparse matrices. The algorithms implemented in
ParMETIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint
[![ci](https://github.com/scivision/ParMETIS/actions/workflows/ci.yml/badge.svg)](https://github.com/scivision/ParMETIS/actions/workflows/ci.yml)

ParMETIS is an MPI-based library for partitioning graphs, partitioning finite element meshes,
and producing fill reducing orderings for sparse matrices. The algorithms implemented in
ParMETIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint
partitioning schemes developed in our lab.

## Downloading ParMETIS
## Downloading ParMETIS

You can download ParMETIS by simply cloning it using the command:
```
git clone https://github.com/KarypisLab/ParMETIS.git
```

## Building the ParMETIS library

To build ParMETIS you can follow the instructions below:

### Dependencies

General dependencies for building ParMETIS are: gcc, cmake, build-essential, and an MPI library.
In Ubuntu systems these can be obtained from the apt package manager (e.g., apt-get install cmake, mpich, etc)

```
sudo apt-get install build-essential
sudo apt-get install cmake
```

In addition, you need to download and install
[GKlib](https://github.com/KarypisLab/GKlib) and
[METIS](https://github.com/KarypisLab/METIS) by following the instructions there.


### Building and installing ParMETIS

ParMETIS is primarily configured by passing options to make config. For example:

```
make config cc=mpicc prefix=~/local
make install
```sh
cmake --workflow --preset default
```

will configure ParMETIS to be built using mpicc and then install the binaries, header files, and libraries at

```
~/local/bin
~/local/include
~/local/lib
```

directories, respectively.

### Common configuration options are:

cc=[compiler] - The C compiler to use [default is determined by CMake]
shared=1 - Build a shared library instead of a static one [off by default]
prefix=[PATH] - Set the installation prefix [~/local by default]
gklib_path=[PATH] - Set the prefix path where GKlib has been installed. You can skip
this if GKlib's installation prefix is the same as that of ParMETIS.
metis_path=[PATH] - Set the prefix path where METIS has been installed. You can skip
this if METIS' installation prefix is the same as that of ParMETIS.

### Advanced debugging related options:

gdb=1 - Build with support for GDB [off by default]
debug=1 - Enable debugging support [off by default]
assert=1 - Enable asserts [off by default]
assert2=1 - Enable very expensive asserts [off by default]

### Other make commands

make uninstall
Removes all files installed by 'make install'.

make clean
Removes all object files but retains the configuration options.

make distclean
Performs clean and completely removes the build directory.


### Definitions of supported data types
Expand All @@ -85,8 +29,6 @@ ParMETIS uses the same data types for integers and floating point numbers (32/64
integers and single/double precision floating point numbers) as used when configuring
and building METIS.


## Copyright & License Notice
Copyright 1998-2020, Regents of the University of Minnesota


Copyright 1998-2020, Regents of the University of Minnesota
7 changes: 7 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

find_dependency(metis CONFIG)

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)

check_required_components(@PROJECT_NAME@)
50 changes: 50 additions & 0 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# --- BOILERPLATE: install / packaging

include(CMakePackageConfigHelpers)

configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION cmake
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)

install(EXPORT ${PROJECT_NAME}-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION cmake
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION cmake
)

# # allow use of package from build directory without installing
export(EXPORT ${PROJECT_NAME}-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
)

# --- CPack

set(CPACK_GENERATOR "TBZ2")
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package)

# not .gitignore as its regex syntax is more advanced than CMake
set(CPACK_SOURCE_IGNORE_FILES .git/ .github/ .vscode/ _CPack_Packages/
${CMAKE_BINARY_DIR}/ ${PROJECT_BINARY_DIR}/
archive/ concepts/
)

install(FILES ${CPACK_RESOURCE_FILE_README} ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION share/docs/${PROJECT_NAME}
)

include(CPack)
Loading