OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::BlockLatticeFieldReductionO< FIELD, REDUCTION_OP, CONDITION >::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > > Struct Template Reference

#include <fieldReduction.h>

+ Collaboration diagram for olb::BlockLatticeFieldReductionO< FIELD, REDUCTION_OP, CONDITION >::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >:

Public Member Functions

void setup (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &blockLattice)
 
void apply (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &blockLattice)
 

Detailed Description

template<typename FIELD, typename REDUCTION_OP, typename CONDITION>
template<typename T, typename DESCRIPTOR>
struct olb::BlockLatticeFieldReductionO< FIELD, REDUCTION_OP, CONDITION >::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >

Definition at line 33 of file fieldReduction.h.

Member Function Documentation

◆ apply()

template<typename FIELD , typename REDUCTION_OP , typename CONDITION >
template<typename T , typename DESCRIPTOR >
void olb::BlockLatticeFieldReductionO< FIELD, REDUCTION_OP, CONDITION >::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >::apply ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & blockLattice)

Definition at line 186 of file fieldReduction.hh.

187{
188 auto& parameters = blockLattice.template getData<OperatorParameters<BlockLatticeFieldReductionO>>().parameters;
189 const auto& blockField = blockLattice.template getField<FIELD>();
190
192 parameters.template get<fields::array_of<FIELD>>(); //not auto. because of considering 1 dimensional field
193
194 /*note
195 -blockField[iD].deviceData(); is return row pointer T* in device.
196 -thrust::device_pointer_cast(elementField[iD])[0] is that thrust::device_pointer_cast is casting to thrust::device_ptr<T> from T* in device.
197 -thrust::device_pointer_cast(
198 blockField[iD].deviceData()); is that thrust::device_pointer_cast is casting to thrust::device_ptr<T> from T* in device.
199 -thrust::raw_pointer_cast(d_partial.data());, with thrust::device_vector<T> d_partial(block_count, (T)0.0);, is that thrust::raw_pointer_cast is casting to T* from thrust::raw_pointer_cast in device.
200
201 */
202
203 for (unsigned iD = 0; iD < blockField.d; iD++) {
204 cudaPointerAttributes attributes;
205 cudaError_t error = cudaPointerGetAttributes(&attributes, elementField[iD]);
206 if (error == cudaSuccess) {
207 if (attributes.devicePointer != nullptr) {
208 }
209 else if (attributes.hostPointer != nullptr) {
210 std::cout << "elementField is on the host" << std::endl;
211 }
212 }
213 else {
214 std::cerr << "Error in cudaPointerGetAttributes: " << cudaGetErrorString(error) << std::endl;
215 }
216 auto devPtr = thrust::device_pointer_cast(
217 blockField[iD].deviceData()); // thrust::device_pointer_cast is casting to thrust::device_ptr<T> from T*.
218 if (devPtr == nullptr) {
219 std::cerr << "Invalid device pointer at index " << iD << std::endl;
220 return;
221 }
222 reductionFunctionDevice<T, DESCRIPTOR, REDUCTION_OP, CONDITION>(devPtr, blockLattice, elementField[iD]);
223 }
224}
void reductionFunctionDevice(thrust::device_ptr< const T > devPtr, ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &blockLattice, T *paramInDevice)
Vector< typename FIELD::template value_type< T >, DESCRIPTOR::template size< FIELD >() > FieldD
Vector storing a single field instance.
Definition vector.h:480
meta::list< fields::array_of< FIELD > > parameters

References olb::reductionFunctionDevice().

+ Here is the call graph for this function:

◆ setup()

template<typename FIELD , typename REDUCTION_OP , typename CONDITION >
template<typename T , typename DESCRIPTOR >
void olb::BlockLatticeFieldReductionO< FIELD, REDUCTION_OP, CONDITION >::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >::setup ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & blockLattice)

Definition at line 178 of file fieldReduction.hh.

179{
180 blockLattice.template getData<OperatorParameters<BlockLatticeFieldReductionO>>();
181}

The documentation for this struct was generated from the following files: