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

Merge branch 'TO/matrices-adaptive-csr' into 'develop'

To/matrices adaptive csr

See merge request !89
parents 7fc5f17b 3d90c996
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,3 +15,4 @@

# VSCode
/.vscode
.gdb_history
+15 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ option(WITH_OPENMP "Build with OpenMP support" ON)
option(WITH_MPI "Build with MPI support" ON)
option(WITH_GMP "Build with GMP support" OFF)
option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF)
option(WITH_SYSTEM_GTEST "Use GTest installed in the local system and do not download the latest version" OFF)
option(BUILD_BENCHMARKS "Compile the 'src/Benchmarks' directory" OFF)
option(BUILD_EXAMPLES "Compile the 'src/Examples' directory" OFF)
option(BUILD_TOOLS "Compile the 'src/Tools' directory" OFF)
@@ -158,8 +159,19 @@ link_libraries( stdc++fs )
if( ${BUILD_TESTS} OR ${BUILD_MATRIX_TESTS} )
   enable_testing()

   if( ${WITH_SYSTEM_GTEST} OR ${OFFLINE_BUILD} )
      # find gtest installed in the local system
      find_package(GTest REQUIRED)
      if( GTEST_FOUND )
         set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_GTEST )
         include_directories( ${GTEST_INCLUDE_DIRS} )
         link_libraries( ${GTEST_LIBRARIES} )
      endif( GTEST_FOUND )
   else()
      # build gtest libs
      include( BuildGtest )
   endif()


   if( ${WITH_COVERAGE} AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
      # enable code coverage reports
@@ -372,6 +384,7 @@ message( " WITH_OPENMP = ${WITH_OPENMP}" )
message( "   WITH_MPI = ${WITH_MPI}" )
message( "   WITH_GMP = ${WITH_GMP}" )
message( "   WITH_COVERAGE = ${WITH_COVERAGE}" )
message( "   WITH_SYSTEM_GTEST= ${WITH_SYSTEM_GTEST}" )
message( "   BUILD_BENCHMARKS = ${BUILD_BENCHMARKS}" )
message( "   BUILD_EXAMPLES = ${BUILD_EXAMPLES}" )
message( "   BUILD_TOOLS = ${BUILD_TOOLS}" )
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ int main( int argc, char* argv[] )
    */
   Vector< double, Devices::Host > host_v1( 10 ), host_v2( 10 ), host_result( 10 );
   host_v1 = 1.0;
   host_v2.evaluate( []__cuda_callable__ ( int i )->double { return i; } );
   host_v2.forEachElement( []__cuda_callable__ ( int i, double& v ) { v = i; } );
   vectorSum( host_v1, host_v2, 2.0, host_result );
   std::cout << "host_v1 = " << host_v1 << std::endl;
   std::cout << "host_v2 = " << host_v2 << std::endl;
@@ -48,7 +48,7 @@ int main( int argc, char* argv[] )
#ifdef HAVE_CUDA
   Vector< double, Devices::Cuda > cuda_v1( 10 ), cuda_v2( 10 ), cuda_result( 10 );
   cuda_v1 = 1.0;
   cuda_v2.evaluate( []__cuda_callable__ ( int i )->double { return i; } );
   cuda_v2.forEachElement( []__cuda_callable__ ( int i, double& v ) { v = i; } );
   vectorSum( cuda_v1, cuda_v2, 2.0, cuda_result );
   std::cout << "cuda_v1 = " << cuda_v1 << std::endl;
   std::cout << "cuda_v2 = " << cuda_v2 << std::endl;
+44 −0
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>
#include <TNL/Containers/ArrayView.h>

using namespace TNL;

template< typename Device >
void forElementsExample()
{
   /****
    * Create new arrays
    */
   const int size = 10;
   Containers::Array< float, Device > a( size ), b( size );
   b = 0;

   /****
    * Initiate the elements of array `a`
    */
   a.forEachElement( [] __cuda_callable__ ( int i, float& value ) { value = i; } );

   /****
    * Initiate elements of array `b` with indexes 0-4 using `a_view`
    */
   auto a_view = a.getView();
   b.forElements( 0, 5, [=] __cuda_callable__ ( int i, float& value ) { value = a_view[ i ] + 4.0; } );

   /****
    * Print the results
    */
   std::cout << " a = " << a << std::endl;
   std::cout << " b = " << b << std::endl;
}

int main( int argc, char* argv[] )
{
   std::cout << "Running example on the host system: " << std::endl;
   forElementsExample< Devices::Host >();

#ifdef HAVE_CUDA
   std::cout << "Running example on the CUDA device: " << std::endl;
   forElementsExample< Devices::Cuda >();
#endif
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
ArrayExample_forElements.cpp
 No newline at end of file
Loading