Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Modernize CMake #28

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

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

jobs:

unix:

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
intsize: [32, 64]

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

steps:
- uses: actions/checkout@v4

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

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

- run: cmake -B build -DIDXTYPEWIDTH=${{ matrix.intsize }}
- run: cmake --build build --parallel

- run: ctest --test-dir build -V
Empty file removed .gitmodules
Empty file.
62 changes: 32 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
cmake_minimum_required(VERSION 2.8)
project(ParMETIS C)
cmake_minimum_required(VERSION 3.14...3.28)
project(ParMETIS LANGUAGES C)

# --- need METIS first
include(FetchContent)

# 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}")
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/scivision/GKlib.git
GIT_TAG 44630ca
GIT_SHALLOW true
)
FetchContent_MakeAvailable(GKlib)

FetchContent_Declare(metis_fc
GIT_REPOSITORY https://github.com/scivision/metis.git
GIT_TAG fd7799b
GIT_SHALLOW true
)

# Prepare libraries.
if(SHARED)
set(ParMETIS_LIBRARY_TYPE SHARED)
else()
set(ParMETIS_LIBRARY_TYPE STATIC)
FetchContent_MakeAvailable(metis_fc)

if(NOT DEFINED REALTYPEWIDTH)
set(REALTYPEWIDTH 32)
endif()
if(NOT DEFINED IDXTYPEWIDTH)
set(IDXTYPEWIDTH 32)
endif()
add_compile_definitions(REALTYPEWIDTH=${REALTYPEWIDTH} IDXTYPEWIDTH=${IDXTYPEWIDTH})

message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}
REALTYPEWIDTH=${REALTYPEWIDTH} IDXTYPEWIDTH=${IDXTYPEWIDTH}")
message(STATUS "METIS ${metis_fc_SOURCE_DIR}")
message(STATUS "GKlib ${gklib_SOURCE_DIR}")

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_subdirectory(libparmetis)
add_subdirectory(programs)

Expand Down
72 changes: 72 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"version": 6,

"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "release",
"configurePreset": "default",
"configuration": "Release"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true,
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false,
"timeout": 60
}
},
{
"name": "release", "inherits": "default",
"configuration": "Release"
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
}
]
},
{
"name": "release",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "release"
}
]
}
]
}
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
Loading