-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement unit tests for MeshField Serialization.
- Loading branch information
Showing
6 changed files
with
215 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "MeshField.hpp" | ||
#include "CabanaController.hpp" | ||
#include "KokkosController.hpp" | ||
#include "MeshField_Macros.hpp" | ||
#include "MeshField_Utility.hpp" | ||
|
||
#include <Cabana_Core.hpp> | ||
#include <Kokkos_Core.hpp> | ||
|
||
#include <vector> | ||
#include <iostream> | ||
#include <initializer_list> | ||
|
||
using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||
using MemorySpace = Kokkos::DefaultExecutionSpace::memory_space; | ||
|
||
int main(int argc, char *argv[]) { | ||
Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
||
const int N = 30; | ||
using kok1 = Controller::KokkosController<MemorySpace,ExecutionSpace,int*,int**,int***,int****,int*****>; | ||
kok1 c1({N,N,N,N,N,N,N,N,N,N,N,N,N,N,N}); | ||
|
||
MeshField::MeshField mf(c1); | ||
MeshField::Field field5 = mf.makeField<4>(); | ||
|
||
Kokkos::View<int*****> view5("5",N,N,N,N,N); | ||
|
||
Kokkos::Array start = MeshFieldUtil::to_kokkos_array<5>({0,0,0,0,0}); | ||
Kokkos::Array end = MeshFieldUtil::to_kokkos_array<5>({N,N,N,N,N}); | ||
Kokkos::MDRangePolicy<Kokkos::Rank<5>> p(start,end); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
view5(i,j,k,l,m) = i+j+k+l+m; | ||
}); | ||
|
||
mf.setField(field5,view5); | ||
|
||
auto serialized5 = field5.serialize(); | ||
|
||
MeshField::Field deserialized5 = mf.makeField<4>(); | ||
deserialized5.deserialize(serialized5); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
assert(view5(i, j, k, l, m) == deserialized5(i, j, k, l, m)); | ||
}); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "MeshField.hpp" | ||
#include "CabanaController.hpp" | ||
#include "KokkosController.hpp" | ||
#include "MeshField_Macros.hpp" | ||
#include "MeshField_Utility.hpp" | ||
|
||
#include <Cabana_Core.hpp> | ||
#include <Kokkos_Core.hpp> | ||
|
||
#include <vector> | ||
#include <iostream> | ||
#include <initializer_list> | ||
|
||
using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||
using MemorySpace = Kokkos::DefaultExecutionSpace::memory_space; | ||
|
||
int main(int argc, char *argv[]) { | ||
Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
||
const int N = 30; | ||
using kok1 = Controller::KokkosController<MemorySpace,ExecutionSpace,int*,int**,int***,int****,int*****>; | ||
kok1 c1({N,N,N,N,N,N,N,N,N,N,N,N,N,N,N}); | ||
|
||
MeshField::MeshField mf(c1); | ||
MeshField::Field field4 = mf.makeField<3>(); | ||
|
||
Kokkos::View<int****> view4("4",N,N,N,N); | ||
|
||
Kokkos::Array start = MeshFieldUtil::to_kokkos_array<5>({0,0,0,0,0}); | ||
Kokkos::Array end = MeshFieldUtil::to_kokkos_array<5>({N,N,N,N,N}); | ||
Kokkos::MDRangePolicy<Kokkos::Rank<5>> p(start,end); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
view4(i,j,k,l) = i+j+k+l; | ||
}); | ||
|
||
mf.setField(field4,view4); | ||
|
||
auto serialized4 = field4.serialize(); | ||
|
||
MeshField::Field deserialized4 = mf.makeField<3>(); | ||
|
||
deserialized4.deserialize(serialized4); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
assert(view4(i, j, k, l) == deserialized4(i, j, k, l)); | ||
}); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "MeshField.hpp" | ||
#include "CabanaController.hpp" | ||
#include "KokkosController.hpp" | ||
#include "MeshField_Macros.hpp" | ||
#include "MeshField_Utility.hpp" | ||
|
||
#include <Cabana_Core.hpp> | ||
#include <Kokkos_Core.hpp> | ||
|
||
#include <vector> | ||
#include <iostream> | ||
#include <initializer_list> | ||
|
||
using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||
using MemorySpace = Kokkos::DefaultExecutionSpace::memory_space; | ||
|
||
int main(int argc, char *argv[]) { | ||
Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
||
const int N = 30; | ||
using kok1 = Controller::KokkosController<MemorySpace,ExecutionSpace,int*,int**,int***,int****,int*****>; | ||
kok1 c1({N,N,N,N,N,N,N,N,N,N,N,N,N,N,N}); | ||
|
||
MeshField::MeshField mf(c1); | ||
MeshField::Field field3 = mf.makeField<2>(); | ||
|
||
Kokkos::View<int***> view3("3",N,N,N); | ||
|
||
Kokkos::Array start = MeshFieldUtil::to_kokkos_array<5>({0,0,0,0,0}); | ||
Kokkos::Array end = MeshFieldUtil::to_kokkos_array<5>({N,N,N,N,N}); | ||
Kokkos::MDRangePolicy<Kokkos::Rank<5>> p(start,end); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
view3(i,j,k) = i+j+k; | ||
}); | ||
|
||
mf.setField(field3,view3); | ||
|
||
auto serialized3 = field3.serialize(); | ||
|
||
MeshField::Field deserialized3 = mf.makeField<2>(); | ||
|
||
deserialized3.deserialize(serialized3); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
assert(view3(i, j, k) == deserialized3(i, j, k)); | ||
}); | ||
std::cerr << "Line 80" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "MeshField.hpp" | ||
#include "CabanaController.hpp" | ||
#include "KokkosController.hpp" | ||
#include "MeshField_Macros.hpp" | ||
#include "MeshField_Utility.hpp" | ||
|
||
#include <Cabana_Core.hpp> | ||
#include <Kokkos_Core.hpp> | ||
|
||
#include <vector> | ||
#include <iostream> | ||
#include <initializer_list> | ||
|
||
using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||
using MemorySpace = Kokkos::DefaultExecutionSpace::memory_space; | ||
|
||
int main(int argc, char *argv[]) { | ||
Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
||
const int N = 30; | ||
using kok1 = Controller::KokkosController<MemorySpace,ExecutionSpace,int*,int**,int***,int****,int*****>; | ||
kok1 c1({N,N,N,N,N,N,N,N,N,N,N,N,N,N,N}); | ||
|
||
MeshField::MeshField mf(c1); | ||
MeshField::Field field2 = mf.makeField<1>(); | ||
|
||
Kokkos::View<int**> view2("2",N,N); | ||
|
||
Kokkos::Array start = MeshFieldUtil::to_kokkos_array<5>({0,0,0,0,0}); | ||
Kokkos::Array end = MeshFieldUtil::to_kokkos_array<5>({N,N,N,N,N}); | ||
Kokkos::MDRangePolicy<Kokkos::Rank<5>> p(start,end); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
view2(i,j) = i+j; | ||
}); | ||
|
||
mf.setField(field2,view2); | ||
|
||
auto serialized2 = field2.serialize(); | ||
|
||
MeshField::Field deserialized2 = mf.makeField<1>(); | ||
|
||
deserialized2.deserialize(serialized2); | ||
|
||
Kokkos::parallel_for( "",p,KOKKOS_LAMBDA(const int& i,const int& j, const int& k, const int& l, const int& m){ | ||
assert(view2(i, j) == deserialized2(i, j)); | ||
}); | ||
return 0; | ||
} |