Loading src/core/tnlCuda.h +24 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,30 @@ class tnlCuda { return setMemoryCuda( destination, value, size ); } static int getMaxGridSize() { return maxGridSize; } static void setMaxGridSize( int newMaxGridSize ) { maxGridSize = newMaxGridSize; } static int getMaxBlockSize() { return maxBlockSize; } static void setMaxBlockSize( int newMaxBlockSize ) { maxBlockSize = newMaxBlockSize; } protected: static int maxGridSize, maxBlockSize; }; Loading src/implementation/core/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ IF( BUILD_CUDA ) ${CURRENT_DIR}/memory-operations_impl.cu ${CURRENT_DIR}/tnlArray_impl.cu ${CURRENT_DIR}/tnlVector_impl.cu ${CURRENT_DIR}/tnlCuda.cu PARENT_SCOPE ) ENDIF() Loading src/implementation/core/memory-operations.h +3 −2 Original line number Diff line number Diff line Loading @@ -99,13 +99,14 @@ __global__ void setVectorValueCudaKernel( Element* data, template< typename Element, typename Index > bool setMemoryCuda( Element* data, const Element& value, const Index size ) const Index size, const int maxGridSize ) { #ifdef HAVE_CUDA dim3 blockSize( 0 ), gridSize( 0 ); blockSize. x = 256; Index blocksNumber = ceil( ( double ) size / ( double ) blockSize. x ); gridSize. x = Min( blocksNumber, ( Index ) maxCudaGridSize - 1 ); gridSize. x = Min( blocksNumber, maxGridSize ); setVectorValueCudaKernel<<< gridSize, blockSize >>>( data, size, value ); return checkCudaDevice; Loading src/implementation/core/tnlCuda.cu 0 → 100644 +23 −0 Original line number Diff line number Diff line /*************************************************************************** tnlCuda.cu - description ------------------- begin : Jul 11, 2013 copyright : (C) 2013 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <core/tnlCuda.h> #include <tnlConfig.h> int tnlCuda :: maxGridSize = maxCudaGridSize; int tnlCuda :: maxBlockSize = maxCudaBlockSize; tnlConfig.h.in +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ #define TNL_CPP_COMPILER_NAME "@CMAKE_CXX_COMPILER@" #define maxCudaGridSize 65536 #define maxCudaGridSize 65535 #define maxCudaBlockSize 1024 #define maxCudaBlockSize 1023 Loading
src/core/tnlCuda.h +24 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,30 @@ class tnlCuda { return setMemoryCuda( destination, value, size ); } static int getMaxGridSize() { return maxGridSize; } static void setMaxGridSize( int newMaxGridSize ) { maxGridSize = newMaxGridSize; } static int getMaxBlockSize() { return maxBlockSize; } static void setMaxBlockSize( int newMaxBlockSize ) { maxBlockSize = newMaxBlockSize; } protected: static int maxGridSize, maxBlockSize; }; Loading
src/implementation/core/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ IF( BUILD_CUDA ) ${CURRENT_DIR}/memory-operations_impl.cu ${CURRENT_DIR}/tnlArray_impl.cu ${CURRENT_DIR}/tnlVector_impl.cu ${CURRENT_DIR}/tnlCuda.cu PARENT_SCOPE ) ENDIF() Loading
src/implementation/core/memory-operations.h +3 −2 Original line number Diff line number Diff line Loading @@ -99,13 +99,14 @@ __global__ void setVectorValueCudaKernel( Element* data, template< typename Element, typename Index > bool setMemoryCuda( Element* data, const Element& value, const Index size ) const Index size, const int maxGridSize ) { #ifdef HAVE_CUDA dim3 blockSize( 0 ), gridSize( 0 ); blockSize. x = 256; Index blocksNumber = ceil( ( double ) size / ( double ) blockSize. x ); gridSize. x = Min( blocksNumber, ( Index ) maxCudaGridSize - 1 ); gridSize. x = Min( blocksNumber, maxGridSize ); setVectorValueCudaKernel<<< gridSize, blockSize >>>( data, size, value ); return checkCudaDevice; Loading
src/implementation/core/tnlCuda.cu 0 → 100644 +23 −0 Original line number Diff line number Diff line /*************************************************************************** tnlCuda.cu - description ------------------- begin : Jul 11, 2013 copyright : (C) 2013 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <core/tnlCuda.h> #include <tnlConfig.h> int tnlCuda :: maxGridSize = maxCudaGridSize; int tnlCuda :: maxBlockSize = maxCudaBlockSize;
tnlConfig.h.in +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ #define TNL_CPP_COMPILER_NAME "@CMAKE_CXX_COMPILER@" #define maxCudaGridSize 65536 #define maxCudaGridSize 65535 #define maxCudaBlockSize 1024 #define maxCudaBlockSize 1023