17 #include <Compadre_Config.h>
24 #ifdef COMPADRE_USE_MPI
28 #include <Kokkos_Timer.hpp>
29 #include <Kokkos_Core.hpp>
31 using namespace Compadre;
36 int main (
int argc,
char* args[]) {
38 #ifdef COMPADRE_USE_MPI
40 MPI_Init(&argc, &args);
44 Kokkos::initialize(argc, args);
47 bool all_passed =
true;
55 if (args[2] != NULL) {
56 auto arg3toi = atoi(args[2]);
57 if (isdigit(arg3toi)) {
68 if (args[1] != NULL) {
69 auto arg2toi = atoi(args[1]);
70 if (isdigit(arg2toi)) {
81 Kokkos::Profiling::pushRegion(
"Setup Data");
84 Kokkos::View<int**, Kokkos::DefaultExecutionSpace> data_device(
"data", num_flags, num_cols);
85 Kokkos::View<int**>::HostMirror data = Kokkos::create_mirror_view(data_device);
88 Kokkos::View<int*, Kokkos::DefaultExecutionSpace> flags_device(
"flags", num_flags);
89 Kokkos::View<int*>::HostMirror flags = Kokkos::create_mirror_view(flags_device);
93 Kokkos::Profiling::popRegion();
94 Kokkos::Profiling::pushRegion(
"Filter And Extract Data");
98 for (
int i=0; i<num_flags; i++) {
99 for (
int j=0; j<num_cols; j++) {
108 Kokkos::deep_copy(data_device, data);
111 int num_filtered_flags = 0;
112 for (
int i=0; i<num_flags; i++) {
115 num_filtered_flags++;
121 Kokkos::deep_copy(flags_device, flags);
124 auto filtered_flags = filterViewByID<Kokkos::HostSpace>(flags_device, 1);
125 auto extracted_data = Extract::extractViewByIndex<Kokkos::HostSpace>(data_device, filtered_flags);
129 Kokkos::Profiling::popRegion();
130 Kokkos::Profiling::pushRegion(
"Check Filtered And Extracted Data");
134 if (filtered_flags.extent(0) != (size_t)num_filtered_flags) {
136 std::cout <<
"Failed - number of filtered flags not matched!" << filtered_flags.extent(0) <<
" " << num_filtered_flags << std::endl;
138 for (
size_t i=0; i<filtered_flags.extent(0); i++) {
139 if (filtered_flags(i) % 2 != 0) {
141 std::cout <<
"Failed - incorrect filtered flags " << filtered_flags(i) << std::endl;
145 for (
size_t i=0; i<extracted_data.extent(0); i++) {
146 for (
size_t j=0; j<extracted_data.extent(1); j++) {
147 if (extracted_data(i, j) != 1) {
149 std::cout <<
"Failed - incorrect values in extracted view at index " << i <<
" " << j <<
" " << extracted_data(i, j) << std::endl;
156 Kokkos::Profiling::popRegion();
164 #ifdef COMPADRE_USE_MPI
170 fprintf(stdout,
"Passed test \n");
173 fprintf(stdout,
"Failed test \n");
int main(int argc, char **argv)