Finish Kokkos::Parallel in ExtrapolatedSmootherTake#268
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
- Coverage 89.49% 89.48% -0.02%
==========================================
Files 79 79
Lines 9223 9214 -9
==========================================
- Hits 8254 8245 -9
Misses 969 969 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Yes. You would only see failures on GPU. All tests in the CI are CPU only (plus we hare still running the loop on OpenMP for now) It is needed for the Compiler output for operator= vs copy constructorCompare your suggestion: #include <utility>
class MyClass {
public:
MyClass() : x(0) {}
private:
const int x;
};
int main () {
MyClass a;
MyClass b;
b = a;
b = std::move(a);
}which generates the following compiler errors: with a version using the copy constructor: #include <utility>
class MyClass {
public:
MyClass() : x(0) {}
private:
const int x;
};
int main () {
MyClass a;
MyClass b(a);
MyClass c(std::move(a));
}which compiles with no errors For GPU the issue is: #include <iostream>
#include <Kokkos_Core.hpp>
class DataClass {
public:
KOKKOS_FUNCTION DataClass() : x_(0) {}
KOKKOS_DEFAULTED_FUNCTION DataClass(const DataClass&) = default;
KOKKOS_INLINE_FUNCTION int x() const { return x_; }
private:
const int x_;
};
class MyClass {
public:
MyClass(DataClass const& data_on_cpu)
: reference_to_data_on_mem_space_where_data_was_created(data_on_cpu) {}
KOKKOS_INLINE_FUNCTION int x() const {
return reference_to_data_on_mem_space_where_data_was_created.x();
}
private:
DataClass const& reference_to_data_on_mem_space_where_data_was_created;
};
class MyClass2 {
public:
MyClass2(DataClass const& data_on_cpu)
: copy_of_data_on_mem_space_where_my_class2_was_created(data_on_cpu) {}
KOKKOS_INLINE_FUNCTION int x() const {
return copy_of_data_on_mem_space_where_my_class2_was_created.x();
}
private:
DataClass copy_of_data_on_mem_space_where_my_class2_was_created;
};
int main (int argc, char* argv[]) {
Kokkos::ScopeGuard kokkos_scope(argc, argv);
DataClass a;
MyClass alloc_on_cpu(a);
MyClass2 alloc_on_cpu2(a);
std::cout << alloc_on_cpu.x() << std::endl; // OK because memory and execution is on CPU
std::cout << alloc_on_cpu2.x() << std::endl; // OK because memory and execution is on CPU
Kokkos::parallel_for("Test OpenMP loop", Kokkos::RangePolicy<Kokkos::DefaultHostExecutionSpace>(0, 1),
KOKKOS_LAMBDA(const int i) {
// OK because memory and execution is on CPU
Kokkos::printf("%d\n", alloc_on_cpu.x());
// OK because memory and execution is on CPU
Kokkos::printf("%d\n", alloc_on_cpu2.x());
});
Kokkos::parallel_for("Test GPU loop", Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>(0, 1),
KOKKOS_LAMBDA(const int i) {
// KO because a is referenced directly. It is on CPU but execution is on GPU
Kokkos::printf("%d\n", alloc_on_cpu.x());
// OK because memory and execution is on GPU (thanks to copy constructors)
Kokkos::printf("%d\n", alloc_on_cpu2.x());
});
}This program compiles perfectly but it crashes on execution as follows: Commenting the line marked KO leads to correct execution |
|
Probably best if we dont use Kokkos class lambda anywhere ( expect the one in the CSR Solver - thats fine ). They just break everything in the code so easily. |


Merge Request - GuideLine Checklist
Guideline to check code before resolve WIP and approval, respectively.
As many checkboxes as possible should be ticked.
Checks by code author:
Always to be checked:
If functions were changed or functionality was added:
If new functionality was added:
If new third party software is used:
If new mathematical methods or epidemiological terms are used:
Checks by code reviewer(s):