Merge branch 'master' into external-face-more-generic

Update exception methods to new names.
This commit is contained in:
Kenneth Moreland 2017-02-08 16:55:58 -07:00
commit dcbbb72784
112 changed files with 1494 additions and 679 deletions

2
.gitattributes vendored Normal file

@ -0,0 +1,2 @@
data/* filter=lfs diff=lfs merge=lfs -text
/**/data/* filter=lfs diff=lfs merge=lfs -text

@ -21,7 +21,7 @@
# Once done this will define
#
# EGL_FOUND - true if EGL has been found
# EGL_INCLUDE_DIR - where the EGL/egl.h and KHR/khrplatform.h can be found
# EGL_INCLUDE_DIRS - where the EGL/egl.h and KHR/khrplatform.h can be found
# EGL_LIBRARY - link this to use libEGL.so.1
# EGL_opengl_LIBRARY - link with these two libraries instead of the gl library
# EGL_gldispatch_LIBRARY for full OpenGL support through EGL
@ -102,10 +102,15 @@ if(NOT EGL_gldispatch_LIBRARY)
endif()
endif()
set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY} ${EGL_gldispatch_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL DEFAULT_MSG
EGL_LIBRARY EGL_opengl_LIBRARY EGL_gldispatch_LIBRARY EGL_INCLUDE_DIR)
find_package_handle_standard_args(EGL
FOUND_VAR EGL_FOUND
REQUIRED_VARS EGL_LIBRARY EGL_opengl_LIBRARY EGL_gldispatch_LIBRARY EGL_INCLUDE_DIR)
if(EGL_FOUND)
set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY} ${EGL_gldispatch_LIBRARY})
set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
endif()
mark_as_advanced(EGL_DIR EGL_INCLUDE_DIR EGL_LIBRARY EGL_opengl_LIBRARY EGL_gldispatch_LIBRARY)

@ -64,15 +64,17 @@
#
# * Kitware, Inc.
find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW
FOUND_VAR GLEW_FOUND
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
if(GLEW_FOUND)
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)

@ -23,8 +23,8 @@
# Once done this will define
#
# GLFW_FOUND
# GLFW_INCLUDE_DIR
# GLFW_LIBRARY
# GLFW_INCLUDE_DIRS
# GLFW_LIBRARIES
#
include(FindPackageHandleStandardArgs)
@ -94,9 +94,14 @@ if (${CMAKE_HOST_UNIX})
DOC "The GLFW library")
endif ()
find_package_handle_standard_args(GLFW DEFAULT_MSG
GLFW_INCLUDE_DIR
GLFW_LIBRARY
find_package_handle_standard_args(GLFW
FOUND_VAR GLFW_FOUND
REQUIRED_VARS GLFW_INCLUDE_DIR GLFW_LIBRARY
)
if(GLFW_FOUND)
set(GLFW_LIBRARIES ${GLFW_LIBRARY})
set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR})
endif()
mark_as_advanced( GLFW_INCLUDE_DIR GLFW_LIBRARY )

@ -69,9 +69,13 @@ endif()
# Check for required components
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( Thrust
FOUND_VAR Thrust_FOUND
REQUIRED_VARS THRUST_INCLUDE_DIR
VERSION_VAR THRUST_VERSION
)
set(THRUST_INCLUDE_DIRS ${THRUST_INCLUDE_DIR})
if(Thrust_FOUND)
set(THRUST_INCLUDE_DIRS ${THRUST_INCLUDE_DIR})
endif()
mark_as_advanced(THRUST_INCLUDE_DIR)

@ -71,7 +71,7 @@ macro(vtkm_finish_configure_component component)
if(NOT VTKm_${component}_FOUND)
cmake_parse_arguments(VTKm_FCC
""
"IS_BACKEND"
""
"DEPENDENT_VARIABLES;ADD_INCLUDES;ADD_LIBRARIES"
${ARGN}
@ -89,6 +89,10 @@ macro(vtkm_finish_configure_component component)
if (VTKm_${component}_FOUND)
set(VTKm_INCLUDE_DIRS ${VTKm_INCLUDE_DIRS} ${VTKm_FCC_ADD_INCLUDES})
set(VTKm_LIBRARIES ${VTKm_LIBRARIES} ${VTKm_FCC_ADD_LIBRARIES})
if(${VTKm_FCC_IS_BACKEND})
set(VTKm_BACKEND_INCLUDE_DIRS ${VTKm_BACKEND_INCLUDE_DIRS} ${VTKm_FCC_ADD_INCLUDES})
set(VTKm_BACKEND_LIBRARIES ${VTKm_BACKEND_LIBRARIES} ${VTKm_FCC_ADD_LIBRARIES})
endif()
endif()
endif()
endmacro()
@ -118,6 +122,7 @@ macro(vtkm_configure_component_Serial)
vtkm_configure_component_Base()
vtkm_finish_configure_component(Serial
IS_BACKEND
DEPENDENT_VARIABLES VTKm_Base_FOUND
)
endmacro(vtkm_configure_component_Serial)
@ -151,8 +156,10 @@ macro(vtkm_configure_component_OpenGL)
find_package(GLEW ${VTKm_FIND_PACKAGE_QUIETLY})
list(APPEND vtkm_opengl_dependent_vars GLEW_FOUND)
list(APPEND vtkm_opengl_includes ${GLEW_INCLUDE_DIRS})
list(APPEND vtkm_opengl_libraries ${GLEW_LIBRARIES})
if(GLEW_FOUND)
list(APPEND vtkm_opengl_includes ${GLEW_INCLUDE_DIRS})
list(APPEND vtkm_opengl_libraries ${GLEW_LIBRARIES})
endif()
#on unix/linux Glew uses pthreads, so we need to find that, and link to it
#explicitly or else in release mode we get sigsegv on launch
if(UNIX)
@ -166,6 +173,10 @@ macro(vtkm_configure_component_OpenGL)
ADD_INCLUDES ${vtkm_opengl_includes}
ADD_LIBRARIES ${vtkm_opengl_libraries}
)
set(VTKm_OPENGL_INCLUDE_DIRS ${vtkm_opengl_includes})
set(VTKm_OPENGL_LIBRARIES ${vtkm_opengl_libraries})
endmacro(vtkm_configure_component_OpenGL)
macro(vtkm_configure_component_OSMesa)
@ -189,8 +200,8 @@ macro(vtkm_configure_component_EGL)
vtkm_finish_configure_component(EGL
DEPENDENT_VARIABLES VTKm_OpenGL_FOUND EGL_FOUND
ADD_INCLUDES ${EGL_INCLUDE_DIR}
ADD_LIBRARIES ${EGL_LIBRARY}
ADD_INCLUDES ${EGL_INCLUDE_DIRS}
ADD_LIBRARIES ${EGL_LIBRARIES}
)
endmacro(vtkm_configure_component_EGL)
@ -201,8 +212,8 @@ macro(vtkm_configure_component_GLFW)
vtkm_finish_configure_component(GLFW
DEPENDENT_VARIABLES VTKm_OpenGL_FOUND GLFW_FOUND
ADD_INCLUDES ${GLFW_INCLUDE_DIR}
ADD_LIBRARIES ${GLFW_LIBRARY}
ADD_INCLUDES ${GLFW_INCLUDE_DIRS}
ADD_LIBRARIES ${GLFW_LIBRARIES}
)
endmacro(vtkm_configure_component_GLFW)
@ -247,6 +258,7 @@ macro(vtkm_configure_component_TBB)
endif()
vtkm_finish_configure_component(TBB
IS_BACKEND
DEPENDENT_VARIABLES VTKm_ENABLE_TBB VTKm_Base_FOUND TBB_FOUND
ADD_INCLUDES ${TBB_INCLUDE_DIRS}
ADD_LIBRARIES ${TBB_LIBRARIES}
@ -258,6 +270,10 @@ macro(vtkm_configure_component_CUDA)
vtkm_configure_component_Base()
find_package(CUDA ${VTKm_FIND_PACKAGE_QUIETLY})
#Make cuda link privately to cuda libraries
set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
mark_as_advanced(
CUDA_BUILD_CUBIN
CUDA_BUILD_EMULATION
@ -272,6 +288,7 @@ macro(vtkm_configure_component_CUDA)
endif()
vtkm_finish_configure_component(CUDA
IS_BACKEND
DEPENDENT_VARIABLES
VTKm_ENABLE_CUDA
VTKm_Base_FOUND

@ -109,16 +109,21 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda)
# and we want system includes so we have to hijack cuda
# to do it
foreach(dir ${VTKm_INCLUDE_DIRS})
#this internal variable has changed names depending on the CMake ver
list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER -isystem ${dir})
list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER -isystem ${dir})
endforeach()
cuda_include_directories(${VTKm_SOURCE_DIR}
${VTKm_BINARY_DIR}/include
)
cuda_add_library(TestBuild_${name} STATIC ${cxxfiles} ${hfiles})
target_include_directories(TestBuild_${name} PRIVATE ${VTKm_INCLUDE_DIRS})
elseif (${cxxfiles_len} GREATER 0)
add_library(TestBuild_${name} STATIC ${cxxfiles} ${hfiles})
target_include_directories(TestBuild_${name} PRIVATE ${VTKm_INCLUDE_DIRS})
target_include_directories(TestBuild_${name} PRIVATE vtkm ${VTKm_INCLUDE_DIRS})
endif ()
target_link_libraries(TestBuild_${name} ${VTKm_LIBRARIES})
target_link_libraries(TestBuild_${name} PRIVATE vtkm_cont ${VTKm_LIBRARIES})
set_source_files_properties(${hfiles}
PROPERTIES HEADER_FILE_ONLY TRUE
)
@ -263,7 +268,10 @@ function(vtkm_unit_tests)
vtkm_setup_nvcc_flags( old_nvcc_flags old_cxx_flags )
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_include_directories(${VTKm_SOURCE_DIR}
${VTKm_BINARY_DIR}/include
${VTKm_INCLUDE_DIRS}
)
cuda_add_executable(${test_prog} ${TestSources})
@ -278,7 +286,7 @@ function(vtkm_unit_tests)
#for any other targets
target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(${test_prog} ${VTKm_LIBRARIES})
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_LIBRARIES})
target_compile_options(${test_prog} PRIVATE ${VTKm_COMPILE_OPTIONS})
@ -395,7 +403,10 @@ function(vtkm_worklet_unit_tests device_adapter)
vtkm_setup_nvcc_flags( old_nvcc_flags old_cxx_flags )
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_include_directories(${VTKm_SOURCE_DIR}
${VTKm_BINARY_DIR}/include
${VTKm_INCLUDE_DIRS}
)
cuda_add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs})
@ -405,7 +416,7 @@ function(vtkm_worklet_unit_tests device_adapter)
add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs})
endif()
target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(${test_prog} ${VTKm_LIBRARIES})
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_LIBRARIES})
#add the specific compile options for this executable
target_compile_options(${test_prog} PRIVATE ${VTKm_COMPILE_OPTIONS})
@ -522,7 +533,11 @@ function(vtkm_benchmarks device_adapter)
if(is_cuda)
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_include_directories(${VTKm_SOURCE_DIR}
${VTKm_BINARY_DIR}/include
${VTKm_BACKEND_INCLUDE_DIRS}
)
cuda_add_executable(${benchmark_prog} ${file} ${benchmark_headers})
else()
@ -532,8 +547,8 @@ function(vtkm_benchmarks device_adapter)
set_source_files_properties(${benchmark_headers}
PROPERTIES HEADER_FILE_ONLY TRUE)
target_include_directories(${benchmark_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(${benchmark_prog} ${VTKm_LIBRARIES})
target_include_directories(${benchmark_prog} PRIVATE ${VTKm_BACKEND_INCLUDE_DIRS})
target_link_libraries(${benchmark_prog} PRIVATE vtkm_cont ${VTKm_BACKEND_LIBRARIES})
if(MSVC)
vtkm_setup_msvc_properties(${benchmark_prog})
@ -610,7 +625,10 @@ function(vtkm_library)
vtkm_wrap_sources_for_cuda(cuda_sources ${VTKm_LIB_WRAP_FOR_CUDA})
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_include_directories(${VTKm_SOURCE_DIR}
${VTKm_BINARY_DIR}/include
${VTKm_BACKEND_INCLUDE_DIRS}
)
if(BUILD_SHARED_LIBS AND NOT WIN32)
set(compile_options -Xcompiler=${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden)
@ -625,18 +643,8 @@ function(vtkm_library)
add_library(${lib_name} ${VTKm_LIB_SOURCES})
endif()
#do it as a property value so we don't pollute the include_directories
#for any other targets
set_property(TARGET ${lib_name} APPEND PROPERTY
INCLUDE_DIRECTORIES ${VTKm_INCLUDE_DIRS} )
set(lib_subset)
foreach(lib ${VTKm_LIBRARIES})
if(NOT lib STREQUAL lib_name)
list(APPEND lib_subset ${lib})
endif()
endforeach()
target_link_libraries(${lib_name} ${lib_subset})
#need to link to the vtkm target as makes C++11 become enabled
target_link_libraries(${lib_name} PUBLIC vtkm)
set(cxx_args ${VTKm_COMPILE_OPTIONS})
separate_arguments(cxx_args)

@ -50,11 +50,6 @@ determine_version(${VTKm_SOURCE_DIR} ${GIT_EXECUTABLE} "VTKm")
# include some vtkm-specific cmake code.
include(VTKmMacros)
set(VTKm_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
)
# Create an "interface" target library. This is not a real library but rather
# holds CMake configuration that is required for CXX targets that use VTK-m
# headers. In particular, it makes sure the appropriate C++11 version is being
@ -64,6 +59,11 @@ set(VTKm_INCLUDE_DIRS
# configuration.
add_library(vtkm INTERFACE)
target_compile_features(vtkm INTERFACE cxx_auto_type)
target_include_directories(vtkm INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS vtkm EXPORT ${VTKm_EXPORT_NAME})
# Load the base VTK-m configuration, which is required for some of the later

3
data/tornado.vec Normal file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dca8105bf888e67a9fe476a563d69ac708925aec519814fb520c6057e5ca0a1f
size 1327116

@ -26,7 +26,7 @@ find_package(VTKm REQUIRED QUIET
add_executable(Clipping_SERIAL Clipping.cxx)
target_include_directories(Clipping_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(Clipping_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
target_compile_definitions(Clipping_SERIAL PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL")
@ -45,7 +45,7 @@ if(VTKm_CUDA_FOUND)
cuda_add_executable(Clipping_CUDA ${cudaSource})
target_include_directories(Clipping_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_CUDA ${VTKm_LIBRARIES})
target_link_libraries(Clipping_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
@ -56,7 +56,7 @@ endif()
if(VTKm_TBB_FOUND)
add_executable(Clipping_TBB Clipping.cxx)
target_include_directories(Clipping_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Clipping_TBB ${VTKm_LIBRARIES})
target_link_libraries(Clipping_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Clipping_TBB PRIVATE PRIVATE ${VTKm_COMPILE_OPTIONS})
target_compile_definitions(Clipping_TBB PRIVATE
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")

@ -27,12 +27,12 @@ find_package(VTKm REQUIRED QUIET
add_executable(ContourTreeMesh2D_SERIAL ContourTreeMesh2D.cxx)
target_include_directories(ContourTreeMesh2D_SERIAL PRIVATE ${GLUT_INCLUDE_DIR} ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh2D_SERIAL ${GLUT_LIBRARIES} ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh2D_SERIAL ${GLUT_LIBRARIES} PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh2D_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(ContourTreeMesh3D_SERIAL ContourTreeMesh3D.cxx)
target_include_directories(ContourTreeMesh3D_SERIAL PRIVATE ${GLUT_INCLUDE_DIR} ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh3D_SERIAL ${GLUT_LIBRARIES} ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh3D_SERIAL ${GLUT_LIBRARIES} PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
@ -48,14 +48,14 @@ if(VTKm_CUDA_FOUND)
configure_file(ContourTreeMesh2D.cxx ${cudaSource} COPYONLY)
cuda_add_executable(ContourTreeMesh2D_CUDA ${cudaSource})
target_include_directories(ContourTreeMesh2D_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh2D_CUDA ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh2D_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh2D_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
set (cudaSource "${CMAKE_CURRENT_BINARY_DIR}/ContourTreeMesh3D.cu")
configure_file(ContourTreeMesh3D.cxx ${cudaSource} COPYONLY)
cuda_add_executable(ContourTreeMesh3D_CUDA ${cudaSource})
target_include_directories(ContourTreeMesh3D_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh3D_CUDA ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh3D_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
@ -65,11 +65,11 @@ endif()
if(VTKm_TBB_FOUND)
add_executable(ContourTreeMesh2D_TBB ContourTreeMesh2D.cxx)
target_include_directories(ContourTreeMesh2D_TBB PRIVATE ${GLUT_INCLUDE_DIR} ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh2D_TBB ${GLUT_LIBRARIES} ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh2D_TBB ${GLUT_LIBRARIES} PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh2D_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(ContourTreeMesh3D_TBB ContourTreeMesh3D.cxx)
target_include_directories(ContourTreeMesh3D_TBB PRIVATE ${GLUT_INCLUDE_DIR} ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh3D_TBB ${GLUT_LIBRARIES} ${VTKm_LIBRARIES})
target_link_libraries(ContourTreeMesh3D_TBB ${GLUT_LIBRARIES} PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -38,7 +38,7 @@ if(VTKm_OSMesa_FOUND AND VTKm_Rendering_FOUND)
#need to setup the default device adapter.
target_include_directories(Demo PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Demo ${VTKm_LIBRARIES})
target_link_libraries(Demo PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Demo PRIVATE ${VTKm_COMPILE_OPTIONS})
#when we are using TBB pass in the default device adapter as

@ -23,5 +23,5 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(DynamicDispatcherExample main.cxx)
target_include_directories(DynamicDispatcherExample PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(DynamicDispatcherExample ${VTKm_LIBRARIES})
target_link_libraries(DynamicDispatcherExample PRIVATE ${VTKm_LIBRARIES})
target_compile_options(DynamicDispatcherExample PRIVATE ${VTKm_COMPILE_OPTIONS})

@ -30,7 +30,7 @@ if(VTKm_Interop_FOUND AND VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
set_source_files_properties(LoadShaders.h PROPERTIES HEADER_FILE_ONLY TRUE)
target_include_directories(HelloWorld_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(HelloWorld_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
@ -39,14 +39,14 @@ if(VTKm_Interop_FOUND AND VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
vtkm_disable_troublesome_thrust_warnings()
cuda_add_executable(HelloWorld_CUDA HelloWorld.cu LoadShaders.h)
target_include_directories(HelloWorld_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_CUDA ${VTKm_LIBRARIES})
target_link_libraries(HelloWorld_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()
if(VTKm_TBB_FOUND)
add_executable(HelloWorld_TBB HelloWorldTBB.cxx LoadShaders.h)
target_include_directories(HelloWorld_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(HelloWorld_TBB ${VTKm_LIBRARIES})
target_link_libraries(HelloWorld_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(HelloWorld_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -29,7 +29,7 @@ if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
add_executable(IsosurfaceUniformGrid_SERIAL IsosurfaceUniformGrid.cxx quaternion.h)
set_source_files_properties(quaternion.h PROPERTIES HEADER_FILE_ONLY TRUE)
target_include_directories(IsosurfaceUniformGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(IsosurfaceUniformGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(IsosurfaceUniformGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(IsosurfaceUniformGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
@ -37,14 +37,14 @@ if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(IsosurfaceUniformGrid_CUDA IsosurfaceUniformGrid.cu quaternion.h)
target_link_libraries(IsosurfaceUniformGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(IsosurfaceUniformGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(IsosurfaceUniformGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()
if(VTKm_ENABLE_TBB)
add_executable(IsosurfaceUniformGrid_TBB IsosurfaceUniformGridTBB.cxx quaternion.h)
target_include_directories(IsosurfaceUniformGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(IsosurfaceUniformGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(IsosurfaceUniformGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(IsosurfaceUniformGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -26,13 +26,21 @@ find_package(VTKm REQUIRED QUIET
)
if(VTKm_CUDA_FOUND)
set(old_nvcc_flags ${CUDA_NVCC_FLAGS})
set(old_cxx_flags ${CMAKE_CXX_FLAGS})
vtkm_setup_nvcc_flags( old_nvcc_flags old_cxx_flags)
vtkm_disable_troublesome_thrust_warnings()
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(MultiBackend MultiBackend.cu)
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
set(CMAKE_CXX_FLAGS ${old_cxx_flags})
else()
add_executable(MultiBackend MultiBackend.cxx)
endif()
target_include_directories(MultiBackend PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(MultiBackend ${VTKm_LIBRARIES})
target_link_libraries(MultiBackend PRIVATE ${VTKm_LIBRARIES})
target_compile_options(MultiBackend PRIVATE ${VTKm_COMPILE_OPTIONS})

@ -28,6 +28,6 @@ find_package(VTKm REQUIRED QUIET
if(VTKm_OpenGL_FOUND AND VTKm_Rendering_FOUND AND VTKm_GLUT_FOUND)
add_executable(Rendering_SERIAL Rendering.cxx)
target_include_directories(Rendering_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(Rendering_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(Rendering_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(Rendering_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -28,7 +28,7 @@ find_package(VTKm REQUIRED QUIET
if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
add_executable(StreamLineUniformGrid_SERIAL StreamLineUniformGrid.cxx)
target_include_directories(StreamLineUniformGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(StreamLineUniformGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(StreamLineUniformGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(StreamLineUniformGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
@ -36,14 +36,14 @@ if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(StreamLineUniformGrid_CUDA StreamLineUniformGrid.cu)
target_include_directories(StreamLineUniformGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(StreamLineUniformGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(StreamLineUniformGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(StreamLineUniformGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()
if(VTKm_TBB_FOUND)
add_executable(StreamLineUniformGrid_TBB StreamLineUniformGridTBB.cxx)
target_include_directories(StreamLineUniformGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(StreamLineUniformGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(StreamLineUniformGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(StreamLineUniformGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -29,22 +29,22 @@ find_package(VTKm REQUIRED QUIET
if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
add_executable(TetrahedralizeExplicitGrid_SERIAL TetrahedralizeExplicitGrid.cxx)
target_include_directories(TetrahedralizeExplicitGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeExplicitGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeExplicitGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeExplicitGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TriangulateExplicitGrid_SERIAL TriangulateExplicitGrid.cxx)
target_include_directories(TriangulateExplicitGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateExplicitGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(TriangulateExplicitGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateExplicitGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TetrahedralizeUniformGrid_SERIAL TetrahedralizeUniformGrid.cxx)
target_include_directories(TetrahedralizeUniformGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeUniformGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeUniformGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeUniformGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TriangulateUniformGrid_SERIAL TriangulateUniformGrid.cxx)
target_include_directories(TriangulateUniformGrid_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateUniformGrid_SERIAL ${VTKm_LIBRARIES})
target_link_libraries(TriangulateUniformGrid_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateUniformGrid_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
if(VTKm_CUDA_FOUND)
@ -53,44 +53,44 @@ if(VTKm_OpenGL_FOUND AND VTKm_GLUT_FOUND)
cuda_add_executable(TetrahedralizeExplicitGrid_CUDA TetrahedralizeExplicitGrid.cu)
target_include_directories(TetrahedralizeExplicitGrid_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeExplicitGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeExplicitGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeExplicitGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
cuda_add_executable(TriangulateExplicitGrid_CUDA TriangulateExplicitGrid.cu)
target_include_directories(TriangulateExplicitGrid_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateExplicitGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(TriangulateExplicitGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateExplicitGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
cuda_add_executable(TetrahedralizeUniformGrid_CUDA TetrahedralizeUniformGrid.cu)
target_include_directories(TetrahedralizeUniformGrid_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeUniformGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeUniformGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeUniformGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
cuda_add_executable(TriangulateUniformGrid_CUDA TriangulateUniformGrid.cu)
target_include_directories(TriangulateUniformGrid_CUDA PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateUniformGrid_CUDA ${VTKm_LIBRARIES})
target_link_libraries(TriangulateUniformGrid_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateUniformGrid_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()
if(VTKm_ENABLE_TBB)
add_executable(TetrahedralizeExplicitGrid_TBB TetrahedralizeExplicitGridTBB.cxx)
target_include_directories(TetrahedralizeExplicitGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeExplicitGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeExplicitGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeExplicitGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TriangulateExplicitGrid_TBB TriangulateExplicitGridTBB.cxx)
target_include_directories(TriangulateExplicitGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateExplicitGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(TriangulateExplicitGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateExplicitGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TetrahedralizeUniformGrid_TBB TetrahedralizeUniformGridTBB.cxx)
target_include_directories(TetrahedralizeUniformGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TetrahedralizeUniformGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(TetrahedralizeUniformGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TetrahedralizeUniformGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(TriangulateUniformGrid_TBB TriangulateUniformGridTBB.cxx)
target_include_directories(TriangulateUniformGrid_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(TriangulateUniformGrid_TBB ${VTKm_LIBRARIES})
target_link_libraries(TriangulateUniformGrid_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(TriangulateUniformGrid_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -26,8 +26,8 @@
#include <vtkm/Types.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorControlInternal.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/ErrorInternal.h>
#include <vtkm/cont/Storage.h>
#include <vtkm/cont/StorageBasic.h>
@ -338,8 +338,8 @@ public:
///
/// The allocation may be done on an already existing array, but can wipe out
/// any data already in the array. This method can throw
/// ErrorControlBadAllocation if the array cannot be allocated or
/// ErrorControlBadValue if the allocation is not feasible (for example, the
/// ErrorBadAllocation if the array cannot be allocated or
/// ErrorBadValue if the allocation is not feasible (for example, the
/// array storage is read-only).
///
VTKM_CONT

@ -32,7 +32,7 @@ ArrayHandle<T,S>::GetStorage()
}
else
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
@ -48,7 +48,7 @@ ArrayHandle<T,S>::GetStorage() const
}
else
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
@ -68,7 +68,7 @@ ArrayHandle<T,S>::GetPortalControl()
}
else
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
@ -84,7 +84,7 @@ ArrayHandle<T,S>::GetPortalConstControl() const
}
else
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
@ -121,7 +121,7 @@ void ArrayHandle<T,S>::CopyInto(IteratorType dest, DeviceAdapterTag) const
if (!this->Internals->ControlArrayValid &&
!this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandle has no data to copy into Iterator.");
}
@ -170,7 +170,7 @@ void ArrayHandle<T,S>::Shrink(vtkm::Id numberOfValues)
}
else // numberOfValues > originalNumberOfValues
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandle::Shrink cannot be used to grow array.");
}
@ -187,7 +187,7 @@ ArrayHandle<T,S>::PrepareForInput(DeviceAdapterTag) const
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandle has no data when PrepareForInput called.");
}
@ -242,7 +242,7 @@ ArrayHandle<T,S>::PrepareForInPlace(DeviceAdapterTag)
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandle has no data when PrepareForInPlace called.");
}

@ -23,7 +23,7 @@
#include <vtkm/Assert.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
namespace vtkm {
namespace exec {
@ -229,13 +229,13 @@ public:
VTKM_CONT
void Allocate(vtkm::Id /*numberOfValues*/)
{
throw vtkm::cont::ErrorControlBadAllocation("Does not make sense.");
throw vtkm::cont::ErrorBadAllocation("Does not make sense.");
}
VTKM_CONT
void Shrink(vtkm::Id /*numberOfValues*/)
{
throw vtkm::cont::ErrorControlBadAllocation("Does not make sense.");
throw vtkm::cont::ErrorBadAllocation("Does not make sense.");
}
VTKM_CONT
@ -327,7 +327,7 @@ public:
VTKM_CONT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
{
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Cannot write to an ArrayHandleCartesianProduct. It does not make "
"sense because there is overlap in the data.");
}
@ -335,7 +335,7 @@ public:
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Cannot write to an ArrayHandleCartesianProduct. It does not make "
"sense because there is overlap in the data.");
}
@ -351,7 +351,7 @@ public:
VTKM_CONT
void Shrink(vtkm::Id /*numberOfValues*/)
{
throw vtkm::cont::ErrorControlBadAllocation("Does not make sense.");
throw vtkm::cont::ErrorBadAllocation("Does not make sense.");
}
VTKM_CONT

