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

Merge branch 'expression-templates-2' into 'develop'

Expression templates 2

See merge request !32
parents e6efd8c6 af7e0dc9
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
add_subdirectory( Tutorials )

## set input and output files
#set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
#set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

## request to configure the file
#configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
#
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)

## note the option ALL which allows to build the docs together with the application
#add_custom_target( doc_doxygen ALL
#    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
#    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#    COMMENT "Generating API documentation with Doxygen"
#    VERBATIM )
#
#INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/tnl )
#
add_custom_target( doc_doxygen ALL
    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "Generating API documentation with Doxygen"
    VERBATIM )

INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/tnl )
+2506 −0

File added.

Preview size limit exceeded, changes collapsed.

+47 −0
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>
#include <list>
#include <vector>

using namespace TNL;
using namespace TNL::Containers;

int main( int argc, char* argv[] )
{
   /****
    * Create one array on host and one array on device.
    */
   Array< int > host_array( 10 );
   Array< int, Devices::Cuda > device_array;

   /***
    * Initiate the host array with number three and assign it to the device array.
    * NOTE: Of course, you may do directly 'device_array = 3' as well.
    */
   host_array = 3;
   device_array = host_array;

   /****
    * Print both arrays.
    */
   std::cout << "host_array = " << host_array << std::endl;
   std::cout << "device_array = " << device_array << std::endl;
   std::cout << std::endl;

   /****
    * There are few other ways how to initialize arrays...
    */
   std::list< int > list { 1, 2, 3, 4, 5 };
   std::vector< int > vector { 6, 7, 8, 9, 10 };

   Array< int, Devices::Cuda > device_array_list( list );
   Array< int, Devices::Cuda > device_array_vector( vector );
   Array< int, Devices::Cuda > device_array_init_list { 11, 12, 13, 14, 15 };

   /****
    * ... and print them all
    */
   std::cout << "device_array_list = " << device_array_list << std::endl;
   std::cout << "device_array_vector = " << device_array_vector << std::endl;
   std::cout << "device_array_init_list = " << device_array_init_list << std::endl;
}
+1 −0
Original line number Diff line number Diff line
ArrayAllocation.cpp
 No newline at end of file
+37 −0
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/Containers/Array.h>

using namespace TNL;
using namespace TNL::Containers;

int main( int argc, char* argv[] )
{
   /****
    * Allocate an array on host
    */
   const int size = 10;
   int* ai = new int[ size ];

   /****
    * Bind the data with TNL array
    */
   Array< int > host_array;
   host_array.bind( ai, size );

   /****
    * Initialize the data using the TNL array
    */
   host_array = 66;

   /****
    * Check the data
    */
   for( int i = 0; i < size; i++ )
      std::cout << ai[ i ] << " ";
   std::cout << std::endl;

   /****
    * Free the allocated data
    */
   delete[] ai;
}
Loading