Commit c062f2e2 authored by Abhishek Yenpure's avatar Abhishek Yenpure

Merge branch 'master' of https://gitlab.kitware.com/vtk/vtk-m into code_sprint_locator_fixes

parents 0fa73352 bc137642
##============================================================================
## 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.
##============================================================================
#-----------------------------------------------------------------------------
# check if this is a sanitizer build. If so, set up the environment.
function(vtkm_check_sanitizer_build)
string (FIND "${CTEST_MEMORYCHECK_TYPE}" "Sanitizer" SANITIZER_BUILD)
if (${SANITIZER_BUILD} GREATER -1)
# This is a sanitizer build.
# Configure the sanitizer blacklist file
set (SANITIZER_BLACKLIST "${VTKm_BINARY_DIR}/sanitizer_blacklist.txt")
configure_file (
"${VTKm_SOURCE_DIR}/Utilities/DynamicAnalysis/sanitizer_blacklist.txt.in"
${SANITIZER_BLACKLIST}
@ONLY
)
# Add the compiler flags for blacklist
set (FSANITIZE_BLACKLIST "\"-fsanitize-blacklist=${SANITIZER_BLACKLIST}\"")
foreach (entity C CXX SHARED_LINKER EXE_LINKER MODULE_LINKER)
set (CMAKE_${entity}_FLAGS "${CMAKE_${entity}_FLAGS} ${FSANITIZE_BLACKLIST}")
endforeach ()
endif ()
endfunction()
......@@ -51,8 +51,9 @@ add_library(vtkm_compiler_flags INTERFACE)
# When building libraries/tests that are part of the VTK-m repository
# inherit the properties from vtkm_developer_flags and vtkm_vectorization_flags.
# The flags are intended only for VTK-m itself and are not needed by consumers.
# We will export vtkm_vectorization_flags in general so consumer can enable
# vectorization if they so desire
# We will export vtkm_developer_flags, and vtkm_vectorization_flags in general
# so consumer can either enable vectorization or use VTK-m's build flags if
# they so desire
if (VTKm_ENABLE_DEVELOPER_FLAGS)
target_link_libraries(vtkm_compiler_flags
INTERFACE $<BUILD_INTERFACE:vtkm_developer_flags>)
......@@ -92,26 +93,29 @@ add_library(vtkm_developer_flags INTERFACE)
# about failures to vectorize.
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.4)
target_compile_options(vtkm_developer_flags INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:-Wno-pass-failed>>)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wno-pass-failed>)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.99)
target_compile_options(vtkm_developer_flags INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:-Wno-pass-failed>>)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wno-pass-failed>)
endif()
if(VTKM_COMPILER_IS_MSVC)
target_compile_definitions(vtkm_developer_flags INTERFACE "_SCL_SECURE_NO_WARNINGS"
"_CRT_SECURE_NO_WARNINGS")
#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\" -Xcudafe=\"--diag_suppress=1394 --diag_suppress=766 --display_error_number\"")
#Setup MSVC warnings with CUDA and CXX
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-wd4702 -wd4505>)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-wd4702,-wd4505 -Xcudafe=--display_error_number,--diag_suppress=1394,--diag_suppress=766>)
endif()
if(MSVC_VERSION LESS 1900)
# In VS2013 the C4127 warning has a bug in the implementation and
# generates false positive warnings for lots of template code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4127")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"/wd4127\"")
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-wd4127>)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-wd4127>)
endif()
endif()
elseif(VTKM_COMPILER_IS_ICC)
......@@ -137,13 +141,9 @@ elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG)
(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.99) )
list(APPEND cxx_flags -Wno-strict-overflow)
endif()
target_compile_options(vtkm_developer_flags
INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>>
)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_developer_flags
INTERFACE $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>>
)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>)
endif()
endif()
......
......@@ -72,6 +72,16 @@ if(VTKm_ENABLE_TBB AND NOT TARGET vtkm::tbb)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION_RELEASE "${real_path}"
)
elseif(EXISTS "${TBB_LIBRARY}")
#When VTK-m is mixed with OSPray we could use the OSPray FindTBB file
#which doesn't define TBB_LIBRARY_RELEASE but instead defined only
#TBB_LIBRARY
vtkm_extract_real_library("${TBB_LIBRARY}" real_path)
set_property(TARGET vtkm::tbb APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(vtkm::tbb PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION_RELEASE "${real_path}"
)
endif()
if(EXISTS "${TBB_LIBRARY_DEBUG}")
......@@ -188,18 +198,21 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
# - Uses: --generate-code=arch=compute_60,code=sm_60
# 6 - volta
# - Uses: --generate-code=arch=compute_70,code=sm_70
# 7 - all
# 7 - turing
# - Uses: --generate-code=arch=compute_75code=sm_75
# 8 - all
# - 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
# - Uses: --generate-code=arch=compute_75,code=sm_75
# 8 - none
#
#specify the property
set(VTKm_CUDA_Architecture "native" CACHE STRING "Which GPU Architecture(s) to compile for")
set_property(CACHE VTKm_CUDA_Architecture PROPERTY STRINGS native fermi kepler maxwell pascal volta all none)
set_property(CACHE VTKm_CUDA_Architecture PROPERTY STRINGS native fermi kepler maxwell pascal volta turing all none)
#detect what the property is set too
if(VTKm_CUDA_Architecture STREQUAL "native")
......@@ -253,12 +266,15 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
set(arch_flags --generate-code=arch=compute_60,code=sm_60)
elseif(VTKm_CUDA_Architecture STREQUAL "volta")
set(arch_flags --generate-code=arch=compute_70,code=sm_70)
elseif(VTKm_CUDA_Architecture STREQUAL "turing")
set(arch_flags --generate-code=arch=compute_75,code=sm_75)
elseif(VTKm_CUDA_Architecture STREQUAL "all")
set(arch_flags --generate-code=arch=compute_30,code=sm_30
--generate-code=arch=compute_35,code=sm_35
--generate-code=arch=compute_50,code=sm_50
--generate-code=arch=compute_60,code=sm_60
--generate-code=arch=compute_70,code=sm_70)
--generate-code=arch=compute_70,code=sm_70
--generate-code=arch=compute_75,code=sm_75)
endif()
string(REPLACE ";" " " arch_flags "${arch_flags}")
......
......@@ -95,6 +95,13 @@ endfunction()
function(vtkm_add_header_build_test name dir_prefix use_cuda)
set(hfiles ${ARGN})
#only attempt to add a test build executable if we have any headers to
#test. this might not happen when everything depends on thrust.
list(LENGTH hfiles num_srcs)
if (${num_srcs} EQUAL 0)
return()
endif()
set(ext "cxx")
if(use_cuda)
set(ext "cu")
......@@ -104,10 +111,9 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda)
foreach (header ${hfiles})
get_source_file_property(cant_be_tested ${header} VTKm_CANT_BE_HEADER_TESTED)
if( NOT cant_be_tested )
get_filename_component(headername ${header} NAME_WE)
get_filename_component(headerextension ${header} EXT)
string(SUBSTRING ${headerextension} 1 -1 headerextension)
set(src ${CMAKE_CURRENT_BINARY_DIR}/TB_${headername}_${headerextension}.${ext})
string(REPLACE "/" "_" headername "${header}")
string(REPLACE "." "_" headername "${headername}")
set(src ${CMAKE_CURRENT_BINARY_DIR}/TB_${headername}.${ext})
#By using file generate we will not trigger CMake execution when
#a header gets touched
......@@ -118,9 +124,10 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda)
//This is used by headers that include thrust to properly define a proper
//device backend / system
#define VTKM_TEST_HEADER_BUILD
#include <${dir_prefix}/${headername}.${headerextension}>
#include <${dir_prefix}/${header}>
int ${headername}_${headerextension}_testbuild_symbol;"
)
list(APPEND srcs ${src})
endif()
endforeach()
......@@ -129,13 +136,6 @@ int ${headername}_${headerextension}_testbuild_symbol;"
PROPERTIES HEADER_FILE_ONLY TRUE
)
#only attempt to add a test build executable if we have any headers to
#test. this might not happen when everything depends on thrust.
list(LENGTH srcs num_srcs)
if (${num_srcs} EQUAL 0)
return()
endif()
if(TARGET TestBuild_${name})
#If the target already exists just add more sources to it
target_sources(TestBuild_${name} PRIVATE ${srcs})
......@@ -206,6 +206,7 @@ function(vtkm_generate_export_header lib_name)
endfunction(vtkm_generate_export_header)
#-----------------------------------------------------------------------------
function(vtkm_install_headers dir_prefix)
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
set(hfiles ${ARGN})
......@@ -345,6 +346,7 @@ endfunction(vtkm_library)
# LIBRARIES <dependent_library_list>
# TEST_ARGS <argument_list>
# MPI
# ALL_BACKENDS
# <options>
# )
#
......@@ -362,6 +364,8 @@ endfunction(vtkm_library)
#
# [MPI] : when specified, the tests should be run in parallel if
# MPI is enabled.
# [ALL_BACKENDS] : when specified, the tests would test against all enabled
# backends. BACKEND argument would be ignored.
#
function(vtkm_unit_tests)
if (NOT VTKm_ENABLE_TESTING)
......@@ -369,7 +373,7 @@ function(vtkm_unit_tests)
endif()
set(options)
set(global_options ${options} MPI)
set(global_options ${options} MPI ALL_BACKENDS)
set(oneValueArgs BACKEND NAME)
set(multiValueArgs SOURCES LIBRARIES TEST_ARGS)
cmake_parse_arguments(VTKm_UT
......@@ -378,17 +382,33 @@ function(vtkm_unit_tests)
)
vtkm_parse_test_options(VTKm_UT_SOURCES "${options}" ${VTKm_UT_SOURCES})
set(test_prog )
set(test_prog)
set(backend ${VTKm_UT_BACKEND})
set(enable_all_backends ${VTKm_UT_ALL_BACKENDS})
set(all_backends SERIAL)
if (VTKm_ENABLE_CUDA)
list(APPEND all_backends CUDA)
endif()
if (VTKm_ENABLE_TBB)
list(APPEND all_backends TBB)
endif()
if (VTKm_ENABLE_OPENMP)
list(APPEND all_backends OPENMP)
endif()
if(VTKm_UT_NAME)
set(test_prog "${VTKm_UT_NAME}")
else()
vtkm_get_kit_name(kit)
set(test_prog "UnitTests_${kit}")
endif()
if(backend)
set(test_prog "${test_prog}_${backend}")
set(all_backends ${backend})
elseif(NOT enable_all_backends)
set (all_backends "NO_BACKEND")
endif()
if(VTKm_UT_MPI)
......@@ -403,7 +423,8 @@ function(vtkm_unit_tests)
#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} ${extraArgs})
if(backend STREQUAL "CUDA")
#if all backends are enabled, we can use cuda compiler to handle all possible backends.
if(backend STREQUAL "CUDA" OR (enable_all_backends AND VTKm_ENABLE_CUDA))
vtkm_compile_as_cuda(cu_srcs ${VTKm_UT_SOURCES})
set(VTKm_UT_SOURCES ${cu_srcs})
endif()
......@@ -414,43 +435,50 @@ function(vtkm_unit_tests)
set_property(TARGET ${test_prog} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH})
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_UT_LIBRARIES})
if(backend)
target_compile_definitions(${test_prog} PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_${backend}")
endif()
#determine the timeout for all the tests based on the backend. CUDA tests
#generally require more time because of kernel generation.
set(timeout 180)
set(run_serial False)
if(backend STREQUAL "CUDA")
set(timeout 1500)
elseif(backend STREQUAL "OPENMP")
#We need to have all OpenMP tests run serially as they
#will uses all the system cores, and we will cause a N*N thread
#explosion which causes the tests to run slower than when run
#serially
set(run_serial True)
endif()
foreach(current_backend ${all_backends})
set (device_command_line_argument --device=${current_backend})
if (current_backend STREQUAL "NO_BACKEND")
set (current_backend "")
set(device_command_line_argument "")
endif()
foreach (test ${VTKm_UT_SOURCES})
get_filename_component(tname ${test} NAME_WE)
if(VTKm_UT_MPI AND VTKm_ENABLE_MPI)
add_test(NAME ${tname}${current_backend}
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ${MPIEXEC_PREFLAGS}
$<TARGET_FILE:${test_prog}> ${tname} ${device_command_line_argument} ${VTKm_UT_TEST_ARGS}
${MPIEXEC_POSTFLAGS}
)
else()
add_test(NAME ${tname}${current_backend}
COMMAND ${test_prog} ${tname} ${device_command_line_argument} ${VTKm_UT_TEST_ARGS}
)
endif()
#determine the timeout for all the tests based on the backend. CUDA tests
#generally require more time because of kernel generation.
if (current_backend STREQUAL "CUDA")
set(timeout 1500)
else()
set(timeout 180)
endif()
if(current_backend STREQUAL "OPENMP")
#We need to have all OpenMP tests run serially as they
#will uses all the system cores, and we will cause a N*N thread
#explosion which causes the tests to run slower than when run
#serially
set(run_serial True)
else()
set(run_serial False)
endif()
foreach (test ${VTKm_UT_SOURCES})
get_filename_component(tname ${test} NAME_WE)
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}
RUN_SERIAL ${run_serial}
)
endforeach (test)
set_tests_properties("${tname}${current_backend}" PROPERTIES
TIMEOUT ${timeout}
RUN_SERIAL ${run_serial}
)
endforeach (test)
endforeach(current_backend)
endfunction(vtkm_unit_tests)
......
......@@ -97,6 +97,7 @@ vtkm_option(VTKm_ENABLE_OPENMP "Enable OpenMP support" OFF)
vtkm_option(VTKm_ENABLE_RENDERING "Enable rendering library" ON)
vtkm_option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON)
vtkm_option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF)
vtkm_option(VTKm_ENABLE_LOGGING "Enable VTKm Logging" OFF)
vtkm_option(VTKm_ENABLE_MPI "Enable MPI support" OFF)
vtkm_option(VTKm_ENABLE_DOCUMENTATION "Build Doxygen documentation" OFF)
......@@ -199,6 +200,11 @@ if (VTKm_ENABLE_TESTING)
# Find Pyexpander in case somebody wants to update the auto generated
# faux variadic template code
find_package(Pyexpander QUIET)
#-----------------------------------------------------------------------------
# Setup compiler flags for dynamic analysis if needed
include(VTKmCompilerDynamicAnalysisFlags)
vtkm_check_sanitizer_build()
endif (VTKm_ENABLE_TESTING)
#-----------------------------------------------------------------------------
......@@ -288,7 +294,7 @@ if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
# Create and install exports for external projects
export(EXPORT ${VTKm_EXPORT_NAME}
FILE ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmTargets.cmake
FILE ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmTargets.cmake
)
install(EXPORT ${VTKm_EXPORT_NAME}
DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
......
......@@ -71,6 +71,7 @@ Optional dependencies are:
+ CUDA Device Adapter
+ [Cuda Toolkit 7.5+](https://developer.nvidia.com/cuda-toolkit)
+ Note CUDA >= 10.0 is required on Windows
+ TBB Device Adapter
+ [TBB](https://www.threadingbuildingblocks.org/)
+ OpenMP Device Adapter
......@@ -95,19 +96,20 @@ Optional dependencies are:
+ EGL Driver
VTK-m has been tested on the following configurations:
+ On Linux
+ GCC 4.8.5, 5.4.0, 6.4.0, Clang 3.8.0
+ CMake 3.9.2, 3.9.3, 3.10.3
+ CUDA 8.0.61, 9.1.85
+ On Linux
+ GCC 4.8.5, 5.4.0, 6.4.0, 7.3.0 Clang 3.8.0, Intel 17.0.4
+ CMake 3.9.3, 3.10.3
+ CUDA 8.0.61, 9.1.85, 10.0.130
+ TBB 4.4 U2, 2017 U7
+ On Windows
+ Visual Studio 2015, 2017
+ CMake 3.3, 3.11.1