@ -21,8 +21,8 @@
#define vtk_m_ArrayHandleCompositeVector_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorControlInternal.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/ErrorInternal.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/VecTraits.h>
@ -158,7 +158,7 @@ struct CheckArraySizeFunctor {
message << "All input arrays to ArrayHandleCompositeVector must be the same size.\n"
<< "Array " << Index-1 << " has " << a.GetNumberOfValues()
<< ". Expected " << this->ExpectedSize << ".";
throw vtkm::cont::ErrorControlBadValue(message.str().c_str());
throw vtkm::cont::ErrorBadValue(message.str().c_str());
}
}
};
@ -213,6 +213,17 @@ public:
return localPortals.GetReturnValue();
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
void Set(vtkm::Id vtkmNotUsed(index),
const ValueType &vtkmNotUsed(value)) const
{
// There is no technical reason why this cannot be implemented. As of this
// writing no one has needed to write to a composite vector yet.
VTKM_ASSERT(false && "Set not yet implemented for composite vector. Do you volunteer to implement it?");
}
private:
PortalTypes Portals;
ComponentMapType SourceComponents;
@ -271,7 +282,7 @@ public:
VTKM_CONT
PortalType GetPortal() {
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays are read only.");
}
@ -279,7 +290,7 @@ public:
PortalConstType GetPortalConst() const {
if (!this->Valid)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Tried to use an ArrayHandleCompositeHandle without dependent arrays.");
}
return PortalConstType(this->Arrays.StaticTransformCont(
@ -291,7 +302,7 @@ public:
vtkm::Id GetNumberOfValues() const {
if (!this->Valid)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Tried to use an ArrayHandleCompositeHandle without dependent arrays.");
}
return this->Arrays.template GetParameter<1>().GetNumberOfValues();
@ -299,7 +310,7 @@ public:
VTKM_CONT
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"The allocate method for the composite vector storage should never "
"have been called. The allocate is generally only called by the "
@ -310,7 +321,7 @@ public:
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays are read-only.");
}
@ -392,7 +403,7 @@ public:
{
// It may be the case a composite vector could be used for in place
// operations, but this is not implemented currently.
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays cannot be used for output or in place.");
}
@ -402,21 +413,21 @@ public:
// It may be the case a composite vector could be used for output if you
// want the delegate arrays to be resized, but this is not implemented
// currently.
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays cannot be used for output.");
}
VTKM_CONT
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays cannot be used for output.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Composite vector arrays cannot be resized.");
}

