Skip to content

Commit

Permalink
Merge pull request #31 from SCOREC/minimal-Clang-Error
Browse files Browse the repository at this point in the history
Fixed clang compiler error
  • Loading branch information
cwsmith authored Feb 14, 2024
2 parents 8f507ae + c5f5722 commit 862efbd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [g++]
compiler: [g++,clang++]
language: ['cpp']
build_type: [Debug, Release]
# Permissions needed for codeql analysis
Expand Down
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ target_link_libraries(Main PRIVATE meshFields)
add_executable(KokkosTests test/testKokkos.cpp)
target_link_libraries(KokkosTests PRIVATE meshFields)

add_executable(ClangTests test/testClangMinimal.cpp)
target_link_libraries(ClangTests PRIVATE meshFields)

add_executable(CabanaTests test/testCabana.cpp)
target_link_libraries(CabanaTests PRIVATE meshFields)

Expand All @@ -60,7 +57,6 @@ target_link_libraries(LogicTests PRIVATE meshFields)

add_test(MainTests ./Main)
add_test(KokkosTests ./KokkosTests)
add_test(ClangTests ./ClangTests)
add_test(CabanaTests ./CabanaTests)
add_test(logicTests ./LogicTests)

Expand Down
42 changes: 21 additions & 21 deletions src/KokkosController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "MeshField_Utility.hpp"
#include "MeshField_Macros.hpp"


namespace Controller {

template <class SliceType, class T>
Expand Down Expand Up @@ -83,8 +84,7 @@ class KokkosController {

template<typename... Tx>
auto construct( std::vector<int> &dims ) {
// Note: the '...' expansion will traverse <Tx...> backwards!
return std::make_tuple( create_view<Tx>("view", dims)... );
return std::tuple<Kokkos::View<Tx>...>{create_view<Tx>("view", dims)...};
}

template<typename Tx>
Expand All @@ -99,29 +99,29 @@ class KokkosController {
Kokkos::View<Tx,MemorySpace> rt;
switch( dynamic ) {
case 1:
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[dims.size()-1] );
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[0] );
break;
case 2:
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[dims.size()-2],
dims[dims.size()-1] );
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[0],
dims[1] );
break;
case 3:
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[dims.size()-3],
dims[dims.size()-2],
dims[dims.size()-1]);
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[0],
dims[1],
dims[2]);
break;
case 4:
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[dims.size()-4],
dims[dims.size()-3],
dims[dims.size()-2],
dims[dims.size()-1]);
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[0],
dims[1],
dims[2],
dims[3]);
break;
case 5:
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[dims.size()-5],
dims[dims.size()-4],
dims[dims.size()-3],
dims[dims.size()-2],
dims[dims.size()-1]);
rt = Kokkos::View<Tx,MemorySpace>(tag, dims[0],
dims[1],
dims[2],
dims[3],
dims[4]);
break;
default:
rt = Kokkos::View<Tx,MemorySpace>(tag);
Expand All @@ -130,10 +130,10 @@ class KokkosController {

// Places all of the dyanmic ranks into the extent_sizes
for( int i = 0; i < dynamic; i++ ) {
this->extent_sizes[theta][i] = dims[dims.size()-dynamic+i];
this->extent_sizes[theta][i] = dims[i];
}
this->theta-=1;
dims.erase( dims.end()-dynamic, dims.end());
this->theta+=1;
dims.erase( dims.begin(), dims.begin()+dynamic );
return rt;
}

Expand Down Expand Up @@ -183,7 +183,7 @@ class KokkosController {
// member vaiables
const int num_types = sizeof...(Ts);
unsigned short delta = 0;
unsigned short theta = num_types-1;
unsigned short theta = 0;
int extent_sizes[sizeof...(Ts)][5];
std::tuple<Kokkos::View<Ts,MemorySpace>...> values_;

Expand Down
38 changes: 0 additions & 38 deletions test/testClangMinimal.cpp

This file was deleted.

21 changes: 21 additions & 0 deletions test/testMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,30 @@ void testSetField() {
printf("== END testSetField ==\n");
}

void testSetCorrect() {

printf("== START testSetCorrect ==\n");

const int N = 10;

using kok1 = Controller::KokkosController<MemorySpace,ExecutionSpace, int**, int***,int****, int*****>;
kok1 c1({N,1,
N,N,N,
N,N,15,N,
N,N,N,N,6});

// Checking that sizes are loaded correctly
assert(c1.size(0,1) == 1);
assert(c1.size(2,2) == 15);
assert(c1.size(3,4) == 6);

printf("== END testSetCorrect ==\n");
}

int main(int argc, char *argv[]) {
Kokkos::ScopeGuard scope_guard(argc, argv);
testParallelScan();
testSetField();
testSetCorrect();
return 0;
}

0 comments on commit 862efbd

Please sign in to comment.