+ template <typename Number, typename MemorySpaceType>
+ template <typename MemorySpaceType2>
+ void
+ Vector<Number, MemorySpaceType>::import(
+ const Vector<Number, MemorySpaceType2> &src,
+ VectorOperation::values operation)
+ {
+ Assert(src.partitioner.get() != nullptr, ExcNotInitialized());
+ Assert(partitioner->locally_owned_range() ==
+ src.partitioner->locally_owned_range(),
+ ExcMessage("Locally owned indices should be identical."));
+ Assert(partitioner->ghost_indices() == src.partitioner->ghost_indices(),
+ ExcMessage("Ghost indices should be identical."));
+ ::dealii::internal::VectorOperations::
+ functions<Number, Number, MemorySpaceType>::import(
+ thread_loop_partitioner, allocated_size, operation, src.data, data);
+ }
+
+
+
#ifdef DEAL_II_WITH_PETSC
namespace petsc_helpers
#include <deal.II/lac/cuda_kernels.h>
#include <deal.II/lac/cuda_kernels.templates.h>
+#include <deal.II/lac/vector_operation.h>
#include <cstdio>
#include <cstring>
{
return Number();
}
+
+ template <typename MemorySpace2>
+ static void
+ import(
+ const std::shared_ptr<::dealii::parallel::internal::TBBPartitioner> &
+ /*thread_loop_partitioner*/,
+ const size_type /*size*/,
+ VectorOperation::values /*operation*/,
+ const ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace2>
+ & /*v_data*/,
+ ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace> & /*data*/)
+ {}
};
return sum;
}
+
+ template <typename MemorySpace2>
+ static void
+ import(const std::shared_ptr<::dealii::parallel::internal::TBBPartitioner>
+ & thread_loop_partitioner,
+ const size_type size,
+ VectorOperation::values operation,
+ const ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace2>
+ &v_data,
+ ::dealii::MemorySpace::MemorySpaceData<Number,
+ ::dealii::MemorySpace::Host>
+ &data,
+ typename std::enable_if<
+ std::is_same<MemorySpace2, dealii::MemorySpace::Host>::value,
+ int>::type = 0)
+ {
+ if (operation == VectorOperation::insert)
+ {
+ copy(thread_loop_partitioner, size, v_data, data);
+ }
+ else if (operation == VectorOperation::add)
+ {
+ add_vector(thread_loop_partitioner, size, v_data, data);
+ }
+ else
+ {
+ AssertThrow(false, ExcNotImplemented());
+ }
+ }
+
+#ifdef DEAL_II_COMPILER_CUDA_AWARE
+ template <typename MemorySpace2>
+ static void
+ import(const std::shared_ptr<::dealii::parallel::internal::TBBPartitioner>
+ & /*thread_loop_partitioner*/,
+ const size_type size,
+ VectorOperation::values operation,
+ const ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace2>
+ &v_data,
+ ::dealii::MemorySpace::MemorySpaceData<Number,
+ ::dealii::MemorySpace::Host>
+ &data,
+ typename std::enable_if<
+ std::is_same<MemorySpace2, ::dealii::MemorySpace::CUDA>::value,
+ int>::type = 0)
+ {
+ if (operation == VectorOperation::insert)
+ {
+ cudaError_t cuda_error_code = cudaMemcpy(data.values.get(),
+ v_data.values_dev.get(),
+ size * sizeof(Number),
+ cudaMemcpyDeviceToHost);
+ AssertCuda(cuda_error_code);
+ }
+ else
+ {
+ AssertThrow(false, ExcNotImplemented());
+ }
+ }
+#endif
};
return res;
}
+
+ template <typename MemorySpace2>
+ static void
+ import(const std::shared_ptr<::dealii::parallel::internal::TBBPartitioner>
+ & thread_loop_partitioner,
+ const size_type size,
+ VectorOperation::values operation,
+ const ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace2>
+ &v_data,
+ ::dealii::MemorySpace::MemorySpaceData<Number,
+ ::dealii::MemorySpace::CUDA>
+ &data,
+ typename std::enable_if<
+ std::is_same<MemorySpace2, ::dealii::MemorySpace::CUDA>::value,
+ int>::type = 0)
+ {
+ if (operation == VectorOperation::insert)
+ {
+ copy(thread_loop_partitioner, size, v_data, data);
+ }
+ else if (operation == VectorOperation::add)
+ {
+ add_vector(thread_loop_partitioner, size, v_data, data);
+ }
+ else
+ {
+ AssertThrow(false, ExcNotImplemented());
+ }
+ }
+
+ template <typename MemorySpace2>
+ static void
+ import(const std::shared_ptr<::dealii::parallel::internal::TBBPartitioner>
+ & /*thread_loop_partitioner*/,
+ const size_type size,
+ VectorOperation::values operation,
+ const ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace2>
+ &v_data,
+ ::dealii::MemorySpace::MemorySpaceData<Number,
+ ::dealii::MemorySpace::CUDA>
+ &data,
+ typename std::enable_if<
+ std::is_same<MemorySpace2, ::dealii::MemorySpace::Host>::value,
+ int>::type = 0)
+ {
+ if (operation == VectorOperation::insert)
+ {
+ cudaError_t cuda_error_code = cudaMemcpy(data.values_dev.get(),
+ v_data.values.get(),
+ size * sizeof(Number),
+ cudaMemcpyHostToDevice);
+ AssertCuda(cuda_error_code);
+ }
+ else
+ {
+ AssertThrow(false, ExcNotImplemented());
+ }
+ }
};
#endif
} // namespace VectorOperations
{
template class Vector<float, ::dealii::MemorySpace::CUDA>;
template class Vector<double, ::dealii::MemorySpace::CUDA>;
+ template void
+ Vector<float, ::dealii::MemorySpace::Host>::import<
+ ::dealii::MemorySpace::CUDA>(
+ const Vector<float, ::dealii::MemorySpace::CUDA> &,
+ VectorOperation::values);
+ template void
+ Vector<double, ::dealii::MemorySpace::Host>::import<
+ ::dealii::MemorySpace::CUDA>(
+ const Vector<double, ::dealii::MemorySpace::CUDA> &,
+ VectorOperation::values);
+
+ template void
+ Vector<float, ::dealii::MemorySpace::CUDA>::import<
+ ::dealii::MemorySpace::Host>(
+ const Vector<float, ::dealii::MemorySpace::Host> &,
+ VectorOperation::values);
+ template void
+ Vector<double, ::dealii::MemorySpace::CUDA>::import<
+ ::dealii::MemorySpace::Host>(
+ const Vector<double, ::dealii::MemorySpace::Host> &,
+ VectorOperation::values);
+
+ template void
+ Vector<float, ::dealii::MemorySpace::CUDA>::import<
+ ::dealii::MemorySpace::CUDA>(
+ const Vector<float, ::dealii::MemorySpace::CUDA> &,
+ VectorOperation::values);
+ template void
+ Vector<double, ::dealii::MemorySpace::CUDA>::import<
+ ::dealii::MemorySpace::CUDA>(
+ const Vector<double, ::dealii::MemorySpace::CUDA> &,
+ VectorOperation::values);
} // namespace distributed
} // namespace LinearAlgebra