@ -143,7 +143,7 @@ public:
VTKM_CONT
void Allocate( vtkm::Id vtkmNotUsed(numberOfValues) )
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandleConcatenate should not be allocated explicitly. " );
}
@ -241,7 +241,7 @@ public:
VTKM_CONT
PortalExecution PrepareForOutput( vtkm::Id vtkmNotUsed(numberOfValues) )
{
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandleConcatenate is derived and read-only. " );
}

@ -82,6 +82,13 @@ public:
this->Step*ValueType(static_cast<ComponentType>(index)));
}
VTKM_EXEC_CONT
void Set(vtkm::Id vtkmNotUsed(index),
const ValueType &vtkmNotUsed(value)) const
{
VTKM_ASSERT(false && "Cannot write to read-only counting array.");
}
private:
ValueType Start;
ValueType Step;

@ -0,0 +1,246 @@
//============================================================================
// 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 2017 Sandia Corporation.
// Copyright 2017 UT-Battelle, LLC.
// Copyright 2017 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// 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.
//============================================================================
#ifndef vtk_m_cont_ArrayHandleDiscard_h
#define vtk_m_cont_ArrayHandleDiscard_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/TypeTraits.h>
namespace vtkm {
namespace exec {
namespace internal {
/// \brief An output-only array portal with no storage. All written values are
/// discarded.
template <typename ValueType_>
class ArrayPortalDiscard
{
public:
using ValueType = ValueType_;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ArrayPortalDiscard()
: NumberOfValues(0)
{ } // needs to be host and device so that cuda can create lvalue of these
VTKM_CONT
explicit ArrayPortalDiscard(vtkm::Id numValues)
: NumberOfValues(numValues)
{ }
/// Copy constructor for any other ArrayPortalDiscard with an iterator
/// type that can be copied to this iterator type. This allows us to do any
/// type casting that the iterators do (like the non-const to const cast).
///
template<class OtherV>
VTKM_CONT
ArrayPortalDiscard(const ArrayPortalDiscard<OtherV> &src)
: NumberOfValues(src.NumberOfValues)
{ }
VTKM_EXEC_CONT
vtkm::Id GetNumberOfValues() const
{
return this->NumberOfValues;
}
ValueType Get(vtkm::Id index) const {
VTKM_ASSERT(index < this->GetNumberOfValues());
VTKM_ASSERT("Method not supported for ArrayPortalDiscard." && false);
(void)index;
return vtkm::TypeTraits<ValueType>::ZeroInitialization();
}
VTKM_EXEC
void Set(vtkm::Id index, const ValueType &) const
{
VTKM_ASSERT(index < this->GetNumberOfValues());
(void)index;
// no-op
}
private:
vtkm::Id NumberOfValues;
};
} // end namespace internal
} // end namespace exec
namespace cont {
namespace internal {
struct VTKM_ALWAYS_EXPORT StorageTagDiscard { };
template <typename ValueType_>
class Storage<ValueType_, StorageTagDiscard>
{
public:
using ValueType = ValueType_;
using PortalType = vtkm::exec::internal::ArrayPortalDiscard<ValueType>;
using PortalConstType = vtkm::exec::internal::ArrayPortalDiscard<ValueType>;
VTKM_CONT
Storage() { }
VTKM_CONT
PortalType GetPortal()
{
return PortalType(this->NumberOfValues);
}
VTKM_CONT
PortalConstType GetPortalConst()
{
return PortalConstType(this->NumberOfValues);
}
VTKM_CONT
vtkm::Id GetNumberOfValues() const
{
return this->NumberOfValues;
}
VTKM_CONT
void Allocate(vtkm::Id numValues)
{
this->NumberOfValues = numValues;
}
VTKM_CONT
void Shrink(vtkm::Id numValues)
{
this->NumberOfValues = numValues;
}
VTKM_CONT
void ReleaseResources()
{
this->NumberOfValues = 0;
}
private:
vtkm::Id NumberOfValues;
};
template <typename ValueType_, typename DeviceAdapter_>
class ArrayTransfer<ValueType_, StorageTagDiscard, DeviceAdapter_>
{
using StorageTag = StorageTagDiscard;
using StorageType = Storage<ValueType_, StorageTag>;
public:
using ValueType = ValueType_;
using PortalControl = typename StorageType::PortalType;
using PortalConstControl = typename StorageType::PortalConstType;
using PortalExecution = vtkm::exec::internal::ArrayPortalDiscard<ValueType>;
using PortalConstExecution = vtkm::exec::internal::ArrayPortalDiscard<ValueType>;
VTKM_CONT
ArrayTransfer(StorageType *storage)
: Internal(storage)
{ }
VTKM_CONT
vtkm::Id GetNumberOfValues() const
{
VTKM_ASSERT(this->Internal != nullptr);
return this->Internal->GetNumberOfValues();
}
VTKM_CONT
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
{
throw vtkm::cont::ErrorBadValue(
"Input access not supported: "
"Cannot read from an ArrayHandleDiscard.");
}
VTKM_CONT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
{
throw vtkm::cont::ErrorBadValue(
"InPlace access not supported: "
"Cannot read from an ArrayHandleDiscard.");
}
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id numValues)
{
VTKM_ASSERT(this->Internal != nullptr);
this->Internal->Allocate(numValues);
return PortalConstExecution(this->Internal->GetNumberOfValues());
}
VTKM_CONT
void RetrieveOutputData(StorageType *storage) const
{
VTKM_ASSERT(storage == this->Internal);
(void)storage;
// no-op
}
VTKM_CONT
void Shrink(vtkm::Id numValues)
{
VTKM_ASSERT(this->Internal != nullptr);
this->Internal->Shrink(numValues);
}
VTKM_CONT
void ReleaseResources()
{
VTKM_ASSERT(this->Internal != nullptr);
this->Internal->ReleaseResources();
}
private:
StorageType *Internal;
};
template <typename ValueType_>
struct ArrayHandleDiscardTraits
{
using ValueType = ValueType_;
using StorageTag = StorageTagDiscard;
using Superclass = vtkm::cont::ArrayHandle<ValueType, StorageTag>;
};
} // end namespace internal
/// ArrayHandleDiscard is a write-only array that discards all data written to
/// it. This can be used to save memory when a filter provides optional outputs
/// that are not needed.
template <typename ValueType_>
class ArrayHandleDiscard
: public internal::ArrayHandleDiscardTraits<ValueType_>::Superclass
{
public:
VTKM_ARRAY_HANDLE_SUBCLASS(
ArrayHandleDiscard,
(ArrayHandleDiscard<ValueType_>),
(typename internal::ArrayHandleDiscardTraits<ValueType_>::Superclass));
};
} // end namespace cont
} // end namespace vtkm
#endif // vtk_m_cont_ArrayHandleDiscard_h

@ -22,7 +22,7 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
namespace vtkm {
namespace exec {
@ -164,7 +164,7 @@ public:
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
if(sourceSize%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return sourceSize/NUM_COMPONENTS;
@ -247,7 +247,7 @@ public:
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
if (sourceSize%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return sourceSize/NUM_COMPONENTS;
@ -258,7 +258,7 @@ public:
{
if (this->SourceArray.GetNumberOfValues()%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return PortalConstExecution(this->SourceArray.PrepareForInput(Device()));
@ -269,7 +269,7 @@ public:
{
if (this->SourceArray.GetNumberOfValues()%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return PortalExecution(this->SourceArray.PrepareForInPlace(Device()));

@ -24,7 +24,7 @@
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/Assert.h>
@ -487,7 +487,7 @@ void DoConvertNumComponentsToOffsets(
if (!success)
{
// Internal error? Maybe need to make a failed to execute error.
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"Failed to run ExclusiveScan on any device.");
}

@ -60,9 +60,19 @@ public:
VTKM_EXEC_CONT
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ValueType Get(vtkm::Id index) const { return this->Functor(index); }
VTKM_EXEC_CONT
void Set(vtkm::Id vtkmNotUsed(index),
const ValueType &vtkmNotUsed(value)) const
{
#if !(defined(VTKM_MSVC) && defined(VTKM_CUDA))
VTKM_ASSERT(false && "Cannot write to read-only implicit array.");
#endif
}
typedef vtkm::cont::internal::IteratorFromArrayPortal<
ArrayPortalImplicit<ValueType,FunctorType> > IteratorType;

@ -23,8 +23,8 @@
#define vtk_m_ArrayHandlePermutation_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorBadValue.h>
namespace vtkm {
namespace exec {
@ -153,13 +153,13 @@ public:
VTKM_CONT
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandlePermutation cannot be allocated.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandlePermutation cannot shrink.");
}
@ -234,7 +234,7 @@ public:
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
{
if (numberOfValues != this->GetNumberOfValues()) {
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"An ArrayHandlePermutation can be used as an output array, "
"but it cannot be resized. Make sure the index array is sized "
"to the appropriate length before trying to prepare for output.");
@ -246,7 +246,7 @@ public:
// we have to assume the allocation is correct.
if ((numberOfValues > 0) && (this->ValueArray.GetNumberOfValues() < 1))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"The value array must be pre-allocated before it is used for the "
"output of ArrayHandlePermutation.");
}
@ -265,7 +265,7 @@ public:
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandlePermutation cannot shrink.");
}

@ -23,8 +23,8 @@
#define vtk_m_cont_ArrayHandleTransform_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorControlInternal.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorInternal.h>
namespace vtkm {
namespace cont {
@ -88,6 +88,16 @@ public:
return this->Functor(this->Portal.Get(index));
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
void Set(vtkm::Id vtkmNotUsed(index),
const ValueType &vtkmNotUsed(value)) const
{
#if !(defined(VTKM_MSVC) && defined(VTKM_CUDA))
VTKM_ASSERT(false && "Cannot write to read-only transform array. (No inverse transform given.)");
#endif
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
const PortalType &GetPortal() const { return this->Portal; }
@ -205,13 +215,13 @@ public:
VTKM_CONT
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleTransform is read only. It cannot be allocated.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleTransform is read only. It cannot shrink.");
}
@ -364,20 +374,20 @@ public:
VTKM_CONT
PortalExecution PrepareForInPlace(bool &vtkmNotUsed(updateData)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleTransform read only. "
"Cannot be used for in-place operations.");
}
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleTransform read only. Cannot be used as output.");
}
VTKM_CONT
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const {
throw vtkm::cont::ErrorControlInternal(
throw vtkm::cont::ErrorInternal(
"ArrayHandleTransform read only. "
"There should be no occurance of the ArrayHandle trying to pull "
"data from the execution environment.");
@ -385,7 +395,7 @@ public:
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleTransform read only. Cannot shrink.");
}

@ -72,8 +72,9 @@ public:
VTKM_CONT
ValueType Get(vtkm::Id index) const;
/// Sets a value in the array. This function may not exist for an ArrayPortal
/// pointing to a const array.
/// Sets a value in the array. If it is not possible to set a value in the
/// array, this method may error out (for example with a VTKM_ASSERT). In
/// this case the behavior is undefined.
///
VTKM_CONT
void Set(vtkm::Id index, const ValueType &value) const;

@ -0,0 +1,132 @@
//============================================================================
// 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 2016 Sandia Corporation.
// Copyright 2016 UT-Battelle, LLC.
// Copyright 2016 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// 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.
//============================================================================
#ifndef vtk_m_cont_ArrayRangeCompute_h
#define vtk_m_cont_ArrayRangeCompute_h
#include <vtkm/Range.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
namespace vtkm {
namespace cont {
namespace internal {
struct RangeMin
{
template<typename T>
VTKM_EXEC
T operator()(const T& a, const T& b)const { return vtkm::Min(a,b); }
};
struct RangeMax
{
template<typename T>
VTKM_EXEC
T operator()(const T& a, const T& b)const { return vtkm::Max(a,b); }
};
} // namespace internal
/// \brief Compute the range of the data in an array handle.
///
/// Given an \c ArrayHandle, this function computes the range (min and max) of
/// the values in the array. For arrays containing Vec values, the range is
/// computed for each component.
///
/// This method also takes a device adapter tag to specify the device on which
/// to compute the range.
///
/// The result is returned in an \c ArrayHandle of \c Range objects. There is
/// one value in the returned array for every component of the input's value
/// type.
///
template<typename ArrayHandleType, typename Device>
inline
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const ArrayHandleType &input, Device)
{
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
typedef typename ArrayHandleType::ValueType ValueType;
typedef vtkm::VecTraits<ValueType> VecType;
const vtkm::IdComponent NumberOfComponents = VecType::NUM_COMPONENTS;
typedef vtkm::cont::DeviceAdapterAlgorithm<Device> Algorithm;
//not the greatest way of doing this for performance reasons. But
//this implementation should generate the smallest amount of code
ValueType initialMin = input.GetPortalConstControl().Get(0);
ValueType initialMax = initialMin;
ValueType minResult =
Algorithm::Reduce(input, initialMin, internal::RangeMin());
ValueType maxResult =
Algorithm::Reduce(input, initialMax, internal::RangeMax());
vtkm::cont::ArrayHandle<vtkm::Range> rangeArray;
rangeArray.Allocate(NumberOfComponents);
for (vtkm::IdComponent i = 0; i < NumberOfComponents; ++i)
{
rangeArray.GetPortalControl().Set(
i, vtkm::Range(VecType::GetComponent(minResult, i),
VecType::GetComponent(maxResult, i)));
}
return rangeArray;
}
// Special implementation for regular point coordinates, which are easy
// to determine.
inline
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::FloatDefault,3>,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>
&array)
{
vtkm::internal::ArrayPortalUniformPointCoordinates portal =
array.GetPortalConstControl();
// In this portal we know that the min value is the first entry and the
// max value is the last entry.
vtkm::Vec<vtkm::FloatDefault,3> minimum = portal.Get(0);
vtkm::Vec<vtkm::FloatDefault,3> maximum =
portal.Get(portal.GetNumberOfValues()-1);
vtkm::cont::ArrayHandle<vtkm::Range> rangeArray;
rangeArray.Allocate(3);
vtkm::cont::ArrayHandle<vtkm::Range>::PortalControl outPortal =
rangeArray.GetPortalControl();
outPortal.Set(0, vtkm::Range(minimum[0], maximum[0]));
outPortal.Set(1, vtkm::Range(minimum[1], maximum[1]));
outPortal.Set(2, vtkm::Range(minimum[2], maximum[2]));
return rangeArray;
}
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ArrayRangeCompute_h

@ -25,6 +25,7 @@ set(headers
ArrayHandleCompositeVector.h
ArrayHandleConstant.h
ArrayHandleCounting.h
ArrayHandleDiscard.h
ArrayHandleGroupVec.h
ArrayHandleGroupVecVariable.h
ArrayHandleImplicit.h
@ -37,6 +38,7 @@ set(headers
ArrayPortal.h
ArrayPortalToIterators.h
ArrayHandleConcatenate.h
ArrayRangeCompute.h
CellSet.h
CellSetExplicit.h
CellSetListTag.h
@ -55,12 +57,11 @@ set(headers
DynamicArrayHandle.h
DynamicCellSet.h
Error.h
ErrorControl.h
ErrorControlBadAllocation.h
ErrorControlBadType.h
ErrorControlBadValue.h
ErrorControlInternal.h
ErrorBadAllocation.h
ErrorBadType.h
ErrorBadValue.h
ErrorExecution.h
ErrorInternal.h
Field.h
RuntimeDeviceInformation.h
Storage.h
@ -89,6 +90,7 @@ set(sources
)
vtkm_library(SOURCES ${sources})
target_include_directories(vtkm_cont PRIVATE ${VTKm_BACKEND_INCLUDE_DIRS})
#-----------------------------------------------------------------------------
add_subdirectory(internal)

@ -214,19 +214,19 @@ public:
if (Traits::GetNumberOfComponents(ids) < numVertices)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Added more cells then expected.");
}
if (this->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
@ -253,7 +253,7 @@ public:
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Did not add as many cells as expected.");
}
@ -289,7 +289,7 @@ public:
this->PointToCell.IndexOffsetsValid = false;
if (offsets.GetNumberOfValues() != 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Explicit cell offsets array unexpected size. "
"Use an empty array to automatically generate.");
}

@ -110,14 +110,14 @@ public:
if (Traits::GetNumberOfComponents(ids) < numVertices)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
@ -125,7 +125,7 @@ public:
{
if (shapeId == vtkm::CELL_SHAPE_EMPTY)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Cannot create cells of type empty.");
}
this->CellShapeAsId = shapeId;
@ -136,12 +136,12 @@ public:
{
if (shapeId != this->GetCellShape(0))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Cannot have differing shapes in CellSetSingleType.");
}
if (numVertices != this->NumberOfPointsPerCell)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Inconsistent number of points in cells for CellSetSingleType.");
}
}
@ -179,7 +179,7 @@ public:
if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Did not add the expected number of cells.");
}
@ -246,7 +246,7 @@ private:
{
if (numVertices != vtkm::CellTraits<CellShapeTag>::NUM_POINTS)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Passed invalid number of points for cell shape.");
}
}
@ -271,7 +271,7 @@ private:
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
numVertices) );
default:
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"CellSetSingleType unable to determine the cell type");
}
}

@ -25,7 +25,7 @@
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
namespace vtkm {
@ -86,7 +86,7 @@ public:
}
else
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"No field with requested name: " + name);
}
}
@ -99,6 +99,18 @@ public:
return this->GetField(this->GetFieldIndex(name, assoc));
}
VTKM_CONT
const vtkm::cont::Field &GetCellField(const std::string &name) const
{
return this->GetField(name, vtkm::cont::Field::ASSOC_CELL_SET);
}
VTKM_CONT
const vtkm::cont::Field &GetPointField(const std::string &name) const
{
return this->GetField(name, vtkm::cont::Field::ASSOC_POINTS);
}
VTKM_CONT
void AddCoordinateSystem(vtkm::cont::CoordinateSystem cs)
{
@ -133,7 +145,7 @@ public:
}
else
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"No coordinate system with requested name");
}
}
@ -186,7 +198,7 @@ public:
}
else
{
throw vtkm::cont::ErrorControlBadValue("No cell set with requested name");
throw vtkm::cont::ErrorBadValue("No cell set with requested name");
}
}

@ -280,7 +280,7 @@ private:
dataSet.AddCellSet(cellSet);
}
else
throw vtkm::cont::ErrorControlBadValue("Invalid cell set dimension");
throw vtkm::cont::ErrorBadValue("Invalid cell set dimension");
return dataSet;
}

@ -161,7 +161,7 @@ private:
dataSet.AddCellSet(cellSet);
}
else
throw vtkm::cont::ErrorControlBadValue("Invalid cell set dimension");
throw vtkm::cont::ErrorBadValue("Invalid cell set dimension");
return dataSet;
}

@ -26,7 +26,7 @@
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/StorageListTag.h>
#include <vtkm/cont/internal/DynamicTransform.h>
@ -260,7 +260,7 @@ public:
}
/// Returns this array cast to an ArrayHandle object of the given type and
/// storage. Throws \c ErrorControlBadType if the cast does not work. Use
/// storage. Throws \c ErrorBadType if the cast does not work. Use
/// \c IsTypeAndStorage to check if the cast can happen.
///
///
@ -272,7 +272,7 @@ public:
detail::DynamicArrayHandleTryCast<Type,Storage>(this->ArrayContainer);
if (downcastArray == nullptr)
{
throw vtkm::cont::ErrorControlBadType("Bad cast of dynamic array.");
throw vtkm::cont::ErrorBadType("Bad cast of dynamic array.");
}
// Technically, this method returns a copy of the \c ArrayHandle. But
// because \c ArrayHandle acts like a shared pointer, it is valid to
@ -281,7 +281,7 @@ public:
}
/// Returns this array cast to the given \c ArrayHandle type. Throws \c
/// ErrorControlBadType if the cast does not work. Use \c IsType
/// ErrorBadType if the cast does not work. Use \c IsType
/// to check if the cast can happen.
///
template<typename ArrayHandleType>
@ -298,7 +298,7 @@ public:
/// Given a refernce to an ArrayHandle object, casts this array to the
/// ArrayHandle's type and sets the given ArrayHandle to this array. Throws
/// \c ErrorControlBadType if the cast does not work. Use \c
/// \c ErrorBadType if the cast does not work. Use \c
/// ArrayHandleType to check if the cast can happen.
///
/// Note that this is a shallow copy. The data are not copied and a change
@ -514,7 +514,7 @@ void DynamicArrayHandleBase<TypeList,StorageList>::
vtkm::ListForEach(tryType, TypeList());
if (!tryType.FoundCast)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Could not find appropriate cast for array in CastAndCall1.");
}
}
@ -538,7 +538,7 @@ void DynamicArrayHandleBase<VTKM_DEFAULT_TYPE_LIST_TAG,
vtkm::ListForEach(tryType, VTKM_DEFAULT_TYPE_LIST_TAG());
if (!tryType.FoundCast)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Could not find appropriate cast for array in CastAndCall2.");
}
}

@ -22,7 +22,7 @@
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/CellSetListTag.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/internal/DynamicTransform.h>
#include <vtkm/cont/internal/SimplePolymorphicContainer.h>
@ -183,7 +183,7 @@ public:
}
/// Returns this cell set cast to the given \c CellSet type. Throws \c
/// ErrorControlBadType if the cast does not work. Use \c IsType to check if
/// ErrorBadType if the cast does not work. Use \c IsType to check if
/// the cast can happen.
///
template<typename CellSetType>
@ -193,14 +193,14 @@ public:
detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer);
if (cellSetPointer == nullptr)
{
throw vtkm::cont::ErrorControlBadType("Bad cast of dynamic cell set.");
throw vtkm::cont::ErrorBadType("Bad cast of dynamic cell set.");
}
return *cellSetPointer;
}
/// Given a reference to a concrete \c CellSet object, attempt to downcast
/// the contain cell set to the provided type and copy into the given \c
/// CellSet object. Throws \c ErrorControlBadType if the cast does not work.
/// CellSet object. Throws \c ErrorBadType if the cast does not work.
/// Use \c IsType to check if the cast can happen.
///
/// Note that this is a shallow copy. Any data in associated arrays are not
@ -344,7 +344,7 @@ void DynamicCellSetBase<CellSetList>::CastAndCall(const Functor &f) const
vtkm::ListForEach(tryCellSet, CellSetList());
if (!tryCellSet.FoundCast)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Could not find appropriate cast for cell set.");
}
}

@ -17,10 +17,10 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_ErrorControlBadAllocation_h
#define vtk_m_cont_ErrorControlBadAllocation_h
#ifndef vtk_m_cont_ErrorBadAllocation_h
#define vtk_m_cont_ErrorBadAllocation_h
#include <vtkm/cont/ErrorControl.h>
#include <vtkm/cont/Error.h>
namespace vtkm {
namespace cont {
@ -28,14 +28,14 @@ namespace cont {
/// This class is thrown when VTK-m attempts to manipulate memory that it should
/// not.
///
class VTKM_ALWAYS_EXPORT ErrorControlBadAllocation : public ErrorControl
class VTKM_ALWAYS_EXPORT ErrorBadAllocation : public Error
{
public:
ErrorControlBadAllocation(const std::string &message)
: ErrorControl(message) { }
ErrorBadAllocation(const std::string &message)
: Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlBadAllocation_h
#endif //vtk_m_cont_ErrorBadAllocation_h

@ -17,10 +17,10 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_ErrorControlBadType_h
#define vtk_m_cont_ErrorControlBadType_h
#ifndef vtk_m_cont_ErrorBadType_h
#define vtk_m_cont_ErrorBadType_h
#include <vtkm/cont/ErrorControl.h>
#include <vtkm/cont/Error.h>
namespace vtkm {
namespace cont {
@ -28,14 +28,14 @@ namespace cont {
/// This class is thrown when VTK-m encounters data of a type that is
/// incompatible with the current operation.
///
class VTKM_ALWAYS_EXPORT ErrorControlBadType : public ErrorControl
class VTKM_ALWAYS_EXPORT ErrorBadType : public Error
{
public:
ErrorControlBadType(const std::string &message)
: ErrorControl(message) { }
ErrorBadType(const std::string &message)
: Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlBadType_h
#endif //vtk_m_cont_ErrorBadType_h

@ -17,10 +17,10 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_ErrorControlBadValue_h
#define vtk_m_cont_ErrorControlBadValue_h
#ifndef vtk_m_cont_ErrorBadValue_h
#define vtk_m_cont_ErrorBadValue_h
#include <vtkm/cont/ErrorControl.h>
#include <vtkm/cont/Error.h>
namespace vtkm {
namespace cont {
@ -28,14 +28,14 @@ namespace cont {
/// This class is thrown when a VTKm function or method encounters an invalid
/// value that inhibits progress.
///
class VTKM_ALWAYS_EXPORT ErrorControlBadValue : public ErrorControl
class VTKM_ALWAYS_EXPORT ErrorBadValue : public Error
{
public:
ErrorControlBadValue(const std::string &message)
: ErrorControl(message) { }
ErrorBadValue(const std::string &message)
: Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlBadValue_h
#endif //vtk_m_cont_ErrorBadValue_h

@ -1,41 +0,0 @@
//============================================================================
// 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 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// 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.
//============================================================================
#ifndef vtk_m_cont_ErrorControl_h
#define vtk_m_cont_ErrorControl_h
#include <vtkm/cont/Error.h>
namespace vtkm {
namespace cont {
/// The superclass of all exceptions thrown from within the VTKm control
/// environment.
///
class VTKM_ALWAYS_EXPORT ErrorControl : public vtkm::cont::Error
{
protected:
ErrorControl() { }
ErrorControl(const std::string message) : Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControl_h

@ -17,10 +17,10 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_ErrorControlInternal_h
#define vtk_m_cont_ErrorControlInternal_h
#ifndef vtk_m_cont_ErrorInternal_h
#define vtk_m_cont_ErrorInternal_h
#include <vtkm/cont/ErrorControl.h>
#include <vtkm/cont/Error.h>
namespace vtkm {
namespace cont {
@ -29,14 +29,14 @@ namespace cont {
/// be reached. This error usually indicates a bug in vtkm or, at best, VTKm
/// failed to detect an invalid input it should have.
///
class VTKM_ALWAYS_EXPORT ErrorControlInternal : public ErrorControl
class VTKM_ALWAYS_EXPORT ErrorInternal : public Error
{
public:
ErrorControlInternal(const std::string &message)
: ErrorControl(message) { }
ErrorInternal(const std::string &message)
: Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlInternal_h
#endif //vtk_m_cont_ErrorInternal_h

@ -31,6 +31,7 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ArrayRangeCompute.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/DynamicArrayHandle.h>
@ -50,50 +51,7 @@ public:
template<typename ArrayHandleType>
void operator()(const ArrayHandleType &input) const
{
typedef typename ArrayHandleType::ValueType ValueType;
typedef vtkm::VecTraits<ValueType> VecType;
const vtkm::IdComponent NumberOfComponents = VecType::NUM_COMPONENTS;
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> Algorithm;
//not the greatest way of doing this for performance reasons. But
//this implementation should generate the smallest amount of code
vtkm::Vec<ValueType,2> initial(input.GetPortalConstControl().Get(0));
vtkm::Vec<ValueType, 2> result =
Algorithm::Reduce(input, initial, vtkm::MinAndMax<ValueType>());
this->Range->Allocate(NumberOfComponents);
for (vtkm::IdComponent i = 0; i < NumberOfComponents; ++i)
{
this->Range->GetPortalControl().Set(
i, vtkm::Range(VecType::GetComponent(result[0], i),
VecType::GetComponent(result[1], i)));
}
}
// Special implementation for regular point coordinates, which are easy
// to determine.
void operator()(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::FloatDefault,3>,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>
&array)
{
vtkm::internal::ArrayPortalUniformPointCoordinates portal =
array.GetPortalConstControl();
// In this portal we know that the min value is the first entry and the
// max value is the last entry.
vtkm::Vec<vtkm::FloatDefault,3> minimum = portal.Get(0);
vtkm::Vec<vtkm::FloatDefault,3> maximum =
portal.Get(portal.GetNumberOfValues()-1);
this->Range->Allocate(3);
vtkm::cont::ArrayHandle<vtkm::Range>::PortalControl outPortal =
this->Range->GetPortalControl();
outPortal.Set(0, vtkm::Range(minimum[0], maximum[0]));
outPortal.Set(1, vtkm::Range(minimum[1], maximum[1]));
outPortal.Set(2, vtkm::Range(minimum[2], maximum[2]));
*this->Range = vtkm::cont::ArrayRangeCompute(input, DeviceAdapterTag());
}
private:

@ -132,8 +132,8 @@ public:
///
/// The allocation may be done on an already existing array, but can wipe out
/// any data already in the array. This method can throw
/// ErrorControlBadAllocation if the array cannot be allocated or
/// ErrorControlBadValue if the allocation is not feasible (for example, the
/// ErrorBadAllocation if the array cannot be allocated or
/// ErrorBadValue if the allocation is not feasible (for example, the
/// array storage is read-only).
///
VTKM_CONT

@ -22,8 +22,8 @@
#include <vtkm/Assert.h>
#include <vtkm/Types.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/Storage.h>
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>

@ -48,7 +48,7 @@ Storage<T, vtkm::cont::StorageTagBasic>::Storage(const Storage<T, StorageTagBasi
{
if (src.DeallocateOnRelease)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Attempted to copy a storage array that needs deallocation. "
"This is disallowed to prevent complications with deallocation.");
}
@ -60,7 +60,7 @@ Storage<T, vtkm::cont::StorageTagBasic>::operator=(const Storage<T, StorageTagBa
{
if (src.DeallocateOnRelease)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Attempted to copy a storage array that needs deallocation. "
"This is disallowed to prevent complications with deallocation.");
}
@ -108,7 +108,7 @@ void Storage<T, vtkm::cont::StorageTagBasic>::Allocate(vtkm::Id numberOfValues)
if(this->UserProvidedMemory)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"User allocated arrays cannot be reallocated.");
}
@ -134,7 +134,7 @@ void Storage<T, vtkm::cont::StorageTagBasic>::Allocate(vtkm::Id numberOfValues)
this->Array = nullptr;
this->NumberOfValues = 0;
this->AllocatedSize = 0;
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Could not allocate basic control array.");
}
@ -147,7 +147,7 @@ void Storage<T, vtkm::cont::StorageTagBasic>::Shrink(vtkm::Id numberOfValues)
{
if (numberOfValues > this->GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Shrink method cannot be used to grow array.");
}

@ -23,7 +23,7 @@
#include <vtkm/Types.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Storage.h>
#include <vtkm/cont/internal/ArrayTransfer.h>
@ -74,7 +74,7 @@ public:
VTKM_CONT
PortalType GetPortal()
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
throw vtkm::cont::ErrorBadValue("Implicit arrays are read-only.");
}
VTKM_CONT
PortalConstType GetPortalConst() const
@ -89,12 +89,12 @@ public:
VTKM_CONT
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
throw vtkm::cont::ErrorBadValue("Implicit arrays are read-only.");
}
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
throw vtkm::cont::ErrorBadValue("Implicit arrays are read-only.");
}
VTKM_CONT
void ReleaseResources()
@ -138,20 +138,20 @@ public:
VTKM_CONT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Implicit arrays cannot be used for output or in place.");
}
VTKM_CONT
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Implicit arrays cannot be used for output.");
}
VTKM_CONT
void RetrieveOutputData(StorageType *vtkmNotUsed(controlArray)) const
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Implicit arrays cannot be used for output.");
}
@ -169,7 +169,7 @@ public:
VTKM_CONT
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays cannot be resized.");
throw vtkm::cont::ErrorBadValue("Implicit arrays cannot be resized.");
}
VTKM_CONT

@ -21,9 +21,9 @@
#define vtk_m_cont_TryExecute_h
#include <vtkm/cont/DeviceAdapterListTag.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/internal/RuntimeDeviceTracker.h>
@ -59,24 +59,24 @@ struct TryExecuteRunIfValid<Functor, Device, true>
{
return functor(Device());
}
catch(vtkm::cont::ErrorControlBadAllocation e)
catch(vtkm::cont::ErrorBadAllocation e)
{
std::cerr << "caught ErrorControlBadAllocation " << e.GetMessage() << std::endl;
std::cerr << "caught ErrorBadAllocation " << e.GetMessage() << std::endl;
//currently we only consider OOM errors worth disabling a device for
//than we fallback to another device
tracker.ReportAllocationFailure(Device(), e);
}
catch(vtkm::cont::ErrorControlBadType e)
catch(vtkm::cont::ErrorBadType e)
{
//should bad type errors should stop the execution, instead of
//deferring to another device adapter?
std::cerr << "caught ErrorControlBadType : " << e.GetMessage() << std::endl;
std::cerr << "caught ErrorBadType : " << e.GetMessage() << std::endl;
}
catch(vtkm::cont::ErrorControlBadValue e)
catch(vtkm::cont::ErrorBadValue e)
{
//should bad value errors should stop the filter, instead of deferring
//to another device adapter?
std::cerr << "caught ErrorControlBadValue : " << e.GetMessage() << std::endl;
std::cerr << "caught ErrorBadValue : " << e.GetMessage() << std::endl;
}
catch(vtkm::cont::Error e)
{

@ -56,7 +56,7 @@ struct Transport<vtkm::cont::arg::TransportTagArrayIn, ContObjectType, Device>
if (object.GetNumberOfValues() != inputDomain.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Input array to worklet invocation the wrong size.");
}

@ -56,7 +56,7 @@ struct Transport<vtkm::cont::arg::TransportTagArrayInOut, ContObjectType, Device
{
if (object.GetNumberOfValues() != size)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Input array to worklet invocation the wrong size.");
}

@ -93,7 +93,7 @@ struct Transport<
if (object.GetNumberOfValues() !=
detail::TopologyDomainSize(inputDomain, TopologyElementTag()))
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Input array to worklet invocation the wrong size.");
}

@ -23,8 +23,8 @@
#define vtk_m_cont_cuda_ArrayHandleCuda_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/Storage.h>
#ifdef VTKM_CUDA
@ -83,7 +83,14 @@ public:
VTKM_CONT
ValueType Get(vtkm::Id index) const
{
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"ArrayHandleCuda only provides access to the device pointer.");
}
VTKM_CONT
void Set(vtkm::Id vtkmNotUsed(index), T vtkmNotUsed(value)) const
{
throw vtkm::cont::ErrorBadType(
"ArrayHandleCuda only provides access to the device pointer.");
}
@ -148,7 +155,7 @@ public:
void Allocate(vtkm::Id size)
{
if (!this->OwnsResources())
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"ArrayHandleCuda does not own its internal device memory.");
if (NumberOfValues != 0)
@ -171,7 +178,7 @@ public:
void ReleaseResources()
{
if (!this->OwnsResources())
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"ArrayHandleCuda does not own its internal device memory.");
if (this->NumberOfValues)

@ -22,7 +22,7 @@ set(headers
ArrayHandleCuda.h
ChooseCudaDevice.h
DeviceAdapterCuda.h
ErrorControlCuda.h
ErrorCuda.h
)
#-----------------------------------------------------------------------------

@ -22,7 +22,7 @@
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/cuda/ErrorControlCuda.h>
#include <vtkm/cont/cuda/ErrorCuda.h>
#include <cuda.h>
#include <algorithm>

@ -17,18 +17,18 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_cuda_ErrorControlCuda_h
#define vtk_m_cont_cuda_ErrorControlCuda_h
#ifndef vtk_m_cont_cuda_ErrorCuda_h
#define vtk_m_cont_cuda_ErrorCuda_h
#include <vtkm/Types.h>
#include <vtkm/cont/ErrorControl.h>
#include <vtkm/cont/Error.h>
#include <cuda.h>
#include <sstream>
/// A macro that can be used to check to see if there are any unchecked
/// CUDA errors. Will throw an ErrorControlCuda if there are.
/// CUDA errors. Will throw an ErrorCuda if there are.
///
#define VTKM_CUDA_CHECK_ASYNCHRONOUS_ERROR() \
VTKM_SWALLOW_SEMICOLON_PRE_BLOCK \
@ -36,7 +36,7 @@
const cudaError_t vtkm_cuda_check_async_error = cudaGetLastError(); \
if (vtkm_cuda_check_async_error != cudaSuccess) \
{ \
throw ::vtkm::cont::cuda::ErrorControlCuda( \
throw ::vtkm::cont::cuda::ErrorCuda( \
vtkm_cuda_check_async_error, \
__FILE__, \
__LINE__, \
@ -46,7 +46,7 @@
VTKM_SWALLOW_SEMICOLON_POST_BLOCK
/// A macro that can be wrapped around a CUDA command and will throw an
/// ErrorControlCuda exception if the CUDA command fails.
/// ErrorCuda exception if the CUDA command fails.
///
#define VTKM_CUDA_CALL(command) \
VTKM_CUDA_CHECK_ASYNCHRONOUS_ERROR(); \
@ -55,7 +55,7 @@
const cudaError_t vtkm_cuda_call_error = command; \
if (vtkm_cuda_call_error != cudaSuccess) \
{ \
throw ::vtkm::cont::cuda::ErrorControlCuda(vtkm_cuda_call_error, \
throw ::vtkm::cont::cuda::ErrorCuda(vtkm_cuda_call_error, \
__FILE__, \
__LINE__, \
#command); \
@ -70,17 +70,17 @@ namespace cuda {
/// This error is thrown whenever an unidentified CUDA runtime error is
/// encountered.
///
class VTKM_ALWAYS_EXPORT ErrorControlCuda : public vtkm::cont::ErrorControl
class VTKM_ALWAYS_EXPORT ErrorCuda : public vtkm::cont::Error
{
public:
ErrorControlCuda(cudaError_t error)
ErrorCuda(cudaError_t error)
{
std::stringstream message;
message << "CUDA Error: " << cudaGetErrorString(error);
this->SetMessage(message.str());
}
ErrorControlCuda(cudaError_t error,
ErrorCuda(cudaError_t error,
const std::string &file,
vtkm::Id line,
const std::string &description)
@ -96,4 +96,4 @@ public:
}
} // namespace vtkm::cont:cuda
#endif //vtk_m_cont_cuda_ErrorControlCuda_h
#endif //vtk_m_cont_cuda_ErrorCuda_h

@ -60,7 +60,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForInput<void>(updateData);
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -81,7 +81,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForInPlace<void>(updateData);
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -102,7 +102,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForOutput<void>(numberOfValues);
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();

@ -21,7 +21,7 @@
#define vtk_m_cont_cuda_internal_ArrayManagerExecutionThrustDevice_h
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/Storage.h>
// Disable warnings we check vtkm for but Thrust does not.
@ -34,42 +34,29 @@ VTKM_THIRDPARTY_PRE_INCLUDE
VTKM_THIRDPARTY_POST_INCLUDE
#include <vtkm/cont/cuda/ErrorCuda.h>
#include <vtkm/cont/cuda/internal/ThrustExceptionHandler.h>
#include <vtkm/exec/cuda/internal/ArrayPortalFromThrust.h>
#include <limits>
namespace vtkm {
namespace cont {
namespace cuda {
namespace internal {
// UninitializedAllocator is an allocator which
// derives from device_allocator and which has a
// no-op construct member function
template<typename T>
struct UninitializedAllocator
: ::thrust::device_malloc_allocator<T>
{
// note that construct is annotated as
// a __host__ __device__ function
__host__ __device__
void construct(T * vtkmNotUsed(p) )
{
// no-op
}
};
/// \c ArrayManagerExecutionThrustDevice provides an implementation for a \c
/// ArrayManagerExecution class for a thrust device adapter that is designed
/// for the cuda backend which has separate memory spaces for host and device.
/// This implementation contains a thrust::system::cuda::vector to allocate
/// and manage the array.
///
/// This implementation contains a thrust::system::cuda::pointer to contain the
/// data.
template<typename T, class StorageTag>
class ArrayManagerExecutionThrustDevice
{
public:
typedef T ValueType;
typedef typename thrust::system::cuda::pointer<T>::difference_type difference_type;
typedef typename thrust::system::cuda::pointer<ValueType> PointerType;
typedef typename PointerType::difference_type difference_type;
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
@ -78,9 +65,11 @@ public:
VTKM_CONT
ArrayManagerExecutionThrustDevice(StorageType *storage)
: Storage(storage), Array()
: Storage(storage),
Begin(static_cast<ValueType*>(nullptr)),
End(static_cast<ValueType*>(nullptr)),
Capacity(static_cast<ValueType*>(nullptr))
{
}
VTKM_CONT
@ -93,7 +82,7 @@ public:
///
VTKM_CONT
vtkm::Id GetNumberOfValues() const {
return static_cast<vtkm::Id>(this->Array.size());
return static_cast<vtkm::Id>(this->End.get() - this->Begin.get());
}
/// Allocates the appropriate size of the array and copies the given data
@ -111,9 +100,7 @@ public:
// The data in this->Array should already be valid.
}
return PortalConstType(this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()));
return PortalConstType(this->Begin, this->End);
}
/// Workaround for nvcc 7.5 compiler warning bug.
@ -139,8 +126,7 @@ public:
// The data in this->Array should already be valid.
}
return PortalType(this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()));
return PortalType(this->Begin, this->End);
}
/// Workaround for nvcc 7.5 compiler warning bug.
@ -156,24 +142,55 @@ public:
VTKM_CONT
PortalType PrepareForOutput(vtkm::Id numberOfValues)
{
if (numberOfValues > this->GetNumberOfValues())
// Can we reuse the existing buffer?
vtkm::Id curCapacity = this->Begin.get() != nullptr
? static_cast<vtkm::Id>(this->Capacity.get() - this->Begin.get())
: 0;
// Just mark a new end if we don't need to increase the allocation:
if (curCapacity >= numberOfValues)
{
// Resize to 0 first so that you don't have to copy data when resizing
// to a larger size.
this->Array.clear();
this->End = PointerType(this->Begin.get() +
static_cast<difference_type>(numberOfValues));
return PortalType(this->Begin, this->End);
}
const std::size_t maxNumVals = (std::numeric_limits<std::size_t>::max() /
sizeof(ValueType));
if (static_cast<size_t>(numberOfValues) > maxNumVals)
{
std::ostringstream err;
err << "Failed to allocate " << numberOfValues << " values on device: "
<< "Number of bytes is not representable by std::size_t.";
throw vtkm::cont::ErrorBadAllocation(err.str());
}
this->ReleaseResources();
const std::size_t bufferSize = numberOfValues * sizeof(ValueType);
// Attempt to allocate:
try
{
this->Array.resize(static_cast<std::size_t>(numberOfValues));
ValueType *tmp;
VTKM_CUDA_CALL(cudaMalloc(&tmp, bufferSize));
this->Begin = PointerType(tmp);
}
catch (std::bad_alloc error)
catch (const std::exception &error)
{
throw vtkm::cont::ErrorControlBadAllocation(error.what());
std::ostringstream err;
err << "Failed to allocate " << bufferSize << " bytes on device: "
<< error.what();
throw vtkm::cont::ErrorBadAllocation(err.str());
}
return PortalType(this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()));
this->Capacity = PointerType(this->Begin.get() +
static_cast<difference_type>(numberOfValues));
this->End = this->Capacity;
return PortalType(this->Begin, this->End);
}
/// Workaround for nvcc 7.5 compiler warning bug.
@ -190,12 +207,10 @@ public:
VTKM_CONT
void RetrieveOutputData(StorageType *storage) const
{
storage->Allocate(static_cast<vtkm::Id>(this->Array.size()));
storage->Allocate(this->GetNumberOfValues());
try
{
::thrust::copy(
this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()),
::thrust::copy(this->Begin, this->End,
vtkm::cont::ArrayPortalToIteratorBegin(storage->GetPortal()));
}
catch (...)
@ -211,10 +226,7 @@ public:
template <class IteratorTypeControl>
VTKM_CONT void CopyInto(IteratorTypeControl dest) const
{
::thrust::copy(
this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()),
dest);
::thrust::copy(this->Begin, this->End, dest);
}
/// Resizes the device vector.
@ -223,18 +235,24 @@ public:
{
// The operation will succeed even if this assertion fails, but this
// is still supposed to be a precondition to Shrink.
VTKM_ASSERT(numberOfValues <= static_cast<vtkm::Id>(this->Array.size()));
VTKM_ASSERT(this->Begin.get() != nullptr &&
this->Begin.get() + numberOfValues <= this->End.get());
this->Array.resize(static_cast<std::size_t>(numberOfValues));
this->End = PointerType(this->Begin.get() +
static_cast<difference_type>(numberOfValues));
}
/// Frees all memory.
///
VTKM_CONT void ReleaseResources()
{
this->Array.clear();
this->Array.shrink_to_fit();
if (this->Begin.get() != nullptr)
{
VTKM_CUDA_CALL(cudaFree(this->Begin.get()));
this->Begin = PointerType(static_cast<ValueType*>(nullptr));
this->End = PointerType(static_cast<ValueType*>(nullptr));
this->Capacity = PointerType(static_cast<ValueType*>(nullptr));
}
}
private:
@ -246,17 +264,19 @@ private:
StorageType *Storage;
::thrust::system::cuda::vector<ValueType,
UninitializedAllocator<ValueType> > Array;
PointerType Begin;
PointerType End;
PointerType Capacity;
VTKM_CONT
void CopyToExecution()
{
try
{
this->Array.assign(
vtkm::cont::ArrayPortalToIteratorBegin(this->Storage->GetPortalConst()),
vtkm::cont::ArrayPortalToIteratorEnd(this->Storage->GetPortalConst()));
this->PrepareForOutput(this->Storage->GetNumberOfValues());
::thrust::copy(vtkm::cont::ArrayPortalToIteratorBegin(this->Storage->GetPortalConst()),
vtkm::cont::ArrayPortalToIteratorEnd(this->Storage->GetPortalConst()),
this->Begin);
}
catch (...)
{

@ -20,7 +20,7 @@
#ifndef vtk_m_cont_cuda_internal_DeviceAdapterAlgorithmCuda_h
#define vtk_m_cont_cuda_internal_DeviceAdapterAlgorithmCuda_h
#include <vtkm/cont/cuda/ErrorControlCuda.h>
#include <vtkm/cont/cuda/ErrorCuda.h>
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
#include <vtkm/cont/cuda/internal/ArrayManagerExecutionCuda.h>

@ -28,7 +28,7 @@
#include <vtkm/TypeTraits.h>
#include <vtkm/UnaryPredicates.h>
#include <vtkm/cont/cuda/ErrorControlCuda.h>
#include <vtkm/cont/cuda/ErrorCuda.h>
#include <vtkm/cont/cuda/internal/MakeThrustIterator.h>
#include <vtkm/cont/cuda/internal/ThrustExceptionHandler.h>

@ -21,7 +21,7 @@
#define vtk_m_cont_cuda_interal_ThrustExecptionHandler_h
#include <vtkm/internal/ExportMacros.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
VTKM_THIRDPARTY_PRE_INCLUDE
@ -43,7 +43,7 @@ static inline void throwAsVTKmException()
}
catch(std::bad_alloc &error)
{
throw vtkm::cont::ErrorControlBadAllocation(error.what());
throw vtkm::cont::ErrorBadAllocation(error.what());
}
catch(thrust::system_error &error)
{

@ -20,7 +20,7 @@
#ifndef vtk_m_cont_exec_ArrayHandleExecutionManager_h
#define vtk_m_cont_exec_ArrayHandleExecutionManager_h
#include <vtkm/cont/ErrorControlInternal.h>
#include <vtkm/cont/ErrorInternal.h>
#include <vtkm/cont/Storage.h>
#include <vtkm/cont/internal/ArrayTransfer.h>
@ -192,7 +192,7 @@ private:
{
if (!this->IsDeviceAdapter(device))
{
throw vtkm::cont::ErrorControlInternal("Device Adapter Mismatch");
throw vtkm::cont::ErrorInternal("Device Adapter Mismatch");
}
}
};

@ -24,7 +24,7 @@
#include <vtkm/Types.h>
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <iterator>
#include <limits>
@ -65,7 +65,7 @@ public:
#ifndef VTKM_USE_64BIT_IDS
if (numberOfValues > (std::numeric_limits<vtkm::Id>::max)())
{
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Distance of iterators larger than maximum array size. "
"To support larger arrays, try turning on VTKM_USE_64BIT_IDS.");
}
@ -149,7 +149,7 @@ public:
#ifndef VTKM_USE_64BIT_IDS
if (numberOfValues > (std::numeric_limits<vtkm::Id>::max)())
{
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Distance of iterators larger than maximum array size. "
"To support larger arrays, try turning on VTKM_USE_64BIT_IDS.");
}
@ -181,6 +181,15 @@ public:
return *this->IteratorAt(index);
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
{
#if ! (defined(VTKM_MSVC) && defined(VTKM_CUDA))
VTKM_ASSERT(false && "Attempted to write to constant array.");
#endif
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
IteratorT GetIteratorBegin() const {

@ -133,7 +133,7 @@ struct ConnectivityExplicitInternals
{
if (!this->IndexOffsetsValid)
{
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"Cannot build indices using the error device. Must be created previously.");
}
}

@ -20,7 +20,7 @@
#ifndef vtk_m_cont_internal_RuntimeDeviceTracker_h
#define vtk_m_cont_internal_RuntimeDeviceTracker_h
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/RuntimeDeviceInformation.h>
#include <vtkm/cont/DeviceAdapter.h>
@ -67,7 +67,7 @@ public:
template<typename DeviceAdapterTag>
VTKM_CONT
void ReportAllocationFailure(DeviceAdapterTag,
const vtkm::cont::ErrorControlBadAllocation&)
const vtkm::cont::ErrorBadAllocation&)
{
typedef vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag> Traits;
this->RuntimeValid[ Traits::GetId() ] = false;

@ -36,6 +36,7 @@ set(unit_tests
UnitTestArrayHandleCartesianProduct.cxx
UnitTestArrayHandleCompositeVector.cxx
UnitTestArrayHandleCounting.cxx
UnitTestArrayHandleDiscard.cxx
UnitTestArrayHandleImplicit.cxx
UnitTestArrayHandleIndex.cxx
UnitTestArrayHandlePermutation.cxx

@ -90,7 +90,7 @@ private:
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_POINTS);
VTKM_TEST_FAIL("Failed to get expected error for association mismatch.");
}
catch (vtkm::cont::ErrorControlBadValue error)
catch (vtkm::cont::ErrorBadValue error)
{
std::cout << "Caught expected error for association mismatch: "
<< std::endl << " " << error.GetMessage() << std::endl;

@ -30,7 +30,7 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleZip.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/RuntimeDeviceInformation.h>
#include <vtkm/cont/StorageBasic.h>
@ -423,7 +423,7 @@ private:
"or the width of vtkm::Id is not large enough to express all "
"array sizes.");
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
std::cout << "Got the expected error: " << error.GetMessage() << std::endl;
}

@ -28,6 +28,7 @@
#include <vtkm/cont/ArrayHandleConcatenate.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandleDiscard.h>
#include <vtkm/cont/ArrayHandleGroupVec.h>
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
#include <vtkm/cont/ArrayHandleImplicit.h>
@ -303,7 +304,7 @@ private:
{
vtkm::Id implicitLen = length - start_pos;
vtkm::Id basicLen = start_pos;
// make an implicit array
ValueHandleType implicit =
vtkm::cont::make_ArrayHandleImplicit<ValueType>(functor,
@ -796,6 +797,37 @@ private:
}
};
struct TestDiscardAsOutput
{
template< typename ValueType>
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
{
using DiscardHandleType = vtkm::cont::ArrayHandleDiscard<ValueType>;
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
typedef typename vtkm::cont::ArrayHandle<ValueType>::PortalControl Portal;
const vtkm::Id length = ARRAY_SIZE;
vtkm::cont::ArrayHandle<ValueType> input;
input.Allocate(length);
Portal inputPortal = input.GetPortalControl();
for(vtkm::Id i=0; i < length; ++i)
{
inputPortal.Set(i,ValueType(ComponentType(i)));
}
DiscardHandleType discard;
discard.Allocate(length);
vtkm::worklet::DispatcherMapField< PassThrough, DeviceAdapterTag > dispatcher;
dispatcher.Invoke(input, discard);
// No output to verify since none is stored in memory. Just checking that
// this compiles/runs without errors.
}
};
struct TestPermutationAsOutput
{
template< typename ValueType>
@ -1036,6 +1068,12 @@ private:
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsOutput(),
HandleTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleDiscard as Output" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestDiscardAsOutput(),
HandleTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleZip as Output" << std::endl;
vtkm::testing::Testing::TryTypes(

@ -331,7 +331,7 @@ void TestBadArrayLengths() {
vtkm::cont::make_ArrayHandleCompositeVector(longInArray,0, shortInArray,0);
VTKM_TEST_FAIL("Did not get exception like expected.");
}
catch (vtkm::cont::ErrorControlBadValue error)
catch (vtkm::cont::ErrorBadValue error)
{
std::cout << "Got expected error: " << std::endl
<< error.GetMessage() << std::endl;

@ -0,0 +1,143 @@
//============================================================================
// 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 2017 Sandia Corporation.
// Copyright 2017 UT-Battelle, LLC.
// Copyright 2017 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// 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/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleDiscard.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/serial/internal/ArrayManagerExecutionSerial.h>
#include <vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h>
#include <vtkm/cont/serial/internal/DeviceAdapterTagSerial.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/BinaryOperators.h>
#include <algorithm>
namespace UnitTestArrayHandleDiscardDetail
{
template <typename ValueType>
struct Test
{
static const vtkm::Id ARRAY_SIZE = 100;
static const vtkm::Id NUM_KEYS = 3;
using DeviceTag = vtkm::cont::DeviceAdapterTagSerial;
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>;
using Handle = vtkm::cont::ArrayHandle<ValueType>;
using DiscardHandle = vtkm::cont::ArrayHandleDiscard<ValueType>;
using OutputPortal = typename Handle::PortalControl;
using ReduceOp = vtkm::Add;
// Test discard arrays by using the ReduceByKey algorithm. Two regular arrays
// handles are provided as inputs, but the keys_output array is a discard
// array handle. The values_output array should still be populated correctly.
void TestReduceByKey()
{
// The reduction operator:
ReduceOp op;
// Prepare inputs / reference data:
ValueType keyData[ARRAY_SIZE];
ValueType valueData[ARRAY_SIZE];
ValueType refData[NUM_KEYS];
std::fill(refData, refData + NUM_KEYS, ValueType(0));
for (vtkm::Id i = 0; i < ARRAY_SIZE; ++i)
{
const vtkm::Id key = i % NUM_KEYS;
keyData[i] = static_cast<ValueType>(key);
valueData[i] = static_cast<ValueType>(i * 2);
refData[key] = op(refData[key], valueData[i]);
}
// Prepare array handles:
Handle keys = vtkm::cont::make_ArrayHandle(keyData, ARRAY_SIZE);
Handle values = vtkm::cont::make_ArrayHandle(valueData, ARRAY_SIZE);
DiscardHandle output_keys;
Handle output_values;
Algorithm::SortByKey(keys, values);
Algorithm::ReduceByKey(keys, values, output_keys, output_values, op);
OutputPortal outputs = output_values.GetPortalControl();
VTKM_TEST_ASSERT(outputs.GetNumberOfValues() == NUM_KEYS,
"Unexpected number of output values from ReduceByKey.");
for (vtkm::Id i = 0; i < NUM_KEYS; ++i)
{
VTKM_TEST_ASSERT(outputs.Get(i) == refData[i],
"Unexpected output value after ReduceByKey.");
}
}
void TestPrepareExceptions()
{
DiscardHandle handle;
handle.Allocate(50);
try
{
handle.PrepareForInput(DeviceTag());
}
catch (vtkm::cont::ErrorBadValue exp)
{
// Expected failure.
}
try
{
handle.PrepareForInPlace(DeviceTag());
}
catch (vtkm::cont::ErrorBadValue exp)
{
// Expected failure.
}
// Shouldn't fail:
handle.PrepareForOutput(ARRAY_SIZE, DeviceTag());
}
void operator()()
{
TestReduceByKey();
TestPrepareExceptions();
}
};
void TestArrayHandleDiscard()
{
Test<vtkm::UInt8>()();
Test<vtkm::Int16>()();
Test<vtkm::Int32>()();
Test<vtkm::Int64>()();
Test<vtkm::Float32>()();
Test<vtkm::Float64>()();
}
} // end namespace UnitTestArrayHandleDiscardDetail
int UnitTestArrayHandleDiscard(int, char *[])
{
using namespace UnitTestArrayHandleDiscardDetail;
return vtkm::cont::testing::Testing::Run(TestArrayHandleDiscard);
}

@ -23,6 +23,7 @@
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/ExplicitTestData.h>
#include <vector>
@ -50,42 +51,63 @@ void ValidateDataSet(const vtkm::cont::DataSet &ds,
vtkm::Id numCells,
const vtkm::Bounds &bounds)
{
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Make sure bounds are correct.
vtkm::Bounds computedBounds =
ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, computedBounds),
"Bounds of coordinates do not match");
// test various field-getting methods and associations
try
{
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET.");
}
try
{
ds.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET.");
}
//Make sure bounds are correct.
vtkm::Bounds computedBounds =
ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, computedBounds),
"Bounds of coordinates do not match");
}
template <typename T>
std::vector<T>
createVec(std::size_t n, const T *data)
{
std::vector<T> vec(n);
for (std::size_t i = 0; i < n; i++)
vec[i] = data[i];
return vec;
std::vector<T> vec(n);
for (std::size_t i = 0; i < n; i++)
{
vec[i] = data[i];
}
return vec;
}
template <typename T>
vtkm::cont::ArrayHandle<T>
createAH(std::size_t n, const T *data)
{
vtkm::cont::ArrayHandle<T> arr;
DFA::Copy(vtkm::cont::make_ArrayHandle(data, static_cast<vtkm::Id>(n)), arr);
return arr;
vtkm::cont::ArrayHandle<T> arr;
DFA::Copy(vtkm::cont::make_ArrayHandle(data, static_cast<vtkm::Id>(n)), arr);
return arr;
}
template <typename T>
@ -97,42 +119,63 @@ CreateDataSetArr(bool useSeparatedCoords,
const vtkm::IdComponent *indices,
const vtkm::UInt8 *shape)
{
vtkm::cont::DataSetBuilderExplicit dsb;
if (useSeparatedCoords)
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetFieldAdd dsf;
vtkm::cont::DataSetBuilderExplicit dsb;
if (useSeparatedCoords)
{
std::vector<T> xvals(numPoints), yvals(numPoints), zvals(numPoints);
std::vector<T> varP(numPoints), varC(numCells);
for (std::size_t i = 0; i < numPoints; i++)
{
std::vector<T> xvals(numPoints), yvals(numPoints), zvals(numPoints);
for (std::size_t i = 0; i < numPoints; i++)
{
xvals[i] = coords[i*3 + 0];
yvals[i] = coords[i*3 + 1];
zvals[i] = coords[i*3 + 2];
}
vtkm::cont::ArrayHandle<T> X,Y,Z;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), X);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Y);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Z);
return dsb.Create(X,Y,Z,
createAH(numCells, shape),
createAH(numCells, indices),
createAH(numConn, conn));
xvals[i] = coords[i*3 + 0];
yvals[i] = coords[i*3 + 1];
zvals[i] = coords[i*3 + 2];
varP[i] = static_cast<T>(i*1.1f);
}
else
for (std::size_t i = 0; i < numCells; i++)
{
std::vector<vtkm::Vec<T,3> > tmp(numPoints);
for (std::size_t i = 0; i < numPoints; i++)
{
tmp[i][0] = coords[i*3 + 0];
tmp[i][1] = coords[i*3 + 1];
tmp[i][2] = coords[i*3 + 2];
}
vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > pts;
DFA::Copy(vtkm::cont::make_ArrayHandle(tmp), pts);
return dsb.Create(pts,
createAH(numCells, shape),
createAH(numCells, indices),
createAH(numConn, conn));
varC[i] = static_cast<T>(i*1.1f);
}
vtkm::cont::ArrayHandle<T> X,Y,Z,P,C;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), X);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Y);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Z);
DFA::Copy(vtkm::cont::make_ArrayHandle(varP), P);
DFA::Copy(vtkm::cont::make_ArrayHandle(varC), C);
dataSet = dsb.Create(X,Y,Z,
createAH(numCells, shape),
createAH(numCells, indices),
createAH(numConn, conn));
dsf.AddPointField(dataSet, "pointvar", P);
dsf.AddCellField(dataSet, "cellvar", C);
return dataSet;
}
else
{
std::vector<vtkm::Vec<T,3> > tmp(numPoints);
std::vector<vtkm::Vec<T,1> > varP(numPoints), varC(numCells);
for (std::size_t i = 0; i < numPoints; i++)
{
tmp[i][0] = coords[i*3 + 0];
tmp[i][1] = coords[i*3 + 1];
tmp[i][2] = coords[i*3 + 2];
varP[i][0] = static_cast<T>(i*1.1f);
}
for (std::size_t i = 0; i < numCells; i++)
{
varC[i][0] = static_cast<T>(i*1.1f);
}
vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > pts;
DFA::Copy(vtkm::cont::make_ArrayHandle(tmp), pts);
dataSet = dsb.Create(pts,
createAH(numCells, shape),
createAH(numCells, indices),
createAH(numConn, conn));
dsf.AddPointField(dataSet, "pointvar", varP);
dsf.AddCellField(dataSet, "cellvar", varC);
return dataSet;
}
}
template <typename T>
@ -144,36 +187,55 @@ CreateDataSetVec(bool useSeparatedCoords,
const vtkm::IdComponent *indices,
const vtkm::UInt8 *shape)
{
vtkm::cont::DataSetBuilderExplicit dsb;
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetFieldAdd dsf;
vtkm::cont::DataSetBuilderExplicit dsb;
if (useSeparatedCoords)
if (useSeparatedCoords)
{
std::vector<T> X(numPoints), Y(numPoints), Z(numPoints), varP(numPoints), varC(numCells);
for (std::size_t i = 0; i < numPoints; i++)
{
std::vector<T> X(numPoints), Y(numPoints), Z(numPoints);
for (std::size_t i = 0; i < numPoints; i++)
{
X[i] = coords[i*3 + 0];
Y[i] = coords[i*3 + 1];
Z[i] = coords[i*3 + 2];
}
return dsb.Create(X,Y,Z,
createVec(numCells, shape),
createVec(numCells, indices),
createVec(numConn, conn));
X[i] = coords[i*3 + 0];
Y[i] = coords[i*3 + 1];
Z[i] = coords[i*3 + 2];
varP[i] = static_cast<T>(i*1.1f);
}
else
for (std::size_t i = 0; i < numCells; i++)
{
std::vector<vtkm::Vec<T,3> > pts(numPoints);
for (std::size_t i = 0; i < numPoints; i++)
{
pts[i][0] = coords[i*3 + 0];
pts[i][1] = coords[i*3 + 1];
pts[i][2] = coords[i*3 + 2];
}
return dsb.Create(pts,
createVec(numCells, shape),
createVec(numCells, indices),
createVec(numConn, conn));
varC[i] = static_cast<T>(i*1.1f);
}
dataSet = dsb.Create(X,Y,Z,
createVec(numCells, shape),
createVec(numCells, indices),
createVec(numConn, conn));
dsf.AddPointField(dataSet, "pointvar", varP);
dsf.AddCellField(dataSet, "cellvar", varC);
return dataSet;
}
else
{
std::vector<vtkm::Vec<T,3> > pts(numPoints);
std::vector<vtkm::Vec<T,1> > varP(numPoints), varC(numCells);
for (std::size_t i = 0; i < numPoints; i++)
{
pts[i][0] = coords[i*3 + 0];
pts[i][1] = coords[i*3 + 1];
pts[i][2] = coords[i*3 + 2];
varP[i][0] = static_cast<T>(i*1.1f);
}
for (std::size_t i = 0; i < numCells; i++)
{
varC[i][0] = static_cast<T>(i*1.1f);
}
dataSet = dsb.Create(pts,
createVec(numCells, shape),
createVec(numCells, indices),
createVec(numConn, conn));
dsf.AddPointField(dataSet, "pointvar", varP);
dsf.AddCellField(dataSet, "cellvar", varC);
return dataSet;
}
}
#define TEST_DATA(num) \
@ -194,40 +256,40 @@ CreateDataSetVec(bool useSeparatedCoords,
void
TestDataSetBuilderExplicit()
{
vtkm::cont::DataSetBuilderExplicit dsb;
vtkm::cont::DataSet ds;
vtkm::Bounds bounds;
vtkm::cont::DataSetBuilderExplicit dsb;
vtkm::cont::DataSet ds;
vtkm::Bounds bounds;
//Iterate over organization of coordinates.
for (int i = 0; i < 2; i++)
{
//Test ExplicitData0
bounds = ComputeBounds(TEST_BOUNDS(0));
ds = CreateDataSetArr(i==0,TEST_DATA(0));
ValidateDataSet(ds, TEST_NUMS(0), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(0));
ValidateDataSet(ds, TEST_NUMS(0), bounds);
//Iterate over organization of coordinates.
for (int i = 0; i < 2; i++)
{
//Test ExplicitData0
bounds = ComputeBounds(TEST_BOUNDS(0));
ds = CreateDataSetArr(i==0,TEST_DATA(0));
ValidateDataSet(ds, TEST_NUMS(0), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(0));
ValidateDataSet(ds, TEST_NUMS(0), bounds);
//Test ExplicitData1
bounds = ComputeBounds(TEST_BOUNDS(1));
ds = CreateDataSetArr(i==0,TEST_DATA(1));
ValidateDataSet(ds, TEST_NUMS(1), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(1));
ValidateDataSet(ds, TEST_NUMS(1), bounds);
//Test ExplicitData1
bounds = ComputeBounds(TEST_BOUNDS(1));
ds = CreateDataSetArr(i==0,TEST_DATA(1));
ValidateDataSet(ds, TEST_NUMS(1), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(1));
ValidateDataSet(ds, TEST_NUMS(1), bounds);
//Test ExplicitData2
bounds = ComputeBounds(TEST_BOUNDS(2));
ds = CreateDataSetArr(i==0,TEST_DATA(2));
ValidateDataSet(ds, TEST_NUMS(2), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(2));
ValidateDataSet(ds, TEST_NUMS(2), bounds);
}
//Test ExplicitData2
bounds = ComputeBounds(TEST_BOUNDS(2));
ds = CreateDataSetArr(i==0,TEST_DATA(2));
ValidateDataSet(ds, TEST_NUMS(2), bounds);
ds = CreateDataSetVec(i==0, TEST_DATA(2));
ValidateDataSet(ds, TEST_NUMS(2), bounds);
}
}
} // namespace DataSetBuilderExplicitNamespace
int UnitTestDataSetBuilderExplicit(int, char *[])
{
using namespace DataSetBuilderExplicitNamespace;
return vtkm::cont::testing::Testing::Run(TestDataSetBuilderExplicit);
using namespace DataSetBuilderExplicitNamespace;
return vtkm::cont::testing::Testing::Run(TestDataSetBuilderExplicit);
}

@ -24,7 +24,7 @@
#include <vtkm/cont/DataSetBuilderRectilinear.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <ctime>
@ -43,36 +43,55 @@ void ValidateDataSet(const vtkm::cont::DataSet &ds,
vtkm::Id numPoints, vtkm::Id numCells,
const vtkm::Bounds &bounds)
{
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Make sure the bounds are correct.
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, res),
"Bounds of coordinates do not match");
if (dim == 2)
{
vtkm::cont::CellSetStructured<2> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
}
else if (dim == 3)
{
vtkm::cont::CellSetStructured<3> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
}
// test various field-getting methods and associations
try
{
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET.");
}
try
{
ds.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET.");
}
//Make sure the bounds are correct.
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, res),
"Bounds of coordinates do not match");
if (dim == 2)
{
vtkm::cont::CellSetStructured<2> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
}
else if (dim == 3)
{
vtkm::cont::CellSetStructured<3> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
}
}
template <typename T>
@ -108,6 +127,7 @@ RectilinearTests()
vtkm::cont::DataSetBuilderRectilinear dataSetBuilder;
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetFieldAdd dsf;
std::uniform_int_distribution<vtkm::Id> randomDim(2,MAX_DIM_SIZE);
std::uniform_int_distribution<vtkm::IdComponent> randomFill(0,NUM_FILL_METHODS-1);
@ -142,18 +162,41 @@ RectilinearTests()
std::cout << "1D cases" << std::endl;
numPoints = dimensions[0];
numCells = dimensions[0]-1;
std::vector<T> varP1D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP1D[i] = static_cast<T>(i*1.1f);
}
std::vector<T> varC1D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC1D[i] = static_cast<T>(i*1.1f);
}
bounds.X = vtkm::Range(xCoordinates.front(), xCoordinates.back());
std::cout << " Create with std::vector" << std::endl;
dataSet = dataSetBuilder.Create(xCoordinates);
dsf.AddPointField(dataSet, "pointvar", varP1D);
dsf.AddCellField(dataSet, "cellvar", varC1D);
ValidateDataSet(dataSet, 1, numPoints, numCells, bounds);
std::cout << "2D cases" << std::endl;
numPoints = dimensions[0]*dimensions[1];
numCells = (dimensions[0]-1)*(dimensions[1]-1);
std::vector<T> varP2D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP2D[i] = static_cast<T>(i*1.1f);
}
std::vector<T> varC2D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC2D[i] = static_cast<T>(i*1.1f);
}
bounds.Y = vtkm::Range(yCoordinates.front(), yCoordinates.back());
std::cout << " Create with std::vector" << std::endl;
dataSet = dataSetBuilder.Create(xCoordinates, yCoordinates);
dsf.AddPointField(dataSet, "pointvar", varP2D);
dsf.AddCellField(dataSet, "cellvar", varC2D);
ValidateDataSet(dataSet, 2, numPoints, numCells, bounds);
std::cout << " Create with C array" << std::endl;
@ -161,20 +204,36 @@ RectilinearTests()
dimensions[1],
&xCoordinates.front(),
&yCoordinates.front());
dsf.AddPointField(dataSet, "pointvar", &varP2D.front(), numPoints);
dsf.AddCellField(dataSet, "cellvar", &varC2D.front(), numCells);
ValidateDataSet(dataSet, 2, numPoints, numCells, bounds);
std::cout << " Create with ArrayHandle" << std::endl;
dataSet = dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates),
vtkm::cont::make_ArrayHandle(yCoordinates));
dsf.AddPointField(dataSet, "pointvar", vtkm::cont::make_ArrayHandle(varP2D));
dsf.AddCellField(dataSet, "cellvar", vtkm::cont::make_ArrayHandle(varC2D));
ValidateDataSet(dataSet, 2, numPoints, numCells, bounds);
std::cout << "3D cases" << std::endl;
numPoints *= dimensions[2];
numCells *= dimensions[2]-1;
std::vector<T> varP3D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP3D[i] = static_cast<T>(i*1.1f);;
}
std::vector<T> varC3D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC3D[i] = static_cast<T>(i*1.1f);
}
bounds.Z = vtkm::Range(zCoordinates.front(), zCoordinates.back());
std::cout << " Create with std::vector" << std::endl;
dataSet = dataSetBuilder.Create(xCoordinates, yCoordinates, zCoordinates);
dsf.AddPointField(dataSet, "pointvar", varP3D);
dsf.AddCellField(dataSet, "cellvar", varC3D);
ValidateDataSet(dataSet, 3, numPoints, numCells, bounds);
std::cout << " Create with C array" << std::endl;
@ -184,12 +243,16 @@ RectilinearTests()
&xCoordinates.front(),
&yCoordinates.front(),
&zCoordinates.front());
dsf.AddPointField(dataSet, "pointvar", vtkm::cont::make_ArrayHandle(varP3D));
dsf.AddCellField(dataSet, "cellvar", vtkm::cont::make_ArrayHandle(varC3D));
ValidateDataSet(dataSet, 3, numPoints, numCells, bounds);
std::cout << " Create with ArrayHandle" << std::endl;
dataSet = dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates),
vtkm::cont::make_ArrayHandle(yCoordinates),
vtkm::cont::make_ArrayHandle(zCoordinates));
dsf.AddPointField(dataSet, "pointvar", vtkm::cont::make_ArrayHandle(varP3D));
dsf.AddCellField(dataSet, "cellvar", vtkm::cont::make_ArrayHandle(varC3D));
ValidateDataSet(dataSet, 3, numPoints, numCells, bounds);
}
}

