1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
7#include <kernel/base_header.hpp>
8#include <kernel/lafem/arch/component_product_dense.hpp>
9#include <kernel/util/exception.hpp>
10#include <kernel/util/cuda_util.hpp>
11#include <kernel/util/half.hpp>
13namespace FEAT::LAFEM::Arch
15 template <typename DT_>
16 __global__ void cuda_component_product_dense(DT_ * r, const DT_ * x, const DT_ * y, const Index size)
18 for(Index i = threadIdx.x + blockDim.x * blockIdx.x; i < size; i += blockDim.x * gridDim.x)
24 template <typename DT_>
25 void ComponentProductDense::exec_cuda_impl(DT_ * r, const DT_ * const x, const DT_ * const y, const Index size)
27 dim3 block(static_cast<unsigned int>(Util::cuda_blocksize_axpy));
28 dim3 grid((static_cast<unsigned int>(size) + block.x - 1u) / block.x); // round up to next integer
30 cuda_component_product_dense<<<grid, block>>>(r, x, y, size);
33 cudaError_t last_error(cudaGetLastError());
34 if (cudaSuccess != last_error)
35 throw InternalError(__func__, __FILE__, __LINE__, "CUDA error occurred in execution!\n" + stringify(cudaGetErrorString(last_error)));
39#ifdef FEAT_HAVE_HALFMATH
40 template void ComponentProductDense::exec_cuda_impl(Half *, const Half * const, const Half * const, const Index);
42 template void ComponentProductDense::exec_cuda_impl(float *, const float * const, const float * const, const Index);
43 template void ComponentProductDense::exec_cuda_impl(double *, const double * const, const double * const, const Index);
44} // namespace FEAT::LAFEM::Arch