Commit aa1dbbc2 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Writting documentation on sparse matrices.

parent 1efbddf2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -11,12 +11,19 @@ void setElements()
{
   auto rowCapacities = { 1, 1, 1, 1, 1 };
   TNL::Pointers::SharedPointer< TNL::Matrices::SparseMatrix< double, Device > > matrix( rowCapacities, 5 );

   /***
    * Calling the method setElements from host (CPU).
    */
   for( int i = 0; i < 5; i++ )
      matrix->setElement( i, i, i );

   std::cout << "Matrix set from the host:" << std::endl;
   std::cout << *matrix << std::endl;

   /***
    * This lambda function will run on the native device of the matrix which can be CPU or GPU.
    */
   auto f = [=] __cuda_callable__ ( int i ) mutable {
      matrix->setElement( i, i, -i );
   };
+37 −1
Original line number Diff line number Diff line
@@ -49,6 +49,37 @@ IF( BUILD_CUDA )
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_rowCapacities_vector.out
                       OUTPUT SparseMatrixExample_Constructor_rowCapacities_vector.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map SparseMatrixExample_Constructor_std_map.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out
                       OUTPUT SparseMatrixExample_Constructor_std_map.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElements SparseMatrixExample_setElements.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements.out
                       OUTPUT SparseMatrixExample_setElements.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElements_map SparseMatrixExample_setElements_map.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements_map >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements_map.out
                       OUTPUT SparseMatrixExample_setElements_map.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElement SparseMatrixExample_setElement.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out
                       OUTPUT SparseMatrixExample_setElement.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_addElement SparseMatrixExample_addElement.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out
                       OUTPUT SparseMatrixExample_addElement.out )

   CUDA_ADD_EXECUTABLE( SparseMatrixExample_forRows SparseMatrixExample_forRows.cu )
   ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_forRows >
                       ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_forRows.out
                       OUTPUT SparseMatrixExample_forRows.out )


ELSE()
#   ADD_EXECUTABLE( UniquePointerExample UniquePointerExample.cpp )
#   ADD_CUSTOM_COMMAND( COMMAND UniquePointerExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/UniquePointerExample.out OUTPUT UniquePointerExample.out )
@@ -69,6 +100,11 @@ ADD_CUSTOM_TARGET( TutorialsMatricesCuda ALL DEPENDS
   DenseMatrixViewExample_setElement.out
   SparseMatrixExample_Constructor_init_list_2.out
   SparseMatrixExample_setRowCapacities.out
   SparseMatrixExample_Constructor_std_map.out
   SparseMatrixExample_setElements.out
   SparseMatrixExample_setElements_map.out
   SparseMatrixExample_setElement.out
   SparseMatrixExample_forRows.out
 )
ENDIF()
#
+1 −0
Original line number Diff line number Diff line
../../Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_std_map.cpp
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
../../Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_std_map.cu
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
../../Examples/Matrices/SparseMatrix/SparseMatrixExample_addElement.cpp
 No newline at end of file
Loading