Skip to content
Snippets Groups Projects
Commit f9770581 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed unused code for vector-scalar multiplication

parent acf1caab
No related branches found
No related tags found
1 merge request!36Fixed expression templates
......@@ -37,9 +37,6 @@ public:
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator );
template< typename Vector, typename Scalar >
static void vectorScalarMultiplication( Vector& v, Scalar alpha );
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
static void addVector( Vector1& y,
const Vector2& x,
......@@ -85,9 +82,6 @@ public:
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator );
template< typename Vector, typename Scalar >
static void vectorScalarMultiplication( Vector& v, const Scalar alpha );
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
static void addVector( Vector1& y,
const Vector2& x,
......
......@@ -39,47 +39,6 @@ addElement( Vector& v,
v[ i ] = thisElementMultiplicator * v[ i ] + value;
}
#ifdef HAVE_CUDA
template< typename Real, typename Index, typename Scalar >
__global__ void
vectorScalarMultiplicationCudaKernel( Real* data,
Index size,
Scalar alpha )
{
Index elementIdx = blockDim.x * blockIdx.x + threadIdx.x;
const Index maxGridSize = blockDim.x * gridDim.x;
while( elementIdx < size )
{
data[ elementIdx ] *= alpha;
elementIdx += maxGridSize;
}
}
#endif
template< typename Vector, typename Scalar >
void
VectorOperations< Devices::Cuda >::
vectorScalarMultiplication( Vector& v,
const Scalar alpha )
{
TNL_ASSERT_GT( v.getSize(), 0, "Vector size must be positive." );
#ifdef HAVE_CUDA
typedef typename Vector::IndexType Index;
dim3 blockSize( 0 ), gridSize( 0 );
const Index& size = v.getSize();
blockSize.x = 256;
Index blocksNumber = TNL::ceil( ( double ) size / ( double ) blockSize.x );
gridSize.x = min( blocksNumber, Devices::Cuda::getMaxGridSize() );
vectorScalarMultiplicationCudaKernel<<< gridSize, blockSize >>>( v.getData(),
size,
alpha );
TNL_CHECK_CUDA_DEVICE;
#else
throw Exceptions::CudaSupportMissing();
#endif
}
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
void
VectorOperations< Devices::Cuda >::
......
......@@ -41,27 +41,6 @@ addElement( Vector& v,
v[ i ] = thisElementMultiplicator * v[ i ] + value;
}
template< typename Vector, typename Scalar >
void
VectorOperations< Devices::Host >::
vectorScalarMultiplication( Vector& v,
const Scalar alpha )
{
typedef typename Vector::IndexType Index;
TNL_ASSERT_GT( v.getSize(), 0, "Vector size must be positive." );
const Index n = v.getSize();
#ifdef HAVE_OPENMP
#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold
#endif
for( Index i = 0; i < n; i ++ )
v[ i ] *= alpha;
}
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
void
VectorOperations< Devices::Host >::
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment