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

Add clang-format check to CI #127

Merged
merged 3 commits into from
Nov 16, 2020
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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ env:
CONFIG: RelWithDebInfo

jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.11
with:
exclude: './thirdparty'
clangFormatVersion: 11

amalgamation:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion examples/alpaka/asyncblur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if (NOT TARGET llama::llama)
find_package(llama REQUIRED)
endif()
find_package(alpaka 0.5.0 REQUIRED)
alpaka_add_executable(${PROJECT_NAME} asyncblur.cpp stb_image.h stb_image_write.h ../../common/alpakaHelpers.hpp ../../common/Stopwatch.hpp)
alpaka_add_executable(${PROJECT_NAME} asyncblur.cpp ../../common/alpakaHelpers.hpp ../../common/Stopwatch.hpp)
target_include_directories(${PROJECT_NAME} PRIVATE ../../../thirdparty/stb/include)
target_compile_definitions(${PROJECT_NAME} PUBLIC LLAMA_FN_HOST_ACC_INLINE=ALPAKA_FN_HOST_ACC)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama alpaka::alpaka)
10 changes: 4 additions & 6 deletions examples/alpaka/asyncblur/asyncblur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

#include "../../common/Stopwatch.hpp"
#include "../../common/alpakaHelpers.hpp"
#include "stb_image.h"
#include "stb_image_write.h"

#include <alpaka/alpaka.hpp>
#include <alpaka/example/ExampleDefaultAcc.hpp>
#include <iostream>
#include <list>
#include <llama/llama.hpp>
#include <random>
#include <stb_image.h>
#include <stb_image_write.h>
#include <utility>

constexpr auto ASYNC = true; ///< defines whether the data shall be processed asynchronously
Expand Down Expand Up @@ -162,8 +162,7 @@ int main(int argc, char** argv)
// using Acc = alpaka::AccGpuCudaRt<Dim, Size>;
// using Acc = alpaka::AccCpuSerial<Dim, Size>;

using Queue
= alpaka::Queue<Acc, std::conditional_t<ASYNC, alpaka::NonBlocking, alpaka::Blocking>>;
using Queue = alpaka::Queue<Acc, std::conditional_t<ASYNC, alpaka::NonBlocking, alpaka::Blocking>>;
using DevHost = alpaka::DevCpu;
using DevAcc = alpaka::Dev<Acc>;
using PltfHost = alpaka::Pltf<DevHost>;
Expand Down Expand Up @@ -230,8 +229,7 @@ int main(int argc, char** argv)
std::vector<alpaka::Buf<DevHost, std::byte, alpaka::DimInt<1>, std::size_t>> hostChunkBuffer;
std::vector<llama::View<decltype(devMapping), std::byte*>> hostChunkView;

std::vector<alpaka::Buf<DevAcc, std::byte, alpaka::DimInt<1>, std::size_t>> devOldBuffer,
devNewBuffer;
std::vector<alpaka::Buf<DevAcc, std::byte, alpaka::DimInt<1>, std::size_t>> devOldBuffer, devNewBuffer;
std::vector<llama::View<decltype(devMapping), std::byte*>> devOldView, devNewView;