@ -25,7 +25,6 @@
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <time.h>
@ -44,44 +43,62 @@ void ValidateDataSet(const vtkm::cont::DataSet &ds,
vtkm::Id numPoints, vtkm::Id numCells,
vtkm::Bounds bounds)
{
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Wrong number of cell sets.");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2,
"Wrong number of fields.");
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems.");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints,
"Wrong number of coordinates.");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells,
"Wrong number of cells.");
//Make sure bounds are correct.
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, res),
"Bounds of coordinates do not match");
// test various field-getting methods and associations
try
{
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET.");
}
if (dim == 1)
{
vtkm::cont::CellSetStructured<1> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_LINE, "Wrong element type");
}
else if (dim == 2)
{
vtkm::cont::CellSetStructured<2> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
}
else if (dim == 3)
{
vtkm::cont::CellSetStructured<3> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
}
try
{
ds.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET.");
}
//Make sure bounds are correct.
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds(DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(bounds, res),
"Bounds of coordinates do not match");
if (dim == 1)
{
vtkm::cont::CellSetStructured<1> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_LINE, "Wrong element type");
}
else if (dim == 2)
{
vtkm::cont::CellSetStructured<2> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
}
else if (dim == 3)
{
vtkm::cont::CellSetStructured<3> cellSet;
ds.GetCellSet(0).CopyTo(cellSet);
vtkm::IdComponent shape = cellSet.GetCellShape();
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
}
}
template <typename T>
@ -130,6 +147,7 @@ UniformTests()
vtkm::cont::DataSetBuilderUniform dataSetBuilder;
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetFieldAdd dsf;
std::uniform_int_distribution<vtkm::Id> randomDim(2, MAX_DIM_SIZE);
std::uniform_int_distribution<vtkm::IdComponent> randomFill(0, NUM_FILL_METHODS-1);
@ -170,16 +188,40 @@ UniformTests()
std::cout << "3D case" << std::endl;
vtkm::Id numPoints = dimensions[0]*dimensions[1]*dimensions[2];
vtkm::Id numCells = (dimensions[0]-1)*(dimensions[1]-1)*(dimensions[2]-1);
std::vector<T> varP3D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP3D[i] = static_cast<T>(i*1.1f);
}
std::vector<T> varC3D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC3D[i] = static_cast<T>(i*1.1f);
}
dataSet = dataSetBuilder.Create(dimensions, origin, spacing);
dsf.AddPointField(dataSet, "pointvar", varP3D);
dsf.AddCellField(dataSet, "cellvar", varC3D);
ValidateDataSet(dataSet, 3, numPoints, numCells, bounds);
std::cout << "2D case" << std::endl;
numPoints = dimensions[0]*dimensions[1];
numCells = (dimensions[0]-1)*(dimensions[1]-1);
bounds.Z = vtkm::Range(0, 0);
std::vector<T> varP2D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP2D[i] = static_cast<T>(i*1.1f);
}
std::vector<T> varC2D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC2D[i] = static_cast<T>(i*1.1f);
}
dataSet = dataSetBuilder.Create(vtkm::Id2(dimensions[0], dimensions[1]),
vtkm::Vec<T,2>(origin[0], origin[1]),
vtkm::Vec<T,2>(spacing[0], spacing[1]));
dsf.AddPointField(dataSet, "pointvar", varP2D);
dsf.AddCellField(dataSet, "cellvar", varC2D);
ValidateDataSet(dataSet, 2, numPoints, numCells, bounds);
std::cout << "1D case" <<std::endl;
@ -187,7 +229,19 @@ UniformTests()
numCells = dimensions[0]-1;
bounds.Y = vtkm::Range(0, 0);
bounds.Z = vtkm::Range(0, 0);
std::vector<T> varP1D(static_cast<unsigned long>(numPoints));
for (unsigned long i = 0; i < static_cast<unsigned long>(numPoints); i++)
{
varP1D[i] = static_cast<T>(i*1.1f);
}
std::vector<T> varC1D(static_cast<unsigned long>(numCells));
for (unsigned long i = 0; i < static_cast<unsigned long>(numCells); i++)
{
varC1D[i] = static_cast<T>(i*1.1f);
}
dataSet = dataSetBuilder.Create(dimensions[0], origin[0], spacing[0]);
dsf.AddPointField(dataSet, "pointvar", varP1D);
dsf.AddCellField(dataSet, "cellvar", varC1D);
ValidateDataSet(dataSet, 1, numPoints, numCells, bounds);
}
}

