Loading Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +11 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector_cuda SparseMatrixExample_Constructor_rowCapacities_vector.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map_cuda SparseMatrixExample_Constructor_std_map.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out Loading Loading @@ -150,6 +155,11 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector SparseMatrixExample_Constructor_rowCapacities_vector.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map SparseMatrixExample_Constructor_std_map.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out Loading Loading @@ -285,6 +295,7 @@ ENDIF() ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_Constructor_init_list_1.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_Constructor_rowCapacities_vector.out SparseMatrixExample_Constructor_std_map.out SparseMatrixExample_getSerializationType.out SparseMatrixExample_setRowCapacities.out Loading Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_rowCapacities_vector.cpp 0 → 100644 +30 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Containers/Vector.h> #include <TNL/Devices/Host.h> template< typename Device > void initializerListExample() { TNL::Containers::Vector< int, Device > rowCapacities{ 1, 2, 3, 4, 5 }; TNL::Matrices::SparseMatrix< double, Device > matrix { rowCapacities, // row capacities 6 }; // number of matrix columns for( int row = 0; row < matrix.getRows(); row++ ) for( int column = 0; column <= row; column++ ) matrix.setElement( row, column, row - column + 1 ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; initializerListExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; initializerListExample< TNL::Devices::Cuda >(); #endif } Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_rowCapacities_vector.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_rowCapacities_vector.cpp No newline at end of file Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_setRowCapacities.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -19,11 +19,11 @@ void setRowCapacitiesExample() int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; std::cout << "Creating matrix on CPU ... " << std::endl; setRowCapacitiesExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; std::cout << "Creating matrix on CUDA GPU ... " << std::endl; setRowCapacitiesExample< TNL::Devices::Cuda >(); #endif } Documentation/Tutorials/Matrices/CMakeLists.txt +38 −7 Original line number Diff line number Diff line IF( BUILD_CUDA ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_Constructor_init_list DenseMatrixExample_Constructor_init_list.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_Constructor_init_list > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_Constructor_init_list.out OUTPUT DenseMatrixExample_Constructor_init_list.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_Constructor_init_list > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_Constructor_init_list.out OUTPUT DenseMatrixExample_Constructor_init_list.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_addElement DenseMatrixExample_addElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_addElement.out OUTPUT DenseMatrixExample_addElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_addElement.out OUTPUT DenseMatrixExample_addElement.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_setElement DenseMatrixExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_setElement.out OUTPUT DenseMatrixExample_setElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_setElement.out OUTPUT DenseMatrixExample_setElement.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_forRows DenseMatrixExample_forRows.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_forRows > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_forRows.out OUTPUT DenseMatrixExample_forRows.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_forRows > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_forRows.out OUTPUT DenseMatrixExample_forRows.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_rowsReduction_vectorProduct DenseMatrixExample_rowsReduction_vectorProduct.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_vectorProduct > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_vectorProduct.out OUTPUT DenseMatrixExample_rowsReduction_vectorProduct.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_vectorProduct > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_vectorProduct.out OUTPUT DenseMatrixExample_rowsReduction_vectorProduct.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_rowsReduction_maxNorm DenseMatrixExample_rowsReduction_maxNorm.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_maxNorm > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_maxNorm.out OUTPUT DenseMatrixExample_rowsReduction_maxNorm.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_maxNorm > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_maxNorm.out OUTPUT DenseMatrixExample_rowsReduction_maxNorm.out ) CUDA_ADD_EXECUTABLE( DenseMatrixViewExample_setElement DenseMatrixViewExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixViewExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixViewExample_setElement.out OUTPUT DenseMatrixViewExample_setElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixViewExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixViewExample_setElement.out OUTPUT DenseMatrixViewExample_setElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2 SparseMatrixExample_Constructor_init_list_2.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2 > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_setRowCapacities SparseMatrixExample_setRowCapacities.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setRowCapacities > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setRowCapacities.out OUTPUT SparseMatrixExample_setRowCapacities.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector SparseMatrixExample_Constructor_rowCapacities_vector.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) ELSE() # ADD_EXECUTABLE( UniquePointerExample UniquePointerExample.cpp ) Loading @@ -38,6 +67,8 @@ ADD_CUSTOM_TARGET( TutorialsMatricesCuda ALL DEPENDS DenseMatrixExample_rowsReduction_vectorProduct.out DenseMatrixExample_rowsReduction_maxNorm.out DenseMatrixViewExample_setElement.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_setRowCapacities.out ) ENDIF() # Loading Loading
Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +11 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector_cuda SparseMatrixExample_Constructor_rowCapacities_vector.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map_cuda SparseMatrixExample_Constructor_std_map.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out Loading Loading @@ -150,6 +155,11 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector SparseMatrixExample_Constructor_rowCapacities_vector.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map SparseMatrixExample_Constructor_std_map.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out Loading Loading @@ -285,6 +295,7 @@ ENDIF() ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_Constructor_init_list_1.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_Constructor_rowCapacities_vector.out SparseMatrixExample_Constructor_std_map.out SparseMatrixExample_getSerializationType.out SparseMatrixExample_setRowCapacities.out Loading
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_rowCapacities_vector.cpp 0 → 100644 +30 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Containers/Vector.h> #include <TNL/Devices/Host.h> template< typename Device > void initializerListExample() { TNL::Containers::Vector< int, Device > rowCapacities{ 1, 2, 3, 4, 5 }; TNL::Matrices::SparseMatrix< double, Device > matrix { rowCapacities, // row capacities 6 }; // number of matrix columns for( int row = 0; row < matrix.getRows(); row++ ) for( int column = 0; column <= row; column++ ) matrix.setElement( row, column, row - column + 1 ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; initializerListExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; initializerListExample< TNL::Devices::Cuda >(); #endif }
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_rowCapacities_vector.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_rowCapacities_vector.cpp No newline at end of file
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_setRowCapacities.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -19,11 +19,11 @@ void setRowCapacitiesExample() int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; std::cout << "Creating matrix on CPU ... " << std::endl; setRowCapacitiesExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; std::cout << "Creating matrix on CUDA GPU ... " << std::endl; setRowCapacitiesExample< TNL::Devices::Cuda >(); #endif }
Documentation/Tutorials/Matrices/CMakeLists.txt +38 −7 Original line number Diff line number Diff line IF( BUILD_CUDA ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_Constructor_init_list DenseMatrixExample_Constructor_init_list.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_Constructor_init_list > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_Constructor_init_list.out OUTPUT DenseMatrixExample_Constructor_init_list.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_Constructor_init_list > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_Constructor_init_list.out OUTPUT DenseMatrixExample_Constructor_init_list.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_addElement DenseMatrixExample_addElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_addElement.out OUTPUT DenseMatrixExample_addElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_addElement.out OUTPUT DenseMatrixExample_addElement.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_setElement DenseMatrixExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_setElement.out OUTPUT DenseMatrixExample_setElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_setElement.out OUTPUT DenseMatrixExample_setElement.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_forRows DenseMatrixExample_forRows.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_forRows > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_forRows.out OUTPUT DenseMatrixExample_forRows.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_forRows > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_forRows.out OUTPUT DenseMatrixExample_forRows.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_rowsReduction_vectorProduct DenseMatrixExample_rowsReduction_vectorProduct.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_vectorProduct > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_vectorProduct.out OUTPUT DenseMatrixExample_rowsReduction_vectorProduct.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_vectorProduct > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_vectorProduct.out OUTPUT DenseMatrixExample_rowsReduction_vectorProduct.out ) CUDA_ADD_EXECUTABLE( DenseMatrixExample_rowsReduction_maxNorm DenseMatrixExample_rowsReduction_maxNorm.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_maxNorm > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_maxNorm.out OUTPUT DenseMatrixExample_rowsReduction_maxNorm.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixExample_rowsReduction_maxNorm > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixExample_rowsReduction_maxNorm.out OUTPUT DenseMatrixExample_rowsReduction_maxNorm.out ) CUDA_ADD_EXECUTABLE( DenseMatrixViewExample_setElement DenseMatrixViewExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixViewExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixViewExample_setElement.out OUTPUT DenseMatrixViewExample_setElement.out ) ADD_CUSTOM_COMMAND( COMMAND DenseMatrixViewExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DenseMatrixViewExample_setElement.out OUTPUT DenseMatrixViewExample_setElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2 SparseMatrixExample_Constructor_init_list_2.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2 > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_setRowCapacities SparseMatrixExample_setRowCapacities.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setRowCapacities > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setRowCapacities.out OUTPUT SparseMatrixExample_setRowCapacities.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_rowCapacities_vector SparseMatrixExample_Constructor_rowCapacities_vector.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_rowCapacities_vector > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out ) ELSE() # ADD_EXECUTABLE( UniquePointerExample UniquePointerExample.cpp ) Loading @@ -38,6 +67,8 @@ ADD_CUSTOM_TARGET( TutorialsMatricesCuda ALL DEPENDS DenseMatrixExample_rowsReduction_vectorProduct.out DenseMatrixExample_rowsReduction_maxNorm.out DenseMatrixViewExample_setElement.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_setRowCapacities.out ) ENDIF() # Loading