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

version 0.9.6 #99

Merged
merged 6 commits into from
Nov 30, 2024
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
68 changes: 0 additions & 68 deletions .clang-format

This file was deleted.

119 changes: 119 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build and Test
on: [ pull_request ]

concurrency:
group: tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-run-tests:
strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-22.04
compiler: clang-17
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.compiler }})
steps:
- name: Install tools
run: |
sudo apt-get install -y wget unzip

- name: Add repos for for gcc-13 and clang-17
run: |
# gcc-13
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

# clang-17
source /etc/os-release
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-17 main" | sudo tee /etc/apt/sources.list.d/llvm-17.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/llvm.gpg > /dev/null

- name: Ensure stdlib version
run: |
sudo apt-get install -y libstdc++-13-dev

- name: Get minimum cmake version
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.30.5

- name: Install compiler
id: install_cc
uses: rlalik/[email protected]
with:
compiler: ${{ matrix.config.compiler }}

- name: Check compiler
shell: bash
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
run: |
$CC --version
$CXX --version

- uses: rui314/setup-mold@v1

- name: install conan
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@main
with:
conan-version: 2.3.1

- name: add conan user
run: |
conan remote add -f dice-group https://conan.dice-research.org/artifactory/api/conan/tentris

- name: Cache conan data
id: cache-conan
uses: actions/cache@v3
with:
path: ~/.conan/data
key: ${{ matrix.config.os }}-${{ matrix.config.compiler }}-testing-conan

- name: Cache torch
id: cache-torch
uses: actions/cache@v3
with:
path: ~/.cache/libtorch
key: cached-torch

# note: newer versions of libtorch than 1.09.0 result in an "error: arithmetic on a pointer to an incomplete type 'c10::IValue'" when building with clang-14 and libstdc++-12
- name: Download torch
if: steps.cache-torch.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p ~/.cache/
wget --continue --timestamping -O ~/.cache/libtorch-cxx11-abi-shared-with-deps-1.09.0+cpu.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip
unzip ~/.cache/libtorch-cxx11-abi-shared-with-deps-1.09.0+cpu.zip -d ~/.cache

- name: Checkout
uses: actions/checkout@v3

- name: Get dependency provider
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider@main

- name: Configure CMake
id: configure-cmake
shell: bash
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument -fuse-ld=mold -march=native" -DBUILD_TESTING=On -DLIBTORCH_PATH=~/.cache/libtorch -G Ninja -B build .

- name: Build tests
id: compile-tests
shell: bash
working-directory: build
env:
CC: ${{ steps.install_cc.outputs.cc }}
CXX: ${{ steps.install_cc.outputs.cxx }}
run: cmake --build . --parallel $(nproc)

- name: Run tests
id: run-tests
shell: bash
working-directory: build
run: ctest --parallel $(nproc) --exclude-regex "(tests_RawHypertrieContext_systematic)|(tests_RawHypertrieContext_systematic_metall)|(tests_HypertrieContext_systematic_metall)|(tests_Einsum)|(tests_Einsum_metall)"
21 changes: 21 additions & 0 deletions .github/workflows/publish-conan-branch-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish Conan branch package

on: [ push ]

concurrency:
group: publish-conan-branch-package-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
publish-conan-branch-package:
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-conan-branch-package.yml@main
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-17
cmake-version: 3.30.5
conan-version: 2.9.3
conan-options: -o boost/*:header_only=True
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
libs/hypertrie/src/dice/hypertrie/Hypertrie_version.hpp

.clang-tidy
.clang-format

# Prerequisites
*.d

Expand Down Expand Up @@ -40,3 +43,9 @@ cmake-build*/
.idea/
venv/
/build/


test_package/build/
test_package/CMakeUserPresets.json
/CMakeUserPresets.json
/conan_provider.cmake
32 changes: 21 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
cmake_minimum_required(VERSION 3.16)
project(hypertrie
VERSION 0.9.5
DESCRIPTION "A flexible data structure for low-rank, sparse tensors supporting slices by any dimension and einstein summation (einsum) and a flexible query interface"
)
cmake_minimum_required(VERSION 3.24)
project(hypertrie VERSION 0.9.6
DESCRIPTION "A flexible data structure for low-rank, sparse tensors supporting slices by any dimension and einstein summation (einsum) and a flexible query interface")

include(cmake/boilerplate_init.cmake)
boilerplate_init()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/libs/hypertrie/src/dice/hypertrie/Hypertrie_version.hpp)