@ -263,7 +263,7 @@ void TryUnusualType()
CheckDynamicArray(array, 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type.");
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
std::cout << " Caught exception for unrecognized type." << std::endl;
}
@ -285,7 +285,7 @@ void TryUnusualStorage()
CheckDynamicArray(array, 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
std::cout << " Caught exception for unrecognized storage." << std::endl;
}
@ -306,7 +306,7 @@ void TryUnusualTypeAndStorage()
VTKM_TEST_FAIL(
"CastAndCall failed to error for unrecognized type/storage.");
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
std::cout << " Caught exception for unrecognized type/storage."
<< std::endl;
@ -317,7 +317,7 @@ void TryUnusualTypeAndStorage()
CheckDynamicArray(array.ResetTypeList(TypeListTagString()), 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
std::cout << " Caught exception for unrecognized storage." << std::endl;
}
@ -327,7 +327,7 @@ void TryUnusualTypeAndStorage()
CheckDynamicArray(array.ResetStorageList(StorageListTagUnusual()), 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type.");
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
std::cout << " Caught exception for unrecognized type." << std::endl;
}
@ -339,7 +339,7 @@ void TryUnusualTypeAndStorage()
StorageListTagUnusual()),
1);
}
catch (vtkm::cont::ErrorControlBadValue)
catch (vtkm::cont::ErrorBadValue)
{
VTKM_TEST_FAIL("ResetTypeAndStorageLists should have handled the custom type/storage.");
}

