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.hpp>
 
    9#include <kernel/util/exception.hpp>
 
   10#include <kernel/util/memory_pool.hpp>
 
   11#include <kernel/util/cuda_util.hpp>
 
   12#include <kernel/util/half.hpp>
 
   20      template <typename DT_>
 
   21      __global__ void cuda_ComponentProduct(DT_ * r, const DT_ * x, const DT_ * y, const Index count)
 
   23        Index idx = threadIdx.x + blockDim.x * blockIdx.x;
 
   26        r[idx] = x[idx] * y[idx];
 
   34using namespace FEAT::LAFEM;
 
   35using namespace FEAT::LAFEM::Arch;
 
   37template <typename DT_>
 
   38void ComponentProduct::value_cuda(DT_ * r, const DT_ * const x, const DT_ * const y, const Index size)
 
   40  Index blocksize = Util::cuda_blocksize_axpy;
 
   43  block.x = (unsigned)blocksize;
 
   44  grid.x = (unsigned)ceil((size)/(double)(block.x));
 
   46  FEAT::LAFEM::Intern::cuda_ComponentProduct<<<grid, block>>>(r, x, y, size);
 
   48  cudaDeviceSynchronize();
 
   50  cudaError_t last_error(cudaGetLastError());
 
   51  if (cudaSuccess != last_error)
 
   52    throw InternalError(__func__, __FILE__, __LINE__, "CUDA error occurred in execution!\n" + stringify(cudaGetErrorString(last_error)));
 
   55#ifdef FEAT_HAVE_HALFMATH
 
   56template void ComponentProduct::value_cuda(Half *, const Half * const, const Half * const, const Index);
 
   58template void ComponentProduct::value_cuda(float *, const float * const, const float * const, const Index);
 
   59template void ComponentProduct::value_cuda(double *, const double * const, const double * const, const Index);