Commit 76389ead authored by Jakub Klinkovský's avatar Jakub Klinkovský Committed by Jakub Klinkovský
Browse files

Added examples comparing native Hypre and TNL wrappers for Hypre

parent 19c5cac7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
add_subdirectory( Hypre )

#add_subdirectory( simple-examples )
#add_subdirectory( Hamilton-Jacobi )
#add_subdirectory( heat-equation )
+13 −0
Original line number Diff line number Diff line
if( ${BUILD_MPI} )
   find_package(Hypre)
   if( ${HYPRE_FOUND} )
      foreach( source IN ITEMS hypre-ex5.c tnl-hypre-ex5.cpp )
         string( REGEX REPLACE "\.cpp|\.c" "" target ${source} )
         add_executable( ${target} ${source} )
         target_compile_definitions( ${target} PUBLIC "-DHAVE_HYPRE" )
         target_include_directories( ${target} PUBLIC ${HYPRE_INCLUDE_DIRS} )
         target_link_libraries( ${target} ${HYPRE_LIBRARIES} -lm )
         install( TARGETS ${target} RUNTIME DESTINATION bin )
      endforeach()
   endif()
endif()
+47 −0
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
 * HYPRE Project Developers. See the top-level COPYRIGHT file for details.
 *
 * SPDX-License-Identifier: (Apache-2.0 OR MIT)
 ******************************************************************************/

/*--------------------------------------------------------------------------
 * Header file for examples
 *--------------------------------------------------------------------------*/

#ifndef HYPRE_EXAMPLES_INCLUDES
#define HYPRE_EXAMPLES_INCLUDES

#include <HYPRE_config.h>

#if defined(HYPRE_EXAMPLE_USING_CUDA)

#include <cuda_runtime.h>

#ifndef HYPRE_USING_UNIFIED_MEMORY
#error *** Running the examples on GPUs requires Unified Memory. Please reconfigure and rebuild with --enable-unified-memory ***
#endif

static inline void*
gpu_malloc(size_t size)
{
   void *ptr = NULL;
   cudaMallocManaged(&ptr, size, cudaMemAttachGlobal);
   return ptr;
}

static inline void*
gpu_calloc(size_t num, size_t size)
{
   void *ptr = NULL;
   cudaMallocManaged(&ptr, num * size, cudaMemAttachGlobal);
   cudaMemset(ptr, 0, num * size);
   return ptr;
}

#define malloc(size) gpu_malloc(size)
#define calloc(num, size) gpu_calloc(num, size)
#define free(ptr) ( cudaFree(ptr), ptr = NULL )
#endif /* #if defined(HYPRE_EXAMPLE_USING_CUDA) */
#endif /* #ifndef HYPRE_EXAMPLES_INCLUDES */
+22 −0
Original line number Diff line number Diff line
#!/bin/bash

ex=ex5
keys=Aaamc

dir="${1:-.}"
mesh="$dir/$ex.mesh"
sol="$dir/$ex.sol"

if ! test -e "$mesh"; then
    echo "Error: cannot find mesh file for $ex"
    exit 1
fi

echo "FiniteElementSpace" > "$sol"
echo "FiniteElementCollection: H1_2D_P1" >> "$sol"
echo "VDim: 1" >> "$sol"
echo "Ordering: 0" >> "$sol"
echo "" >> "$sol"
find "$dir" -name "$ex.sol.??????" | sort | xargs cat >> "$sol"

glvis -m "$mesh" -g "$sol" -k "$keys"
+674 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading