Skip to content

Commit

Permalink
merge and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Ulrich committed Oct 16, 2024
2 parents 6920a2b + a782c9c commit e920be7
Show file tree
Hide file tree
Showing 49 changed files with 2,656 additions and 367 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/yateto-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Yateto CI

on: push

jobs:
general:
runs-on: ubuntu-latest
container:
image: ravilmobile/yateto-env:latest
steps:
- uses: actions/checkout@v2

- name: Install Yateto
run: |
pip3 install -e .
- name: Python Tests
run: |
python3 -m unittest tests/internals/*.py
- name: Interface Tests
run: |
. /etc/profile.d/z10_spack_environment.sh && . /etc/profile.d/z20_additional_env.sh
cd ./tests/interface
for build_type in Debug Release; do
mkdir -p ./build-${build_type} && cd ./build-${build_type}
cmake .. -DCMAKE_BUILD_TYPE=${build_type}
make
make test
cd ..
done
codegen:
runs-on: ubuntu-latest
container:
image: ravilmobile/yateto-env:latest
env:
CTEST_OUTPUT_ON_FAILURE: 1
strategy:
matrix:
generator: [Eigen, LIBXSMM, LIBXSMM_JIT, OpenBLAS]

steps:
- uses: actions/checkout@v2

- name: Install Yateto
run: |
pip3 install -e .
- name: Codegen Tests
run: |
. /etc/profile.d/z10_spack_environment.sh && . /etc/profile.d/z20_additional_env.sh
cd ./tests/code-gen
for example in matmul minimal; do
for build_type in Debug Release; do
for precision in single double; do
echo " ====== Test Config: ======"
echo " Build: ${build_type}"
echo " Precision: ${precision}"
echo " Example: ${example}"
echo "==========================="
mkdir -p ./build-${example}-${build_type}-${precision}
cd ./build-${example}-${build_type}-${precision}
cmake .. -DEXAMPLES=${example} -DCMAKE_BUILD_TYPE=${build_type} -DPRECISION=${precision} -DVARIANT=${{ matrix.generator }} -DARCH=snb
make
make test
cd ..
done
done
done
1 change: 1 addition & 0 deletions include/yateto.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#include "yateto/TensorView.h"
#include "yateto/InitTools.h"
#include "yateto/LinearAllocator.h"
#include "yateto/Misc.h"

#endif
49 changes: 25 additions & 24 deletions include/yateto/LinearAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@
#include <assert.h>

namespace yateto {
template<typename T>
struct LinearAllocatorT {
void initialize(T* ptr) {
isInit = true;
userSpaceMem = ptr;
}
template<typename T>
struct LinearAllocatorT {
public:
void initialize(T* ptr) {
isInit = true;
userSpaceMem = ptr;
}

T* allocate(size_t size) {
assert(isInit && "YATETO: Temporary-Memory manager hasn't been initialized");
int currentByteCount = byteCount;
byteCount += size;
return &userSpaceMem[currentByteCount];
}
T* allocate(size_t size) {
assert(isInit && "YATETO: Temporary-Memory manager hasn't been initialized");
int currentByteCount = byteCount;
byteCount += size;
return &userSpaceMem[currentByteCount];
}

void free() {
isInit = false;
byteCount = 0;
userSpaceMem = nullptr;
}
void free() {
isInit = false;
byteCount = 0;
userSpaceMem = nullptr;
}

private:
size_t byteCount{0};
bool isInit{false};
T *userSpaceMem{nullptr};
};
} // YATETO_LINEAR_ALLOCATED_H_
#endif
private:
size_t byteCount{0};
bool isInit{false};
T *userSpaceMem{nullptr};
};
} // yateto
#endif // YATETO_LINEAR_ALLOCATED_H_
31 changes: 31 additions & 0 deletions include/yateto/Misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef YATETO_MISC_H_
#define YATETO_MISC_H_

namespace yateto {

template<typename KernelType>
auto getMaxTmpMemRequired(KernelType& krnl) {
return KernelType::TmpMaxMemRequiredInBytes;
}

template<typename KernelType, typename... OtherKernelTypes>
auto getMaxTmpMemRequired(KernelType& krnl,
OtherKernelTypes&... otherKrnls) {
auto currentTmpMem = KernelType::TmpMaxMemRequiredInBytes;
auto otherTmpMem = getMaxTmpMemRequired(otherKrnls...);
return (currentTmpMem > otherTmpMem) ? currentTmpMem : otherTmpMem;
}

template <typename Tensor, int Dim>
constexpr size_t dimSize() noexcept {
return Tensor::Stop[Dim] - Tensor::Start[Dim];
}

template <typename Tensor>
constexpr size_t leadDim() noexcept {
return dimSize<Tensor, 0>();
}

} // yateto

#endif // YATETO_MISC_H_
57 changes: 47 additions & 10 deletions include/yateto/TensorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ namespace yateto {
uint_t m_shape[Dim];
};

template<typename real_t, typename uint_t>
class TensorView<0, real_t, uint_t> {
public:
explicit TensorView(std::initializer_list<uint_t> shape) {}

explicit TensorView(uint_t const shape[]) {}

constexpr uint_t dim() const {
return 0;
}

uint_t shape(uint_t dim) const {
return 0;
}
};

template<unsigned Dim, typename real_t, typename uint_t=unsigned>
class DenseTensorView : public TensorView<Dim, real_t, uint_t> {
public:
Expand Down Expand Up @@ -116,22 +132,29 @@ namespace yateto {
}

template<typename Head>
void isInRange(uint_t start[Dim], uint_t stop[Dim], int dim, Head head) {
assert(static_cast<uint_t>(head) >= start[dim]);
assert(static_cast<uint_t>(head) < stop[dim]);
bool isInRange(const uint_t start[Dim], const uint_t stop[Dim], int dim, Head head) const {
return static_cast<uint_t>(head) >= start[dim] && static_cast<uint_t>(head) < stop[dim];
}

template<typename Head, typename... Tail>
void isInRange(uint_t start[Dim], uint_t stop[Dim], int dim, Head head, Tail... tail) {
assert(static_cast<uint_t>(head) >= start[dim]);
assert(static_cast<uint_t>(head) < stop[dim]);
isInRange(start, stop, dim+1, tail...);
bool isInRange(const uint_t start[Dim], const uint_t stop[Dim], int dim, Head head, Tail... tail) const {
return static_cast<uint_t>(head) >= start[dim]
&& static_cast<uint_t>(head) < stop[dim]
&& isInRange(start, stop, dim+1, tail...);
}

template<typename... Entry>
bool isInRange(Entry... entry) const {
static_assert(sizeof...(entry) == Dim,
"Number of arguments to isInRange(...) does not match Tensor's dimension.");
return isInRange(m_start, m_stop, 0, entry...);
}

template<typename... Entry>
real_t& operator()(Entry... entry) {
static_assert(sizeof...(entry) == Dim, "Number of arguments to operator() does not match Tensor's dimension.");
isInRange(m_start, m_stop, 0, entry...);
static_assert(sizeof...(entry) == Dim,
"Number of arguments to operator() does not match Tensor's dimension.");
assert(isInRange(entry...));
return m_values[address(entry...)];
}

Expand Down Expand Up @@ -303,6 +326,20 @@ namespace yateto {
return m_values[addr];
}

bool isInRange(uint_t row, uint_t col) const {
assert(col >= 0 && col < this->shape(1));
uint_t addr = m_colPtr[ col ];
uint_t stop = m_colPtr[ col+1 ];
while (addr < stop) {
if (m_rowInd[addr] == row) {
return true;
}
++addr;
}

return false;
}

real_t& operator[](uint_t entry[2]) {
return operator()(entry[0], entry[1]);
}
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()
Expand All @@ -17,7 +17,7 @@
description="A tensor toolbox for discontinuous Galerkin methods",
long_description=long_description,
long_description_content_type="text/markdown",
packages=["yateto"],
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD 3-Clause License",
Expand Down
64 changes: 46 additions & 18 deletions tests/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
properties([parameters([string(defaultValue: '', description: 'target architecture (according to yateto format). If not given then taken from Jenkins env-vars', name: 'ARCH', trim: true),
string(defaultValue: 'matmul minimal', description: 'whitespace separate list of examples', name: 'EXAMPLES', trim: true),
string(defaultValue: 'Eigen LIBXSMM OpenBLAS', description: 'whitespace separate list of generators', name: 'GENERATORS', trim: true),
booleanParam(defaultValue: false, description: 'if true the environment image will be build. Note: it will take a considerable amount of time', name: 'BUILD_ENV_IMAGE')
])])
properties([
parameters([string(
defaultValue: 'runner',
description: 'agent name which tells where to run a job',
name: 'AGENT',
trim: true),
string(
defaultValue: '',
description: 'target architecture (according to yateto format). If not given then taken from Jenkins env-vars',
name: 'ARCH',
trim: true),
string(
defaultValue: 'matmul minimal',
description: 'whitespace separate list of examples',
name: 'EXAMPLES',
trim: true),
string(
defaultValue: 'Eigen LIBXSMM OpenBLAS',
description: 'whitespace separate list of generators',
name: 'GENERATORS',
trim: true),
booleanParam(
defaultValue: false,
description: 'if true the environment image will be build. Note: it will take a considerable amount of time',
name: 'BUILD_ENV_IMAGE')
])
])


pipeline {
agent any
agent {label "${params.AGENT}"}

stages {
stage('CleanWorkspace') {
Expand All @@ -33,12 +55,18 @@ pipeline {
// Make sure that Jenkins knows the location of Spack.
// You will need to add it to the Jenkins settings
dir("tests") {
sh 'spack containerize > ./Dockerfile-env'
sh 'cat ./Dockerfile-env'

script {
def customImage = docker.build("ravilmobile/yateto-env", "-f Dockerfile-env .")
customImage.push("latest")
script {
withCredentials([usernamePassword(credentialsId: 'docker-hub',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD')]) {
sh """
docker run --rm -v \$(pwd):/home -w /home ${USERNAME}/spack-ubuntu-1804:latest containerize > ./Dockerfile-env
cat ./Dockerfile-env
docker login -u ${USERNAME} -p ${PASSWORD}
"""
def customImage = docker.build("${USERNAME}/yateto-env", "-f Dockerfile-env .")
customImage.push("latest")
}
}
}
}
Expand Down Expand Up @@ -103,19 +131,19 @@ cmake .. && make && make test
sh "mkdir ./cache"

script {
// define runner arch. for testing
// define test arch. for testing
// if the user specifies ARCH as parameter it is going to be used for testing
// if not, we will try to get ARCH from the Jenkins env. variables
// if the user didn't set env.HOST_ARCH in his/her Jenkins settings, then 'noarch' will be used
env.RUNNER_ARCH="noarch"
env.TEST_ARCH="noarch"
if (!env.ARCH.allWhitespace) {
env.RUNNER_ARCH=env.ARCH
env.TEST_ARCH=env.ARCH
}
else if (env.HOST_ARCH) {
env.RUNNER_ARCH=env.HOST_ARCH
else if (env.RUNNER_HOST_ARCH) {
env.TEST_ARCH=env.RUNNER_HOST_ARCH
}
}
sh 'docker container run --rm -e ARCH="${RUNNER_ARCH}" -e EXAMPLES="${EXAMPLES}" -e GENERATORS="${GENERATORS}" -v $(pwd)/cache:/cache -v $(pwd)/run_tests.sh:/local_workspace/tests/run_tests.sh yateto:latest run_tests.sh'
sh 'docker container run --rm -e ARCH="${TEST_ARCH}" -e EXAMPLES="${EXAMPLES}" -e GENERATORS="${GENERATORS}" -v $(pwd)/cache:/cache -v $(pwd)/run_tests.sh:/local_workspace/tests/run_tests.sh yateto:latest run_tests.sh'
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ in you current working environment.
| code-gen | 2 tests |


## Running tests
## Running tests manually
### Interface
```console
cd mkdir interface/build && cd interface/build
Expand Down Expand Up @@ -75,3 +75,14 @@ cmake .. -DPRECISION=single -DVARIANT=LIBXSMM
make
ctest
```

## Running tests automatically
The following [pipeline](Jenkinsfile) has been implemented to run the aforementioned tests automatically. As a regular user, you can see results of the last few runs of the pipeline [here](http://vmbungartz10.informatik.tu-muenchen.de/seissol/view/Yateto/job/yateto-codegen/).

You can trigger the pipeline and thus run all tests if you a member of SeisSol in github. To achive this, please, perform the following steps:

- open this [page](http://vmbungartz10.informatik.tu-muenchen.de/seissol/view/Yateto/job/yateto-codegen/)
- click on `log in` button at the top right corner and follow the authentication procedure
- click on `Build with Parameters` button. You will be forwarded to the next page where you can adjust parameters. We do not recommend to make any changes in `AGENT` and `BUILD_ENV_IMAGE` fields
- click on `Build` to trigger the pipeline.
- After that, you will see a new flashing entry at the very top of `Build History` field. If you want to see a detail status information about all steps involved in the pipeline then click on a dropdown widget of the flashing entry and select `Console Output`
Loading

0 comments on commit e920be7

Please sign in to comment.