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

[test] Update catch to v2 and add install guidance #14

Merged
merged 2 commits into from
Jul 8, 2022
Merged
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
27 changes: 4 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(nvme)

find_package(Torch REQUIRED
PATHS $ENV{CMAKE_TORCH_PATH} # look here
NO_DEFAULT_PATH)
find_library(TORCH_PYTHON_LIBRARY torch_python PATHS $ENV{CMAKE_TORCH_PATH}/lib)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

find_library(URING PATHS $ENV{CMAKE_URING_PATH})

include_directories($ENV{CMAKE_AIO_PATH}/include)
link_directories($ENV{CMAKE_AIO_PATH}/lib)

include_directories($ENV{CMAKE_PYTHON_PATH}/include)
link_directories($ENV{CMAKE_PYTHON_PATH}/lib)

include_directories(csrc)
include_directories(csrc/include)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
include_directories(tests)

add_executable(test_asyncio tests/test_asyncio.cpp
csrc/include/asyncio.h
csrc/include/uring.h
csrc/include/aio.h
tests/catch.hpp
csrc/uring.cpp
csrc/aio.cpp)
target_link_libraries(test_asyncio "${TORCH_LIBRARIES}" uring aio python3 ${TORCH_PYTHON_LIBRARY})
target_link_libraries(test_asyncio uring aio)

add_executable(test_space_mgr tests/test_space_mgr.cpp
csrc/include/space_mgr.h
tests/catch.hpp
csrc/space_mgr.cpp)
target_link_libraries(test_space_mgr "${TORCH_LIBRARIES}" python3 ${TORCH_PYTHON_LIBRARY})
61 changes: 38 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,51 @@

- [liburing](https://github.com/axboe/liburing)
- [libaio](https://pagure.io/libaio)
- [libtorch](https://github.com/pytorch/pytorch)

## Install

You must install `liburing` and `libaio` first. You can install them through your package manager or from source code. We will introduce you how to install them from source code.

### Install liburing
```shell
git clone https://github.com/axboe/liburing.git
cd liburing
# If you have sudo privilege
./configure && make && sudo make install
# If you don't have sudo privilege
./configure --prefix=~/.local && make && make install
# "~/.local" can be replaced with any path
```

### Install libaio
```shell
git clone https://pagure.io/libaio.git
cd libaio
# If you have sudo privilege
sudo make prefix=/usr install
# If you don't have sudo privilege
make prefix=~/.local install
```

If you install `liburing` or `libaio` without `sudo`, you must set environment variables correctly. Here is an example code snippet in `~/.bashrc`:
```shell
export LIBRARY_PATH=$HOME/.local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$HOME/.local/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$HOME/.local/include:$CPLUS_INCLUDE_PATH
```

### Install colo_nvme

```shell
pip install -v --no-cache-dir -e .
```

## How to test

We have C++ test scrpits for `AsyncIO` and `SpaceManager` class. To run the tests:
We have C++ test scrpits for `AsyncIO` and `SpaceManager` class. Make sure you have installed `liburing` and `libaio`, and set environment variables correctly before testing. To run the tests:

```shell
export CMAKE_TORCH_PATH=/path/to/libtorch
export CMAKE_URING_PATH=/path/to/liburing
export CMAKE_AIO_PATH=/path/to/libaio
export CMAKE_PYTHON_PATH=/path/to/python
mkdir build
cd build
cmake ..
Expand All @@ -31,21 +59,8 @@ make
./test_space_mgr
```

Currently, we can save and load Pytorch Tensor:

```python
import torch
from colo_nvme import Offloader
x = torch.rand(2, 2)
print(x)
of = Offloader('test.pth', 4)
of.write(x, str(id(x)))
of.synchronize()
x.zero_()
print(x)
of.read(x, str(id(x)))
of.synchronize()
print(x)
```
We also have python unit tests. Make sure you have installed `pytest`. To run:

A `t.pth` will be generated to save the tensor.
```shell
pytest ./tests
```
Loading