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

Used DevicePointer instead of passToDevice/freeFromDevice

RAII is a thing :-P
parent 320b5916
No related branches found
No related tags found
1 merge request!3Refactoring
......@@ -15,6 +15,7 @@
#include "benchmarks.h"
#include <TNL/Containers/List.h>
#include <TNL/DevicePointer.h>
#include <TNL/Matrices/CSR.h>
#include <TNL/Matrices/Ellpack.h>
#include <TNL/Matrices/SlicedEllpack.h>
......@@ -74,7 +75,7 @@ void setCudaTestMatrix( Matrix& matrix,
#ifdef HAVE_CUDA
typedef typename Matrix::IndexType IndexType;
typedef typename Matrix::RealType RealType;
Matrix* kernel_matrix = Devices::Cuda::passToDevice( matrix );
DevicePointer< Matrix > kernel_matrix( matrix );
dim3 cudaBlockSize( 256 ), cudaGridSize( Devices::Cuda::getMaxGridSize() );
const IndexType cudaBlocks = roundUpDivision( matrix.getRows(), cudaBlockSize.x );
const IndexType cudaGrids = roundUpDivision( cudaBlocks, Devices::Cuda::getMaxGridSize() );
......@@ -83,10 +84,9 @@ void setCudaTestMatrix( Matrix& matrix,
cudaGridSize.x = cudaBlocks % Devices::Cuda::getMaxGridSize();
setCudaTestMatrixKernel< Matrix >
<<< cudaGridSize, cudaBlockSize >>>
( kernel_matrix, elementsPerRow, gridIdx );
( &kernel_matrix.template modifyData< Devices::Cuda >(), elementsPerRow, gridIdx );
TNL_CHECK_CUDA_DEVICE;
}
Devices::Cuda::freeFromDevice( kernel_matrix );
#endif
}
......
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