for (std::size_t i = 0; i < CHUNK_COUNT; ++i)
Expand Down
2 changes: 1 addition & 1 deletion examples/nbody_benchmark/nbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ int main()
run<mapping, alignment>();
});
});
}
}
3 changes: 2 additions & 1 deletion include/llama/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace llama
template <typename T, std::size_t N>
struct Array
{
static constexpr std::size_t rank = N; // FIXME this is right from the ArrayDomain's POV, but wrong from the Array's POV
static constexpr std::size_t rank
= N; // FIXME this is right from the ArrayDomain's POV, but wrong from the Array's POV
T element[N > 0 ? N : 1];

LLAMA_FN_HOST_ACC_INLINE constexpr T* begin()
Expand Down
42 changes: 21 additions & 21 deletions tests/mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ TEST_CASE("address.SoA.MultiBlob")
CHECK(mapping.getBlobNrAndOffset<0, 0>(coord) == llama::NrAndOffset{0, 0});
CHECK(mapping.getBlobNrAndOffset<0, 1>(coord) == llama::NrAndOffset{1, 0});
CHECK(mapping.getBlobNrAndOffset<0, 2>(coord) == llama::NrAndOffset{2, 0});
CHECK(mapping.getBlobNrAndOffset<1>(coord ) == llama::NrAndOffset{3, 0});
CHECK(mapping.getBlobNrAndOffset<1>(coord) == llama::NrAndOffset{3, 0});
CHECK(mapping.getBlobNrAndOffset<2, 0>(coord) == llama::NrAndOffset{4, 0});
CHECK(mapping.getBlobNrAndOffset<2, 1>(coord) == llama::NrAndOffset{5, 0});
CHECK(mapping.getBlobNrAndOffset<2, 2>(coord) == llama::NrAndOffset{6, 0});
Expand All @@ -385,31 +385,31 @@ TEST_CASE("address.SoA.MultiBlob")

{
const auto coord = ArrayDomain{0, 1};
CHECK(mapping.getBlobNrAndOffset<0, 0>(coord) == llama::NrAndOffset{0, 8});
CHECK(mapping.getBlobNrAndOffset<0, 1>(coord) == llama::NrAndOffset{1, 8});
CHECK(mapping.getBlobNrAndOffset<0, 2>(coord) == llama::NrAndOffset{2, 8});
CHECK(mapping.getBlobNrAndOffset<1>(coord) == llama::NrAndOffset{3, 4});
CHECK(mapping.getBlobNrAndOffset<2, 0>(coord) == llama::NrAndOffset{4, 8});
CHECK(mapping.getBlobNrAndOffset<2, 1>(coord) == llama::NrAndOffset{5, 8});
CHECK(mapping.getBlobNrAndOffset<2, 2>(coord) == llama::NrAndOffset{6, 8});
CHECK(mapping.getBlobNrAndOffset<3, 0>(coord) == llama::NrAndOffset{7, 1});
CHECK(mapping.getBlobNrAndOffset<3, 1>(coord) == llama::NrAndOffset{8, 1});
CHECK(mapping.getBlobNrAndOffset<3, 2>(coord) == llama::NrAndOffset{9, 1});
CHECK(mapping.getBlobNrAndOffset<0, 0>(coord) == llama::NrAndOffset{0, 8});
CHECK(mapping.getBlobNrAndOffset<0, 1>(coord) == llama::NrAndOffset{1, 8});
CHECK(mapping.getBlobNrAndOffset<0, 2>(coord) == llama::NrAndOffset{2, 8});
CHECK(mapping.getBlobNrAndOffset<1>(coord) == llama::NrAndOffset{3, 4});
CHECK(mapping.getBlobNrAndOffset<2, 0>(coord) == llama::NrAndOffset{4, 8});
CHECK(mapping.getBlobNrAndOffset<2, 1>(coord) == llama::NrAndOffset{5, 8});
CHECK(mapping.getBlobNrAndOffset<2, 2>(coord) == llama::NrAndOffset{6, 8});
CHECK(mapping.getBlobNrAndOffset<3, 0>(coord) == llama::NrAndOffset{7, 1});
CHECK(mapping.getBlobNrAndOffset<3, 1>(coord) == llama::NrAndOffset{8, 1});
CHECK(mapping.getBlobNrAndOffset<3, 2>(coord) == llama::NrAndOffset{9, 1});
CHECK(mapping.getBlobNrAndOffset<3, 3>(coord) == llama::NrAndOffset{10, 1});
}

{
const auto coord = ArrayDomain{1, 0};
CHECK(mapping.getBlobNrAndOffset<0, 0>(coord) == llama::NrAndOffset{0, 128});
CHECK(mapping.getBlobNrAndOffset<0, 1>(coord) == llama::NrAndOffset{1, 128});
CHECK(mapping.getBlobNrAndOffset<0, 2>(coord) == llama::NrAndOffset{2, 128});
CHECK(mapping.getBlobNrAndOffset<1>(coord) == llama::NrAndOffset{3, 64});
CHECK(mapping.getBlobNrAndOffset<2, 0>(coord) == llama::NrAndOffset{4, 128});
CHECK(mapping.getBlobNrAndOffset<2, 1>(coord) == llama::NrAndOffset{5, 128});
CHECK(mapping.getBlobNrAndOffset<2, 2>(coord) == llama::NrAndOffset{6, 128});
CHECK(mapping.getBlobNrAndOffset<3, 0>(coord) == llama::NrAndOffset{7, 16});
CHECK(mapping.getBlobNrAndOffset<3, 1>(coord) == llama::NrAndOffset{8, 16});
CHECK(mapping.getBlobNrAndOffset<3, 2>(coord) == llama::NrAndOffset{9, 16});
CHECK(mapping.getBlobNrAndOffset<0, 0>(coord) == llama::NrAndOffset{0, 128});
CHECK(mapping.getBlobNrAndOffset<0, 1>(coord) == llama::NrAndOffset{1, 128});
CHECK(mapping.getBlobNrAndOffset<0, 2>(coord) == llama::NrAndOffset{2, 128});
CHECK(mapping.getBlobNrAndOffset<1>(coord) == llama::NrAndOffset{3, 64});
CHECK(mapping.getBlobNrAndOffset<2, 0>(coord) == llama::NrAndOffset{4, 128});
CHECK(mapping.getBlobNrAndOffset<2, 1>(coord) == llama::NrAndOffset{5, 128});
CHECK(mapping.getBlobNrAndOffset<2, 2>(coord) == llama::NrAndOffset{6, 128});
CHECK(mapping.getBlobNrAndOffset<3, 0>(coord) == llama::NrAndOffset{7, 16});
CHECK(mapping.getBlobNrAndOffset<3, 1>(coord) == llama::NrAndOffset{8, 16});
CHECK(mapping.getBlobNrAndOffset<3, 2>(coord) == llama::NrAndOffset{9, 16});
CHECK(mapping.getBlobNrAndOffset<3, 3>(coord) == llama::NrAndOffset{10, 16});
}
}
Expand Down