option(CONAN_CMAKE "If this should use conan cmake to fetch dependencies" On)
if (IS_TOP_LEVEL AND CONAN_CMAKE)
include(cmake/conan_cmake.cmake)
install_packages_via_conan(${CMAKE_CURRENT_SOURCE_DIR}/conanfile.py)
if (PROJECT_IS_TOP_LEVEL)
set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=boost/*:header_only=True")

if (BUILD_TESTING)
set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=&:with_test_deps=True")
endif ()
endif ()

if (IS_TOP_LEVEL AND USE_CLANG_TIDY)
set(style_files
.clang-format
.clang-tidy
)
foreach(style_file ${style_files})
file(DOWNLOAD "https://raw.githubusercontent.com/dice-group/tentris-cpp-coding-guidelines/main/${style_file}"
"${CMAKE_SOURCE_DIR}/${style_file}"
TLS_VERIFY ON)
endforeach()

if (PROJECT_IS_TOP_LEVEL AND USE_CLANG_TIDY)
include(cmake/ClangTidy.cmake)
endif ()

add_subdirectory(libs)

if (IS_TOP_LEVEL AND BUILD_TESTING)
if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
include(CTest)
enable_testing()
add_subdirectory(tests)
Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
TODO: update readme

# hypertrie
A flexible data structure for low-rank, sparse tensors supporting slices by any dimension and einstein summation (einsum).

For details on the data structure refer to https://tentris.dice-research.org/
A flexible data structure for low-rank, sparse tensors supporting slices by any dimension and einstein summation (
einsum).

For details on the data structure refer to https://tentris.dice-research.org/

## build

### prerequisites

install conan, cmake and a C++20 compiler. The steps below are tested for gcc 10, clang 10 and clang 11.
install conan, cmake and a C++20 compiler.

Add dice-hash remote to conan
```shell script
conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris
```
and create a conan profile

```shell script
conan profile new --detect default
conan profile update settings.compiler.libcxx=libstdc++11 default
```

You'll need some packages from DICE group's conan artifactory. Add it with:

```shell script
conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris
```

### build

```shell script
Expand All @@ -29,16 +36,21 @@ cmake ..
```

# running tests
To enable test, set `hypertrie_BUILD_TESTS` in cmake:

To enable test, set `DBUILD_TESTING` in cmake:

```shell script
cmake -Dhypertrie_BUILD_TESTS=ON ..
cmake -DBUILD_TESTING=ON ..
make -j tests
tests/tests
```

Some tests are using [pytorch](https://github.com/pytorch/pytorch) which is not provided with the code.
Those tests are disabled by default.
Those tests are disabled by default.
To enable them, provide the path to the pytorch library via cmake variable `hypertrie_LIBTORCH_PATH`.
Prebuild binaries may be download via https://pytorch.org/get-started/locally/ (works at least with Stable|Linux|LibTorch|C++|None).
Prebuild binaries may be downloaded via https://pytorch.org/get-started/locally/ (works at least with
Stable|Linux|LibTorch|C++|None).

```shell script
cmake -Dhypertrie_BUILD_TESTS=ON -Dhypertrie_LIBTORCH_PATH=/path/to/libtorch ..
cmake -DDBUILD_TESTING=ON -DLIBTORCH_PATH=/path/to/libtorch ..
```
4 changes: 2 additions & 2 deletions cmake/ClangTidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ if(NOT CLANG_TIDY_FOUND)
endif()

set(CMAKE_CXX_CLANG_TIDY
${CLANG_TIDY_FOUND};
-extra-arg=-Wno-unknown-warning-option;
${CLANG_TIDY_FOUND};
-extra-arg=-Wno-unknown-warning-option;
)
4 changes: 0 additions & 4 deletions cmake/HypertrieConfig.cmake.in

This file was deleted.

16 changes: 12 additions & 4 deletions cmake/boilerplate_init.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
macro(boilerplate_init)
## enforce standard compliance
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # need fPIC to build tests
endif ()

## C++ compiler flags
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wold-style-cast -Wcast-qual")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# -Wchanges-meaning is not useful
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-changes-meaning")
endif ()
endif ()

## C++ language visibility configuration
Expand All @@ -24,6 +34,4 @@ macro(boilerplate_init)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif ()
endif ()

string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" IS_TOP_LEVEL)
endmacro()
Loading