@ -182,7 +182,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorControlBadValue) {}
catch(vtkm::cont::ErrorBadValue) {}
}
void operator()()

@ -85,7 +85,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(false == true,
"Implicit Storage Allocate method didn't throw error.");
}
catch(vtkm::cont::ErrorControlBadValue e) {}
catch(vtkm::cont::ErrorBadValue e) {}
try
{
@ -93,7 +93,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorControlBadValue) {}
catch(vtkm::cont::ErrorBadValue) {}
//verify that calling ReleaseResources doesn't throw an exception
arrayStorage.ReleaseResources();

@ -337,18 +337,24 @@ public:
ValueType Get(vtkm::Id index) const {
return vtkm::exec::cuda::internal::load_through_texture<ValueType>::get( this->BeginIterator + index );
}
__device__
void Set(vtkm::Id vtkmNotUsed(index), ValueType vtkmNotUsed(value)) const {
}
#else
__host__
ValueType Get(vtkm::Id vtkmNotUsed(index) ) const {
return ValueType();
}
__host__
void Set(vtkm::Id vtkmNotUsed(index), ValueType vtkmNotUsed(value)) const {
#if ! (defined(VTKM_MSVC) && defined(VTKM_CUDA))
VTKM_ASSERT(true && "Cannot set to const array.");
#endif
__host__ __device__
void Set(vtkm::Id index, ValueType value) const {
*(this->BeginIterator + index) = value;
}
#endif
VTKM_EXEC_CONT
IteratorType GetIteratorBegin() const { return this->BeginIterator; }

@ -26,7 +26,7 @@
#include <vtkm/filter/internal/ResolveFieldTypeAndMap.h>
#include <vtkm/cont/Error.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>

@ -26,7 +26,7 @@
#include <vtkm/filter/internal/ResolveFieldTypeAndMap.h>
#include <vtkm/cont/Error.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>

@ -25,7 +25,7 @@
#include <vtkm/filter/internal/ResolveFieldTypeAndExecute.h>
#include <vtkm/cont/Error.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>

@ -21,7 +21,7 @@
#define vtkm_interop_cuda_internal_TransferToOpenGL_h
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
#include <vtkm/cont/cuda/internal/MakeThrustIterator.h>
@ -91,7 +91,7 @@ public:
cudaError_t cError =cudaGraphicsMapResources(1,&this->CudaResource);
if(cError != cudaSuccess)
{
throw vtkm::cont::ErrorControlBadAllocation(
throw vtkm::cont::ErrorBadAllocation(
"Could not allocate enough memory in CUDA for OpenGL interop.");
}
}

@ -53,5 +53,5 @@ endif()
vtkm_declare_headers(${headers})
vtkm_unit_tests(SOURCES ${unit_tests})
if(needs_rendering)
target_link_libraries(UnitTests_vtkm_interop_testing vtkm_rendering)
target_link_libraries(UnitTests_vtkm_interop_testing PRIVATE vtkm_rendering)
endif()

@ -77,13 +77,13 @@ private:
vtkm::interop::BufferState state(handle);
vtkm::interop::TransferToOpenGL(array, state, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
"Got an unexpected Out Of Memory error transferring to openGL");
}
catch (vtkm::cont::ErrorControlBadValue bvError)
catch (vtkm::cont::ErrorBadValue bvError)
{
std::cout << bvError.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
@ -100,13 +100,13 @@ private:
vtkm::interop::BufferState state(handle, type);
vtkm::interop::TransferToOpenGL(array, state, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorControlBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
"Got an unexpected Out Of Memory error transferring to openGL");
}
catch (vtkm::cont::ErrorControlBadValue bvError)
catch (vtkm::cont::ErrorBadValue bvError)
{
std::cout << bvError.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,

@ -26,8 +26,8 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
#include <vtkm/io/ErrorIO.h>
@ -371,7 +371,7 @@ private:
}
else
{
throw vtkm::cont::ErrorControlBadType(
throw vtkm::cont::ErrorBadType(
"Could not determine type to write out.");
}
@ -399,14 +399,14 @@ public:
}
else
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Selected invalid cell set index.");
}
}
if (dataSet.GetNumberOfCoordinateSystems() < 1)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"DataSet has no coordinate system, which is not supported by VTK file format.");
}

@ -20,7 +20,7 @@
#include <vtkm/rendering/AxisAnnotation.h>
#include <vtkm/cont/ErrorControlBadType.h>
#include <vtkm/cont/ErrorBadType.h>
namespace vtkm {
namespace rendering {

@ -156,6 +156,16 @@ else()
)
endif()
target_link_libraries(vtkm_rendering
PUBLIC vtkm_cont
PRIVATE ${VTKm_OPENGL_LIBRARIES}
${VTKm_BACKEND_LIBRARIES}
)
target_include_directories(vtkm_rendering
PRIVATE ${VTKm_OPENGL_INCLUDE_DIRS}
${VTKm_BACKEND_INCLUDE_DIRS}
)
# Subclasses need rendering library
vtkm_configure_component_Rendering()

@ -60,12 +60,12 @@ void CanvasEGL::Initialize()
this->Internals->Display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!(this->Internals->Display))
{
throw vtkm::cont::ErrorControlBadValue("Failed to get EGL display");
throw vtkm::cont::ErrorBadValue("Failed to get EGL display");
}
EGLint major, minor;
if (!(eglInitialize(this->Internals->Display, &major, &minor)))
{
throw vtkm::cont::ErrorControlBadValue("Failed to initialize EGL display");
throw vtkm::cont::ErrorBadValue("Failed to initialize EGL display");
}
const EGLint cfgAttrs[] =
@ -84,7 +84,7 @@ void CanvasEGL::Initialize()
if (!(eglChooseConfig(this->Internals->Display, cfgAttrs, &cfg, 1, &nCfgs)) ||
(nCfgs == 0))
{
throw vtkm::cont::ErrorControlBadValue("Failed to get EGL config");
throw vtkm::cont::ErrorBadValue("Failed to get EGL config");
}
const EGLint pbAttrs[] =
@ -98,21 +98,21 @@ void CanvasEGL::Initialize()
eglCreatePbufferSurface(this->Internals->Display, cfg, pbAttrs);
if (!this->Internals->Surface)
{
throw vtkm::cont::ErrorControlBadValue("Failed to create EGL PBuffer surface");
throw vtkm::cont::ErrorBadValue("Failed to create EGL PBuffer surface");
}
eglBindAPI(EGL_OPENGL_API);
this->Internals->Context =
eglCreateContext(this->Internals->Display, cfg, EGL_NO_CONTEXT, NULL);
if (!this->Internals->Context)
{
throw vtkm::cont::ErrorControlBadValue("Failed to create EGL context");
throw vtkm::cont::ErrorBadValue("Failed to create EGL context");
}
if (!(eglMakeCurrent(this->Internals->Display,
this->Internals->Surface,
this->Internals->Surface,
this->Internals->Context)))
{
throw vtkm::cont::ErrorControlBadValue("Failed to create EGL context current");
throw vtkm::cont::ErrorBadValue("Failed to create EGL context current");
}
}

@ -68,7 +68,7 @@ void CanvasOSMesa::Initialize()
if (!this->Internals->Context)
{
throw vtkm::cont::ErrorControlBadValue("OSMesa context creation failed.");
throw vtkm::cont::ErrorBadValue("OSMesa context creation failed.");
}
vtkm::Vec<vtkm::Float32,4> *colorBuffer =
this->GetColorBuffer().GetStorage().GetArray();
@ -78,7 +78,7 @@ void CanvasOSMesa::Initialize()
static_cast<GLsizei>(this->GetWidth()),
static_cast<GLsizei>(this->GetHeight())))
{
throw vtkm::cont::ErrorControlBadValue("OSMesa context activation failed.");
throw vtkm::cont::ErrorBadValue("OSMesa context activation failed.");
}
@ -110,7 +110,7 @@ void CanvasOSMesa::Finish()
static_cast<vtkm::Id>(w)!=this->GetWidth() ||
static_cast<vtkm::Id>(h)!=this->GetHeight())
{
throw vtkm::cont::ErrorControlBadValue("Wrong width/height in ZBuffer");
throw vtkm::cont::ErrorBadValue("Wrong width/height in ZBuffer");
}
vtkm::cont::ArrayHandle<vtkm::Float32>::PortalControl depthPortal =
this->GetDepthBuffer().GetPortalControl();

@ -310,7 +310,7 @@ void RenderTriangles(MapperGL &mapper,
msg = std::string(strInfoLog);
delete [] strInfoLog;
}
throw vtkm::cont::ErrorControlBadValue("Shader compile error:"+msg);
throw vtkm::cont::ErrorBadValue("Shader compile error:"+msg);
}
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
@ -333,7 +333,7 @@ void RenderTriangles(MapperGL &mapper,
msg = std::string(strInfoLog);
delete [] strInfoLog;
}
throw vtkm::cont::ErrorControlBadValue("Shader compile error:"+msg);
throw vtkm::cont::ErrorBadValue("Shader compile error:"+msg);
}
mapper.shader_programme = glCreateProgram();
@ -353,7 +353,7 @@ void RenderTriangles(MapperGL &mapper,
GLsizei len;
glGetProgramInfoLog(mapper.shader_programme, 2048, &len, log);
std::string msg = std::string("Shader program link failed: ")+std::string(log);
throw vtkm::cont::ErrorControlBadValue(msg);
throw vtkm::cont::ErrorBadValue(msg);
}
}
}
@ -471,7 +471,7 @@ void MapperGL::SetCanvas(vtkm::rendering::Canvas *c)
{
this->Canvas = dynamic_cast<vtkm::rendering::CanvasGL*>(c);
if (this->Canvas == NULL)
throw vtkm::cont::ErrorControlBadValue("Bad canvas type for MapperGL. Must be CanvasGL");
throw vtkm::cont::ErrorBadValue("Bad canvas type for MapperGL. Must be CanvasGL");
}
}

@ -90,7 +90,7 @@ void MapperRayTracer::SetCanvas(vtkm::rendering::Canvas *canvas)
this->Internals->Canvas = dynamic_cast<CanvasRayTracer*>(canvas);
if(this->Internals->Canvas == nullptr)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Ray Tracer: bad canvas type. Must be CanvasRayTracer");
}
}

@ -96,7 +96,7 @@ void MapperVolume::SetCanvas(vtkm::rendering::Canvas *canvas)
this->Internals->Canvas = dynamic_cast<CanvasRayTracer*>(canvas);
if(this->Internals->Canvas == nullptr)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Ray Tracer: bad canvas type. Must be CanvasRayTracer");
}
}

@ -553,12 +553,12 @@ public:
}
else
{
throw vtkm::cont::ErrorControlBadType("Unsupported cell type for trianglulation with CellSetSingleType");
throw vtkm::cont::ErrorBadType("Unsupported cell type for trianglulation with CellSetSingleType");
}
}
else
{
throw vtkm::cont::ErrorControlBadType("Unsupported cell set type for trianglulation");
throw vtkm::cont::ErrorBadType("Unsupported cell set type for trianglulation");
}
//get rid of any triagles we cannot see

@ -21,7 +21,7 @@
#define vtk_m_rendering_raytracing_Camera_h
#include <vtkm/VectorAnalysis.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/rendering/Camera.h>
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/raytracing/Ray.h>
@ -259,7 +259,7 @@ public:
{
if(height <= 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera height must be greater than zero.");
}
if(Height != height)
@ -281,7 +281,7 @@ public:
{
if(width <= 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera width must be greater than zero.");
}
if(this->Width != width)
@ -303,7 +303,7 @@ public:
{
if(zoom <= 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera zoom must be greater than zero.");
}
if(this->Zoom != zoom)
@ -324,12 +324,12 @@ public:
{
if(degrees <= 0)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera feild of view must be greater than zero.");
}
if(degrees > 180)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera feild of view must be less than 180.");
}
// fov is stored as a half angle
@ -421,13 +421,13 @@ public:
{
if(canvas == nullptr)
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Camera can not write to nullptr canvas");
}
if(this->Height != vtkm::Int32(canvas->GetHeight()) ||
this->Width != vtkm::Int32(canvas->GetWidth()))
{
throw vtkm::cont::ErrorControlBadValue("Camera: suface-view mismatched dims");
throw vtkm::cont::ErrorBadValue("Camera: suface-view mismatched dims");
}
vtkm::worklet::DispatcherMapField< SurfaceConverter >(
SurfaceConverter( this->Width,

@ -239,7 +239,7 @@ public:
{
bool isSupportedField = (scalarField->GetAssociation() == vtkm::cont::Field::ASSOC_POINTS ||
scalarField->GetAssociation() == vtkm::cont::Field::ASSOC_CELL_SET );
if(!isSupportedField) throw vtkm::cont::ErrorControlBadValue("Feild not accociated with cell set or points");
if(!isSupportedField) throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
bool isAssocPoints = scalarField->GetAssociation() == vtkm::cont::Field::ASSOC_POINTS;
vtkm::worklet::DispatcherMapField< CalculateNormals >( CalculateNormals(bvh.LeafNodes) )

@ -26,7 +26,7 @@
#include <iostream>
#include <stdio.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/rendering/ColorTable.h>
#include <vtkm/rendering/raytracing/Ray.h>
#include <vtkm/rendering/raytracing/Camera.h>
@ -1000,7 +1000,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
Rays.MaxDistance);
bool isSupportedField = (ScalarField->GetAssociation() == vtkm::cont::Field::ASSOC_POINTS ||
ScalarField->GetAssociation() == vtkm::cont::Field::ASSOC_CELL_SET );
if(!isSupportedField) throw vtkm::cont::ErrorControlBadValue("Feild not accociated with cell set or points");
if(!isSupportedField) throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
bool isAssocPoints = ScalarField->GetAssociation() == vtkm::cont::Field::ASSOC_POINTS;
if(IsUniformDataSet)
{
@ -1086,7 +1086,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
void SetSampleDistance(const vtkm::Float32 & distance)
{
if(distance <= 0.f)
throw vtkm::cont::ErrorControlBadValue("Sample distance must be positive.");
throw vtkm::cont::ErrorBadValue("Sample distance must be positive.");
SampleDistance = distance;
}

@ -365,7 +365,7 @@ struct Transport<
{
if (object.GetNumberOfValues() != inputDomain.GetInputRange())
{
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"Input array to worklet invocation the wrong size.");
}

Some files were not shown because too many files have changed in this diff Show More