Skip to content

Commit

Permalink
Move some files around (#14)
Browse files Browse the repository at this point in the history
* Update CMakeLists.txt

* Move examples to a new folder.
Change the location of some installation headers

* Update CI

* Update READMEs

* Update README
  • Loading branch information
RaulPPelaez authored May 4, 2024
1 parent 9cd23a2 commit 4b4e30b
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ jobs:
mkdir build && cd build
cmake -DCMAKE_VERBOSE_MAKEFILE=yes -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
make -j3 all install
- name: Compile examples
run: |
micromamba activate libmobility
mkdir examples/cpp/build && cd examples/cpp/build
cmake -DCMAKE_VERBOSE_MAKEFILE=yes -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
make -j3
- name: Try to import libMobility
run: |
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "third_party/uammd"]
path = third_party/uammd
path = include/third_party/uammd
url = https://github.com/raulppelaez/uammd
[submodule "third_party/LanczosAlgorithm"]
path = third_party/LanczosAlgorithm
path = include/third_party/LanczosAlgorithm
url = https://github.com/Raulppelaez/LanczosAlgorithm
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(libMobility)
enable_language(CUDA)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" "$ENV{CONDA_PREFIX}/share/cmake/Modules")
set(CMAKE_BUILD_TYPE Release)

#add_compile_definitions(PUBLIC MAXLOGLEVEL=15)
add_compile_definitions(PUBLIC MAXLOGLEVEL=3)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_SEPARABLE_COMPILATION OFF)
# Set CUDA archs so all supported GPUs are covered
set(CMAKE_CUDA_ARCHITECTURES "all")

#add_compile_definitions(PUBLIC DOUBLE_PRECISION)
set(UAMMD_INCLUDE third_party/uammd/src third_party/uammd/src/third_party)
set(UAMMD_INCLUDE include/third_party/uammd/src include/third_party/uammd/src/third_party)
# When UAMMD is available in conda-forge, use the following lines to find it instead of the above
# find_package(UAMMD REQUIRED)
# set(UAMMD_INCLUDE ${UAMMD_INCLUDE_DIR})
Expand Down Expand Up @@ -57,7 +59,7 @@ endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
include_directories(${UAMMD_INCLUDE} ${BLAS_INCLUDE_DIRS} ${LAPACKE_INCLUDE_DIRS})
include_directories(third_party/LanczosAlgorithm/include)
include_directories(include/third_party/LanczosAlgorithm/include)
include_directories(include)
link_libraries(${CUDA_LIBRARY})
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
Expand All @@ -81,6 +83,6 @@ IF (CMAKE_BUILD_TYPE MATCHES "Debug")
ENDIF()

# Install headers under include/ to the CMAKE_INSTALL_PREFIX include directory
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(DIRECTORY third_party/LanczosAlgorithm/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MobilityInterface)
install(DIRECTORY third_party/uammd/src/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/uammd/src)
install(DIRECTORY include/MobilityInterface DESTINATION ${CMAKE_INSTALL_PREFIX}/include/)
install(DIRECTORY include/third_party/LanczosAlgorithm/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MobilityInterface/)
install(DIRECTORY include/third_party/uammd/src/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/uammd/src)
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ For each solver, a python and a C++ interface are provided. All solvers have the

Some of the solvers have different functionalities than the others. For instance, some modules accept torques while others don't. The documentation for a particular solver must be visited to know more.

## How this repository is organized
## Repository Structure

The directory **solvers** contains a subfolder for each module. The folder for each solver the implementation of the libMobility interface for that solver.
The directory **python** contains the file libMobility.py, which can be imported giving access to all the compiled modules.
The directory **cpp** contains an example usage of the C++ interface to the modules.
The directory **include** contains the C++ base class and utilities used to construct the modules.
This repository is organized into the following directories:

- **solvers/**: This directory hosts a subfolder for each solver module. Each subfolder contains the implementation of the `libMobility` interface specific to that solver.

- **examples/**: Contains examples on how to use the library from Python and C++.

- **include/**: Includes the essential C++ base classes and utility files needed to construct the modules.

- **conda/**: Contains a meta.yaml file to build a conda package for libMobility using conda-build.

- **docs/**: Contains the source files for the documentation.

- **tests/**: Contains the tests for the library.

## The libMobility interface

Each solver is encased in a single class which is default constructible (no arguments required for its constructor).
Each solver provides the following set of functions (called the same in C++ and python and described here in a kind of language agnostic way):
* **[Constructor] (configuration)**: The solver constructors must be provided with a series of system-related parameters (see below).
Expand Down
13 changes: 13 additions & 0 deletions conda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Conda package

Create a conda package for libMobility with the following steps:

1. Install conda-build and conda-verify:
```bash
conda install conda-build
```

2. Build the package:
```bash
conda build .
```
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt → examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_SEPARABLE_COMPILATION OFF)
set(UAMMD_INCLUDE third_party/uammd/src third_party/uammd/src/third_party)
set(UAMMD_INCLUDE include/third_party/uammd/src include/third_party/uammd/src/third_party)
set(BLA_STATIC OFF)
set(BLA_VENDOR Intel10_64lp)
find_package(BLAS)
Expand Down
12 changes: 9 additions & 3 deletions cpp/README.md → examples/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ The code example.cpp showcases how a solver can be included and used with libMob


### Compilation
In order to succesfully compile example.cpp, ensure the Makefile in the root directory of the repo has generated the libraries for all the modules used (in this case ../solvers/NBody/mobility.so and ../solvers/PSE/mobility.so).

It is required to compile using the same precision as the libraries, so modify the Makefile if necessary (single precision is the default).
Running the Makefile at the root folder, instead of the one directly in this folder, will take care of that.
After [installing libMobility](https://libmobility.readthedocs.io) you can use CMake to compile this file:

```bash
mkdir build
cd build
cmake ..
make
```


### Running
A valid CUDA environment and a GPU are needed to run the example.
Expand Down
6 changes: 3 additions & 3 deletions cpp/example.cpp → examples/cpp/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
All available solvers are used in a similar way, providing, in each case, the required parameters.
For instance, a triply periodic algorithm will need at least a box size.
*/
#include "MobilityInterface/MobilityInterface.h"
#include"../solvers/NBody/mobility.h"
#include"../solvers/PSE/mobility.h"
#include"MobilityInterface/MobilityInterface.h"
#include"libMobility/solvers/NBody/mobility.h"
#include"libMobility/solvers/PSE/mobility.h"
#include <type_traits>
#include<vector>
#include<random>
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4b4e30b

Please sign in to comment.