Commit 1cdd59cf authored by James Kress's avatar James Kress

Merge remote-tracking branch 'upstream/master'

parents d2abcfe8 06c3389a
......@@ -332,7 +332,7 @@ findpkg_finish(TBB_MALLOC_PROXY)
#=============================================================================
#parse all the version numbers from tbb
if(NOT TBB_VERSION)
if(NOT TBB_VERSION_MAJOR AND NOT TBB_VERSION_MINOR)
#only read the start of the file
file(READ
......
......@@ -56,8 +56,15 @@ endif()
# Enable large object support so we can have 2^32 addressable sections
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"/bigobj\" -Xcudafe=\"--diag_suppress=1394 --diag_suppress=766 --display_error_number\"")
if(CMAKE_VERSION VERSION_LESS 3.11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"/bigobj\"")
else()
target_compile_options(vtkm_compiler_flags INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:/bigobj>>)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_compiler_flags INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler="/bigobj">>)
endif()
endif()
endif()
# Setup the include directories that are needed for vtkm
......@@ -97,7 +104,7 @@ if(VTKM_COMPILER_IS_MSVC)
#CMake COMPILE_LANGUAGE doesn't work with MSVC, ans since we want these flags
#only for C++ compilation we have to resort to setting CMAKE_CXX_FLAGS :(
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4702 /wd4505")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"/wd4702 /wd4505\"")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"/wd4702 /wd4505\" -Xcudafe=\"--diag_suppress=1394 --diag_suppress=766 --display_error_number\"")
if(MSVC_VERSION LESS 1900)
# In VS2013 the C4127 warning has a bug in the implementation and
......@@ -116,10 +123,16 @@ elseif(VTKM_COMPILER_IS_ICC)
target_compile_definitions(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-wd1478 -wd13379>)
elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG)
set(flags -Wall -Wno-long-long -Wcast-align -Wconversion -Wchar-subscripts -Wextra -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wunused-parameter -fno-common)
set(cxx_flags -Wall -Wno-long-long -Wcast-align -Wconversion -Wchar-subscripts -Wextra -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wunused-parameter -fno-common)
set(cuda_flags "-Xcudafe=\"--display_error_number\"")
target_compile_options(vtkm_compiler_flags
INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:${flags}>>
INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>>
)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_compiler_flags
INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>>
)
endif()
endif()
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
......
......@@ -105,27 +105,22 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
# 1 - native
# - Uses system introspection to determine compile flags
# 2 - fermi
# - Uses: --generate-code=arch=compute_20,code=compute_20
# - Uses: --generate-code=arch=compute_20,code=sm_20
# 3 - kepler
# - Uses: --generate-code=arch=compute_30,code=compute_30
# - Uses: --generate-code=arch=compute_35,code=compute_35
# - Uses: --generate-code=arch=compute_30,code=sm_30
# - Uses: --generate-code=arch=compute_35,code=sm_35
# 4 - maxwell
# - Uses: --generate-code=arch=compute_50,code=compute_50
# - Uses: --generate-code=arch=compute_52,code=compute_52
# - Uses: --generate-code=arch=compute_50,code=sm_50
# 5 - pascal
# - Uses: --generate-code=arch=compute_60,code=compute_60
# - Uses: --generate-code=arch=compute_61,code=compute_61
# - Uses: --generate-code=arch=compute_60,code=sm_60
# 6 - volta
# - Uses: --generate-code=arch=compute_70,code=compute_70
# - Uses: --generate-code=arch=compute_70,code=sm_70
# 7 - all
# - Uses: --generate-code=arch=compute_20,code=compute_20
# - Uses: --generate-code=arch=compute_30,code=compute_30
# - Uses: --generate-code=arch=compute_35,code=compute_35
# - Uses: --generate-code=arch=compute_50,code=compute_50
# - Uses: --generate-code=arch=compute_52,code=compute_52
# - Uses: --generate-code=arch=compute_60,code=compute_60
# - Uses: --generate-code=arch=compute_61,code=compute_61
# - Uses: --generate-code=arch=compute_70,code=compute_70
# - Uses: --generate-code=arch=compute_30,code=sm_30
# - Uses: --generate-code=arch=compute_35,code=sm_35
# - Uses: --generate-code=arch=compute_50,code=sm_50
# - Uses: --generate-code=arch=compute_60,code=sm_60
# - Uses: --generate-code=arch=compute_70,code=sm_70
#
#specify the property
......@@ -173,33 +168,30 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
set(VTKM_CUDA_NATIVE_EXE_PROCESS_RAN_OUTPUT ${run_output} CACHE INTERNAL
"device type(s) for cuda[native]")
else()
set(VTKm_CUDA_Architecture "fermi")
set(VTKm_CUDA_Architecture "kepler")
endif()
endif()
endif()
#since when we are native we can fail, and fall back to "fermi" these have
#since when we are native we can fail, and fall back to "kepler" these have
#to happen after, and separately of the native check
if(VTKm_CUDA_Architecture STREQUAL "fermi")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_20,code=compute_20")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_20,code=sm_20")
elseif(VTKm_CUDA_Architecture STREQUAL "kepler")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_30,code=compute_30")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_35,code=compute_35")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_30,code=sm_30")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_35,code=sm_35")
elseif(VTKm_CUDA_Architecture STREQUAL "maxwell")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_50,code=compute_50")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_52,code=compute_52")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_50,code=sm_50")
elseif(VTKm_CUDA_Architecture STREQUAL "pascal")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_60,code=compute_60")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_61,code=compute_61")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_60,code=sm_60")
elseif(VTKm_CUDA_Architecture STREQUAL "volta")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_70,code=compute_70")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_70,code=sm_70")
elseif(VTKm_CUDA_Architecture STREQUAL "all")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_30,code=compute_30")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_35,code=compute_35")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_50,code=compute_50")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_52,code=compute_52")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_60,code=compute_60")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_61,code=compute_61")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_30,code=sm_30")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_35,code=sm_35")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_50,code=sm_50")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_60,code=sm_60")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code=arch=compute_70,code=sm_70")
endif()
endif()
......@@ -34,6 +34,7 @@
# - OpenGL::GL
# For OpenGL Will also provide the more explicit targets of:
# - OpenGL::OpenGL
# - OpenGL::GLU
# - OpenGL::GLX
# - OpenGL::EGL
function(vtkm_find_gl)
......@@ -59,18 +60,16 @@ function(vtkm_find_gl)
endforeach()
#Find GL
if(CMAKE_VERSION VERSION_LESS 3.10)
if(DO_GL_FIND AND NOT TARGET OpenGL::GL)
if(DO_GL_FIND AND NOT TARGET OpenGL::GL)
if(CMAKE_VERSION VERSION_LESS 3.10)
find_package(OpenGL ${GL_REQUIRED} ${QUIETLY} MODULE)
endif()
else()
#clunky but we need to make sure we use the upstream module if it exists
set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
if(DO_GL_FIND AND NOT TARGET OpenGL::GL)
else()
#clunky but we need to make sure we use the upstream module if it exists
set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
find_package(OpenGL ${GL_REQUIRED} ${QUIETLY} MODULE)
set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH})
endif()
set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH})
endif()
#Find GLEW
......@@ -106,11 +105,11 @@ if(VTKm_ENABLE_GL_CONTEXT)
INTERFACE OpenGL::OpenGL OpenGL::GLX GLEW::GLEW)
elseif(TARGET OpenGL::GL)
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::GL GLEW::GLEW)
INTERFACE OpenGL::GL OpenGL::GLU GLEW::GLEW)
endif()
elseif(VTKm_ENABLE_OSMESA_CONTEXT)
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::GL GLEW::GLEW)
INTERFACE OpenGL::GL OpenGL::GLU GLEW::GLEW)
elseif(VTKm_ENABLE_EGL_CONTEXT)
target_link_libraries(vtkm_rendering_gl_context
INTERFACE OpenGL::OpenGL OpenGL::EGL GLEW::GLEW)
......
......@@ -293,7 +293,7 @@ function(vtkm_library)
endif()
# Setup the SOVERSION and VERSION information for this vtkm library
set_property(TARGET ${lib_name} PROPERTY VERSION ${VTKm_VERSION})
set_property(TARGET ${lib_name} PROPERTY VERSION 1)
set_property(TARGET ${lib_name} PROPERTY SOVERSION 1)
# Support custom library suffix names, for other projects wanting to inject
......@@ -333,6 +333,7 @@ endfunction(vtkm_library)
# BACKEND <type>
# LIBRARIES <dependent_library_list>
# TEST_ARGS <argument_list>
# MPI
# <options>
# )
#
......@@ -348,24 +349,20 @@ endfunction(vtkm_library)
# [TEST_ARGS] : arguments that should be passed on the command line to the
# test executable
#
# Supported <options> are documented below. These can be specified for
# all tests or for individual tests. When specifying these for individual tests,
# simply add them after the test name in the <source_list> separated by a comma.
# e.g. `UnitTestMultiBlock,MPI`.
#
# Supported <options> are
# * MPI : the test(s) will be executed using `mpirun`.
# [MPI] : when specified, the tests should be run in parallel if
# MPI is enabled.
#
function(vtkm_unit_tests)
if (NOT VTKm_ENABLE_TESTING)
return()
endif()
set(options MPI)
set(options)
set(global_options ${options} MPI)
set(oneValueArgs BACKEND NAME)
set(multiValueArgs SOURCES LIBRARIES TEST_ARGS)
cmake_parse_arguments(VTKm_UT
"${options}" "${oneValueArgs}" "${multiValueArgs}"
"${global_options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}
)
vtkm_parse_test_options(VTKm_UT_SOURCES "${options}" ${VTKm_UT_SOURCES})
......@@ -383,10 +380,18 @@ function(vtkm_unit_tests)
string(APPEND test_prog "_${backend}")
endif()
if(VTKm_UT_MPI)
# for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls.
string(APPEND "test_prog" "_mpi")
set(extraArgs EXTRA_INCLUDE "vtkm/cont/testing/Testing.h"
FUNCTION "vtkm::cont::testing::Environment env")
else()
set(extraArgs)
endif()
#the creation of the test source list needs to occur before the labeling as
#cuda. This is so that we get the correctly named entry points generated
#
create_test_sourcelist(test_sources ${test_prog}.cxx ${VTKm_UT_SOURCES})
create_test_sourcelist(test_sources ${test_prog}.cxx ${VTKm_UT_SOURCES} ${extraArgs})
if(backend STREQUAL "CUDA")
vtkm_compile_as_cuda(cu_srcs ${VTKm_UT_SOURCES})
set(VTKm_UT_SOURCES ${cu_srcs})
......@@ -409,11 +414,20 @@ function(vtkm_unit_tests)
if(backend STREQUAL "CUDA")
set(timeout 1500)
endif()
foreach (test ${VTKm_UT_SOURCES})
get_filename_component(tname ${test} NAME_WE)
add_test(NAME ${tname}${backend}
COMMAND ${test_prog} ${tname} ${VTKm_UT_TEST_ARGS}
)
if(VTKm_UT_MPI AND VTKm_ENABLE_MPI)
add_test(NAME ${tname}${backend}
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ${MPIEXEC_PREFLAGS}
$<TARGET_FILE:${test_prog}> ${tname} ${VTKm_UT_TEST_ARGS}
${MPIEXEC_POSTFLAGS}
)
else()
add_test(NAME ${tname}${backend}
COMMAND ${test_prog} ${tname} ${VTKm_UT_TEST_ARGS}
)
endif()
set_tests_properties("${tname}${backend}" PROPERTIES TIMEOUT ${timeout})
endforeach (test)
......
......@@ -126,11 +126,14 @@ set(CMAKE_CXX_EXTENSIONS False)
# Setup default build types
include(VTKmBuildType)
# Include the vtk-m wrappers
include(VTKmWrappers)
# Create vtkm_compiler_flags library. This is an interface library that
# holds all the C++ compiler flags that are needed for consumers and
# when building VTK-m.
include(VTKmCompilerFlags)
include(VTKmWrappers)
#-----------------------------------------------------------------------------
# When building VTK-m it self we want to explicitly disable compiler extensions
......
......@@ -30,19 +30,21 @@ if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
set(gl_libs OpenGL::GL GLEW::GLEW GLUT::GLUT)
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
target_link_libraries(HelloWorld_SERIAL
PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
PRIVATE vtkm_cont ${gl_libs})
if(TARGET vtkm::tbb)
add_executable(HelloWorld_TBB HelloWorldTBB.cxx LoadShaders.h)
target_link_libraries(HelloWorld_TBB
PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
PRIVATE vtkm_cont ${gl_libs})
endif()
if(TARGET vtkm::cuda)
add_executable(HelloWorld_CUDA HelloWorld.cu LoadShaders.h)
target_link_libraries(HelloWorld_CUDA
PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
PRIVATE vtkm_cont ${gl_libs})
endif()
endif()
......@@ -32,17 +32,18 @@ if(TARGET OpenGL::GL AND
set_source_files_properties(quaternion.h PROPERTIES HEADER_FILE_ONLY TRUE)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(IsosurfaceUniformGrid_SERIAL IsosurfaceUniformGrid.cxx quaternion.h)
target_link_libraries(IsosurfaceUniformGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(IsosurfaceUniformGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
if(TARGET vtkm::cuda)
add_executable(IsosurfaceUniformGrid_CUDA IsosurfaceUniformGrid.cu quaternion.h)
target_link_libraries(IsosurfaceUniformGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(IsosurfaceUniformGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
endif()
if(TARGET vtkm::tbb)
add_executable(IsosurfaceUniformGrid_TBB IsosurfaceUniformGridTBB.cxx quaternion.h)
target_link_libraries(IsosurfaceUniformGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(IsosurfaceUniformGrid_TBB PRIVATE vtkm_cont ${gl_libs})
endif()
endif()
......@@ -20,7 +20,7 @@
##
##=============================================================================
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(Rendering CXX)
project(RenderingExample CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
......@@ -34,12 +34,12 @@ if(NOT TARGET GLUT::GLUT)
return()
endif()
add_executable(Rendering_SERIAL Rendering.cxx)
target_link_libraries(Rendering_SERIAL PRIVATE vtkm_rendering GLUT::GLUT)
add_executable(RenderingExample_SERIAL Rendering.cxx)
target_link_libraries(RenderingExample_SERIAL PRIVATE vtkm_rendering GLUT::GLUT)
if(TARGET vtkm::tbb)
add_executable(Rendering_TBB Rendering.cxx)
add_executable(RenderingExample_TBB Rendering.cxx)
target_compile_definitions(Rendering_TBB PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
target_link_libraries(Rendering_TBB PRIVATE vtkm_rendering GLUT::GLUT)
target_link_libraries(RenderingExample_TBB PRIVATE vtkm_rendering GLUT::GLUT)
endif()
......@@ -30,17 +30,19 @@ if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
add_executable(StreamLineUniformGrid_SERIAL StreamLineUniformGrid.cxx)
target_link_libraries(StreamLineUniformGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(StreamLineUniformGrid_SERIAL StreamLineUniformGrid.cxx)
target_link_libraries(StreamLineUniformGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
if(TARGET vtkm::cont)
add_executable(StreamLineUniformGrid_CUDA StreamLineUniformGrid.cu)
target_link_libraries(StreamLineUniformGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(StreamLineUniformGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
endif()
if(TARGET vtkm::tbb)
add_executable(StreamLineUniformGrid_TBB StreamLineUniformGridTBB.cxx)
target_link_libraries(StreamLineUniformGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(StreamLineUniformGrid_TBB PRIVATE vtkm_cont ${gl_libs})
endif()
endif()
......@@ -29,15 +29,18 @@ vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(TetrahedralizeExplicitGrid_SERIAL TetrahedralizeExplicitGrid.cxx)
add_executable(TriangulateExplicitGrid_SERIAL TriangulateExplicitGrid.cxx)
add_executable(TetrahedralizeUniformGrid_SERIAL TetrahedralizeUniformGrid.cxx)
add_executable(TriangulateUniformGrid_SERIAL TriangulateUniformGrid.cxx)
target_link_libraries(TetrahedralizeExplicitGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateExplicitGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeUniformGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateUniformGrid_SERIAL PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeExplicitGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateExplicitGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TetrahedralizeUniformGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateUniformGrid_SERIAL PRIVATE vtkm_cont ${gl_libs})
if(TARGET vtkm::cuda)
add_executable(TetrahedralizeExplicitGrid_CUDA TetrahedralizeExplicitGrid.cu)
......@@ -45,10 +48,10 @@ if(TARGET OpenGL::GL AND
add_executable(TetrahedralizeUniformGrid_CUDA TetrahedralizeUniformGrid.cu)
add_executable(TriangulateUniformGrid_CUDA TriangulateUniformGrid.cu)
target_link_libraries(TetrahedralizeExplicitGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateExplicitGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeUniformGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateUniformGrid_CUDA PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeExplicitGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateExplicitGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TetrahedralizeUniformGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateUniformGrid_CUDA PRIVATE vtkm_cont ${gl_libs})
endif()
if(TARGET vtkm::tbb)
......@@ -57,9 +60,9 @@ if(TARGET OpenGL::GL AND
add_executable(TetrahedralizeUniformGrid_TBB TetrahedralizeUniformGridTBB.cxx)
add_executable(TriangulateUniformGrid_TBB TriangulateUniformGridTBB.cxx)
target_link_libraries(TetrahedralizeExplicitGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateExplicitGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeUniformGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TriangulateUniformGrid_TBB PRIVATE vtkm_cont OpenGL::GL GLEW::GLEW GLUT::GLUT)
target_link_libraries(TetrahedralizeExplicitGrid_TBB PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateExplicitGrid_TBB PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TetrahedralizeUniformGrid_TBB PRIVATE vtkm_cont ${gl_libs})
target_link_libraries(TriangulateUniformGrid_TBB PRIVATE vtkm_cont ${gl_libs})
endif()
endif()
......@@ -80,3 +80,10 @@ set(unit_tests
)
vtkm_unit_tests(SOURCES ${unit_tests})
# add distributed tests i.e. test to run with MPI
# if MPI is enabled.
set(mpi_unit_tests
UnitTestFieldRangeGlobalCompute.cxx)
vtkm_unit_tests(MPI SOURCES ${mpi_unit_tests})
......@@ -20,9 +20,15 @@
#ifndef vtk_m_cont_testing_Testing_h
#define vtk_m_cont_testing_Testing_h
#include <vtkm/cont/EnvironmentTracker.h>
#include <vtkm/cont/Error.h>
#include <vtkm/testing/Testing.h>
#include <vtkm/thirdparty/diy/Configure.h>
// clang-format off
VTKM_THIRDPARTY_PRE_INCLUDE
#include VTKM_DIY(diy/mpi.hpp)
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm
{
......@@ -65,6 +71,32 @@ public:
return 0;
}
};
struct Environment
{
VTKM_CONT Environment(int* argc, char*** argv)
{
#if defined(VTKM_ENABLE_MPI)
int provided_threading;
MPI_Init_thread(argc, argv, MPI_THREAD_FUNNELED, &provided_threading);
// set the global communicator to use in VTKm.
diy::mpi::communicator comm(MPI_COMM_WORLD);
vtkm::cont::EnvironmentTracker::SetCommunicator(comm);
#else
(void) argc;
(void) argv;
#endif
}
VTKM_CONT ~Environment()
{
#if defined(VTKM_ENABLE_MPI)
MPI_Finalize();
#endif
}
};
}
}
} // namespace vtkm::cont::testing
......
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/EnvironmentTracker.h>
#include <vtkm/cont/FieldRangeGlobalCompute.h>
#include <vtkm/cont/testing/Testing.h>
#include <algorithm>
#include <numeric>
#include <random>
#include <utility>
#include <vector>
namespace
{
static unsigned int uid = 1;
#define PRINT_INFO(msg) std::cout << "[" << comm.rank() << ":" << __LINE__ << "] " msg << std::endl;
#define PRINT_INFO_0(msg) \
if (comm.rank() == 0) \
{ \
std::cout << "[" << comm.rank() << ":" << __LINE__ << "] " msg << std::endl; \
}
template <typename T>
vtkm::cont::ArrayHandle<T> CreateArray(T min, T max, vtkm::Id numVals, vtkm::TypeTraitsScalarTag)
{
std::mt19937 gen(uid++);
std::uniform_real_distribution<double> dis(static_cast<double>(min), static_cast<double>(max));
vtkm::cont::ArrayHandle<T> handle;
handle.Allocate(numVals);
std::generate(vtkm::cont::ArrayPortalToIteratorBegin(handle.GetPortalControl()),
vtkm::cont::ArrayPortalToIteratorEnd(handle.GetPortalControl()),
[&]() { return static_cast<T>(dis(gen)); });
return handle;
}
template <typename T>
vtkm::cont::ArrayHandle<T> CreateArray(const T& min,
const T& max,
vtkm::Id numVals,
vtkm::TypeTraitsVectorTag)
{
constexpr int size = T::NUM_COMPONENTS;
std::mt19937 gen(uid++);
std::uniform_real_distribution<double> dis[size];
for (int cc = 0; cc < size; ++cc)
{
dis[cc] = std::uniform_real_distribution<double>(static_cast<double>(min[cc]),
static_cast<double>(max[cc]));
}
vtkm::cont::ArrayHandle<T> handle;
handle.Allocate(numVals);
std::generate(vtkm::cont::ArrayPortalToIteratorBegin(handle.GetPortalControl()),
vtkm::cont::ArrayPortalToIteratorEnd(handle.GetPortalControl()),
[&]() {
T val;
for (int cc = 0; cc < size; ++cc)
{
val[cc] = static_cast<typename T::ComponentType>(dis[cc](gen));
}
return val;
});
return handle;
}
static constexpr vtkm::Id ARRAY_SIZE = 1025;
template <typename ValueType>
void Validate(const vtkm::cont::ArrayHandle<vtkm::Range>& ranges,
const ValueType& min,
const ValueType& max)
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
VTKM_TEST_ASSERT(ranges.GetNumberOfValues() == 1, "Wrong number of ranges");
auto portal = ranges.GetPortalConstControl();
auto range = portal.Get(0);
PRINT_INFO(<< " expecting [" << min << ", " << max << "], got [" << range.Min << ", "
<< range.Max
<< "]");
VTKM_TEST_ASSERT(range.IsNonEmpty() && range.Min >= static_cast<ValueType>(min) &&
range.Max <= static_cast<ValueType>(max),
"Got wrong range.");
}
template <typename T, int size>
void Validate(const vtkm::cont::ArrayHandle<vtkm::Range>& ranges,
const vtkm::Vec<T, size>& min,
const vtkm::Vec<T, size>& max)
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
VTKM_TEST_ASSERT(ranges.GetNumberOfValues() == size, "Wrong number of ranges");
auto portal = ranges.GetPortalConstControl();
for (int cc = 0; cc < size; ++cc)
{
auto range = portal.Get(cc);
PRINT_INFO(<< " [" << cc << "] expecting [" << min[cc] << ", " << max[cc] << "], got ["
<< range.Min
<< ", "
<< range.Max
<< "]");
VTKM_TEST_ASSERT(range.IsNonEmpty() && range.Min >= static_cast<T>(min[cc]) &&
range.Max <= static_cast<T>(max[cc]),
"Got wrong range.");
}
}
template <typename ValueType>
void DecomposeRange(ValueType& min, ValueType& max)
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
auto delta = (max - min) / static_cast<ValueType>(comm.size());
min = min + static_cast<ValueType>(comm.rank()) * delta;
max = (comm.rank() == comm.size() - 1) ? max : min + delta;
}
template <typename T, int size>
void DecomposeRange(vtkm::Vec<T, size>& min, vtkm::Vec<T, size>& max)
{
for (int cc = 0; cc < size; ++cc)
{
DecomposeRange(min[0], max[0]);
}
}
template <typename ValueType>
void TryRangeGlobalComputeDS(const ValueType& min, const ValueType& max)
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
PRINT_INFO_0("Trying type (dataset): " << vtkm::testing::TypeName<ValueType>::Name());
// distribute range among all ranks, so we can confirm reduction works.
ValueType lmin = min, lmax = max;
DecomposeRange(lmin, lmax);
PRINT_INFO("gmin=" << min << ", gmax=" << max << " lmin=" << lmin << ", lmax=" << lmax);
// let's create a dummy dataset with a bunch of fields.
vtkm::cont::DataSet dataset;
vtkm::cont::DataSetFieldAdd::AddPointField(
dataset,
"pointvar",
CreateArray(lmin, lmax, ARRAY_SIZE, typename vtkm::TypeTraits<ValueType>::DimensionalityTag()));
vtkm::cont::ArrayHandle<vtkm::Range> ranges =
vtkm::cont::FieldRangeGlobalCompute(dataset, "pointvar");
Validate(ranges, min, max);
}
template <typename ValueType>
void TryRangeGlobalComputeMB(const ValueType& min, const ValueType& max)
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
PRINT_INFO("Trying type (multiblock): " << vtkm::testing::TypeName<ValueType>::Name());
vtkm::cont::MultiBlock mb;
for (int cc = 0; cc < 5; cc++)
{
// let's create a dummy dataset with a bunch of fields.
vtkm::cont::DataSet dataset;
vtkm::cont::DataSetFieldAdd::AddPointField(
dataset,
"pointvar",
CreateArray(min, max, ARRAY_SIZE, typename vtkm::TypeTraits<ValueType>::DimensionalityTag()));
mb.AddBlock(dataset);
}
vtkm::cont::ArrayHandle<vtkm::Range> ranges = vtkm::cont::FieldRangeGlobalCompute(mb, "pointvar");
Validate(ranges, min, max);
}
static void TestFieldRangeGlobalCompute()
{
diy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
PRINT_INFO_0("Running on " << comm.size() << " ranks.");
// init random seed.
std::srand(static_cast<unsigned int>(100 + 1024 * comm.rank()));
TryRangeGlobalComputeDS<vtkm::Float64>(0, 1000);
TryRangeGlobalComputeDS<vtkm::Int32>(-1024, 1024);
TryRangeGlobalComputeDS<vtkm::Vec<vtkm::Float32, 3>>(vtkm::make_Vec(1024, 0, -1024),
vtkm::make_Vec(2048, 2048, 2048));
TryRangeGlobalComputeMB<vtkm::Float64>(0, 1000);
TryRangeGlobalComputeMB<vt