Skip to content

Commit

Permalink
Merge pull request #94 from lanl/Sarah
Browse files Browse the repository at this point in the history
Sarah - added in set_values function
  • Loading branch information
shankinsMechEng authored Sep 16, 2024
2 parents 4f504bb + 3d20a79 commit 4d15353
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/include/kokkos_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6742,12 +6742,20 @@ class RaggedRightArrayKokkos {
//setup start indices
void data_setup(const std::string& tag_string);

//return pointer
KOKKOS_INLINE_FUNCTION
T* pointer();

//return the view
KOKKOS_INLINE_FUNCTION
TArray1D get_kokkos_view();

//print values
void print() const;

//set values to input
KOKKOS_INLINE_FUNCTION
void set_values(T val);

// Get the name of the view
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -7072,14 +7080,22 @@ Kokkos::View<T*, Layout, ExecSpace, MemoryTraits> RaggedRightArrayKokkos<T,Layou
return array_;
}

//set values to input
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits, typename ILayout>
KOKKOS_INLINE_FUNCTION
void RaggedRightArrayKokkos<T,Layout,ExecSpace,MemoryTraits,ILayout>::set_values(T val) {
Kokkos::parallel_for("SetValues_RaggedRightArrayKokkos", length_, KOKKOS_CLASS_LAMBDA(const int i) {
array_(i) = val;
});
}

// Get the name of the view
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits, typename ILayout>
KOKKOS_INLINE_FUNCTION
const std::string RaggedRightArrayKokkos<T,Layout,ExecSpace,MemoryTraits,ILayout>::get_name() const{
return array_.label();
}


// Destructor
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits, typename ILayout>
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -7503,6 +7519,7 @@ class RaggedDownArrayKokkos {
KOKKOS_INLINE_FUNCTION
T& operator()(size_t i, size_t j) const;

//return pointer
KOKKOS_INLINE_FUNCTION
T* pointer();

Expand All @@ -7516,6 +7533,13 @@ class RaggedDownArrayKokkos {

KOKKOS_INLINE_FUNCTION
RaggedDownArrayKokkos& operator= (const RaggedDownArrayKokkos &temp);

//print values
void print() const;

//set values to input
KOKKOS_INLINE_FUNCTION
void set_values(T val);

// Kokkos views of strides and start indices
Strides1D mystrides_;
Expand Down Expand Up @@ -7805,13 +7829,15 @@ Kokkos::View<T*, Layout, ExecSpace, MemoryTraits> RaggedDownArrayKokkos<T,Layout
return array_;
}

//set values to input
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits, typename ILayout>
KOKKOS_INLINE_FUNCTION
void RaggedDownArrayKokkos<T,Layout,ExecSpace,MemoryTraits,ILayout>::set_values(T val) {
Kokkos:parallel_for( Kokkos::RangePolicy<> ( 0, length_), KOKKOS_CLASS_LAMBDA(const int i){
Kokkos::parallel_for("SetValues_RaggedDownArrayKokkos", length_, KOKKOS_CLASS_LAMBDA(const int i) {
array_(i) = val;
});
}

// Get the name of the view
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits, typename ILayout>
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -7869,6 +7895,10 @@ class DynamicRaggedRightArrayKokkos {
KOKKOS_INLINE_FUNCTION
const std::string get_name() const;

// set values to input
KOKKOS_INLINE_FUNCTION
void set_values(T val);

// Overload operator() to access data as array(i,j),
// where i=[0:N-1], j=[stride(i)]
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -8006,10 +8036,11 @@ Kokkos::View<T*, Layout, ExecSpace, MemoryTraits> DynamicRaggedRightArrayKokkos<
return array_;
}

//set values to input
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits>
KOKKOS_INLINE_FUNCTION
void DynamicRaggedRightArrayKokkos<T,Layout,ExecSpace,MemoryTraits>::set_values(T val) {
Kokkos:parallel_for( Kokkos::RangePolicy<> ( 0, length_), KOKKOS_CLASS_LAMBDA(const int i){
Kokkos::parallel_for("SetValues_DynamicRaggedRightArrayKokkos", length_, KOKKOS_CLASS_LAMBDA(const int i) {
array_(i) = val;
});
}
Expand Down Expand Up @@ -8084,6 +8115,10 @@ class DynamicRaggedDownArrayKokkos {
KOKKOS_INLINE_FUNCTION
const std::string get_name() const;

//set values to input
KOKKOS_INLINE_FUNCTION
void set_values(T val);

// Overload operator() to access data as array(i,j),
// where i=[stride(j)], j=[0:N-1]
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -8221,10 +8256,11 @@ Kokkos::View<T*, Layout, ExecSpace, MemoryTraits> DynamicRaggedDownArrayKokkos<T
return array_;
}

//set values to input
template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits>
KOKKOS_INLINE_FUNCTION
void DynamicRaggedDownArrayKokkos<T,Layout,ExecSpace,MemoryTraits>::set_values(T val) {
Kokkos:parallel_for( Kokkos::RangePolicy<> ( 0, length_), KOKKOS_CLASS_LAMBDA(const int i){
Kokkos::parallel_for("SetValues_DynamicRaggedDownArrayKokkos", length_, KOKKOS_CLASS_LAMBDA(const int i) {
array_(i) = val;
});
}
Expand Down

0 comments on commit 4d15353

Please sign in to comment.