merge from the latest

This commit is contained in:
Samuel Li 2017-04-14 14:00:16 -06:00
commit eaee6c3e4b
458 changed files with 31244 additions and 6272 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)

@ -39,9 +39,10 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
# The VTKm version number
set(VTKm_MAJOR_VERSION "@VTKm_MAJOR_VERSION@")
set(VTKm_MINOR_VERSION "@VTKm_MINOR_VERSION@")
set(VTKm_PATCH_VERSION "@VTKm_PATCH_VERSION@")
set(VTKm_VERSION_MAJOR "@VTKm_VERSION_MAJOR@")
set(VTKm_VERSION_MINOR "@VTKm_VERSION_MINOR@")
set(VTKm_VERSION_PATCH "@VTKm_VERSION_PATCH@")
set(VTKm_VERSION_FULL "@VTKm_VERSION_FULL@")
set(VTKm_VERSION "@VTKm_VERSION@")
# This is true when the package is still in the build directory (not installed)

@ -56,10 +56,8 @@ function(vtkm_configure_component_message message_text)
list(FIND VTKm_CONFIGURE_COMPONENT_MESSAGES "${message_text}" in_list)
if(in_list EQUAL -1)
message(STATUS "${message_text}")
set(VTKm_CONFIGURE_COMPONENT_MESSAGES
${VTKm_CONFIGURE_COMPONENT_MESSAGES}
${message_text}
CACHE INTERNAL "" FORCE)
set(VTKm_CONFIGURE_COMPONENT_MESSAGES "${VTKm_CONFIGURE_COMPONENT_MESSAGES} ${message_text}"
CACHE STRING "" FORCE)
endif()
endif()
endfunction(vtkm_configure_component_message)
@ -71,7 +69,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 +87,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()
@ -110,7 +112,7 @@ macro(vtkm_configure_component_Base)
vtkm_finish_configure_component(Base
DEPENDENT_VARIABLES VTKm_base_vtkm_target_FOUND
ADD_LIBRARIES vtkm
ADD_LIBRARIES vtkm vtkm_cont
)
endmacro()
@ -118,6 +120,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 +154,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 +171,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 +198,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 +210,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 +256,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 +268,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 +286,7 @@ macro(vtkm_configure_component_CUDA)
endif()
vtkm_finish_configure_component(CUDA
IS_BACKEND
DEPENDENT_VARIABLES
VTKm_ENABLE_CUDA
VTKm_Base_FOUND
@ -325,7 +340,7 @@ macro(vtkm_configure_component_CUDA)
#specify the property
set(VTKm_CUDA_Architecture "native" CACHE STRING "Which GPU Architecture(s) to compile for")
set_property(CACHE VTKm_CUDA_Architecture PROPERTY STRINGS native fermi kepler maxwell all)
set_property(CACHE VTKm_CUDA_Architecture PROPERTY STRINGS native fermi kepler maxwell pascal all)
#detect what the propery is set too
if(VTKm_CUDA_Architecture STREQUAL "native")
@ -338,8 +353,10 @@ macro(vtkm_configure_component_CUDA)
#run execute_process to do auto_detection
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(args "-ccbin" "${CMAKE_CXX_COMPILER}" "--run" "${VTKm_CMAKE_MODULE_PATH}/VTKmDetectCUDAVersion.cu")
else()
elseif(CUDA_HOST_COMPILER)
set(args "-ccbin" "${CUDA_HOST_COMPILER}" "--run" "${VTKm_CMAKE_MODULE_PATH}/VTKmDetectCUDAVersion.cu")
else()
set(args "--run" "${VTKm_CMAKE_MODULE_PATH}/VTKmDetectCUDAVersion.cu")
endif()
execute_process(
@ -347,6 +364,7 @@ macro(vtkm_configure_component_CUDA)
RESULT_VARIABLE ran_properly
OUTPUT_VARIABLE run_output
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(ran_properly EQUAL 0)
#find the position of the "--generate-code" output. With some compilers such as
#msvc we get compile output plus run output. So we need to strip out just the
@ -359,9 +377,7 @@ macro(vtkm_configure_component_CUDA)
"device type(s) for cuda[native]")
else()
set(VTKm_CUDA_Architecture "fermi")
vtkm_configure_component_message(
"Unable to run \"${CUDA_NVCC_EXECUTABLE}\" to autodetect GPU architecture.
Falling back to fermi, please manually specify if you want something else.")
vtkm_configure_component_message("Unable to run ${CUDA_NVCC_EXECUTABLE} to autodetect GPU architecture. Falling back to fermi, please manually specify if you want something else.")
endif()
endif()
endif()

@ -0,0 +1,99 @@
##============================================================================
## 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.
##============================================================================
# Used to determine the version for VTK-m source using "git describe", if git
# is found. On success sets the following variables in caller's scope:
# ${var_prefix}_VERSION
# ${var_prefix}_VERSION_MAJOR
# ${var_prefix}_VERSION_MINOR
# ${var_prefix}_VERSION_PATCH
# ${var_prefix}_VERSION_PATCH_EXTRA
# ${var_prefix}_VERSION_FULL
# ${var_prefix}_VERSION_IS_RELEASE is true, if patch-extra is empty.
#
# If git is not found, or git describe cannot be run successfully, then these
# variables are left unchanged and a status message is printed.
#
# Arguments are:
# source_dir : Source directory
# git_command : git executable
# var_prefix : prefix for variables e.g. "VTKm".
function(determine_version source_dir git_command var_prefix)
if ("$Format:$" STREQUAL "")
# We are in an exported tarball and should use the shipped version
# information. Just return here to avoid the warning message at the end of
# this function.
return ()
elseif (NOT VTKm_GIT_DESCRIBE)
if(EXISTS ${git_command})
execute_process(
COMMAND ${git_command} describe
WORKING_DIRECTORY ${source_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
else()
set(result 0)
set(output ${VTKm_GIT_DESCRIBE})
endif()
extract_version_components("${output}" tmp)
if(DEFINED tmp_VERSION)
message(STATUS "Determined Source Version : ${tmp_VERSION_FULL}")
if (NOT "${tmp_VERSION}" STREQUAL "${${var_prefix}_VERSION}")
message(WARNING
"Version from git (${tmp_VERSION}) disagrees with hard coded version (${${var_prefix}_VERSION}). Either update the git tags or version.txt.")
endif()
foreach(suffix VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH
VERSION_PATCH_EXTRA VERSION_FULL VERSION_IS_RELEASE)
set(${var_prefix}_${suffix} ${tmp_${suffix}} PARENT_SCOPE)
endforeach()
else()
message(STATUS
"Could not use git to determine source version, using version ${${var_prefix}_VERSION_FULL}")
endif()
endfunction()
# Extracts components from a version string. See determine_version() for usage.
function(extract_version_components version_string var_prefix)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)[-]*(.*)"
version_matches "${version_string}")
if(CMAKE_MATCH_0)
set(full ${CMAKE_MATCH_0})
set(major ${CMAKE_MATCH_1})
set(minor ${CMAKE_MATCH_2})
set(patch ${CMAKE_MATCH_3})
set(patch_extra ${CMAKE_MATCH_4})
set(${var_prefix}_VERSION "${major}.${minor}" PARENT_SCOPE)
set(${var_prefix}_VERSION_MAJOR ${major} PARENT_SCOPE)
set(${var_prefix}_VERSION_MINOR ${minor} PARENT_SCOPE)
set(${var_prefix}_VERSION_PATCH ${patch} PARENT_SCOPE)
set(${var_prefix}_VERSION_PATCH_EXTRA ${patch_extra} PARENT_SCOPE)
set(${var_prefix}_VERSION_FULL ${full} PARENT_SCOPE)
if("${major}.${minor}.${patch}" VERSION_EQUAL "${full}")
set(${var_prefix}_VERSION_IS_RELEASE TRUE PARENT_SCOPE)
else()
set(${var_prefix}_VERSION_IS_RELEASE FALSE PARENT_SCOPE)
endif()
endif()
endfunction()

@ -0,0 +1,79 @@
//=============================================================================
//
// 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 @EXPORT_MACRO_NAME@_EXPORT_H
#define @EXPORT_MACRO_NAME@_EXPORT_H
#if defined(_MSC_VER)
# if @EXPORT_IS_BUILT_STATIC@
/* This is a static component and has no need for exports
elf based static libraries are able to have hidden/default visibility
controls on symbols so we should propagate this information in that
use case
*/
# define @EXPORT_MACRO_NAME@_EXPORT_DEFINE
# define @EXPORT_MACRO_NAME@_IMPORT_DEFINE
# define @EXPORT_MACRO_NAME@_NO_EXPORT_DEFINE
# else
# define @EXPORT_MACRO_NAME@_EXPORT_DEFINE __declspec(dllexport)
# define @EXPORT_MACRO_NAME@_IMPORT_DEFINE __declspec(dllimport)
# define @EXPORT_MACRO_NAME@_NO_EXPORT_DEFINE
# endif
#else
# define @EXPORT_MACRO_NAME@_EXPORT_DEFINE __attribute__((visibility("default")))
# define @EXPORT_MACRO_NAME@_IMPORT_DEFINE __attribute__((visibility("default")))
# define @EXPORT_MACRO_NAME@_NO_EXPORT_DEFINE __attribute__((visibility("hidden")))
#endif
#ifndef @EXPORT_MACRO_NAME@_EXPORT
# if defined(@EXPORT_IMPORT_CONDITION@)
/* We are building this library */
# define @EXPORT_MACRO_NAME@_EXPORT @EXPORT_MACRO_NAME@_EXPORT_DEFINE
# else
/* We are using this library */
# define @EXPORT_MACRO_NAME@_EXPORT @EXPORT_MACRO_NAME@_IMPORT_DEFINE
# endif
#endif
#ifndef @EXPORT_MACRO_NAME@_TEMPLATE_EXPORT
# if defined(@EXPORT_IMPORT_CONDITION@) && defined(_MSC_VER)
/* Warning C4910 on windows state that extern explicit template can't be
labeled with __declspec(dllexport). So that is why we use a new custom
define. But when other modules ( e.g. rendering ) include this header
we need them to see that the extern template is actually being imported.
*/
/* We are building this library with MSVC */
# define @EXPORT_MACRO_NAME@_TEMPLATE_EXPORT
# elif defined(@EXPORT_IMPORT_CONDITION@)
/* We are building this library */
# define @EXPORT_MACRO_NAME@_TEMPLATE_EXPORT @EXPORT_MACRO_NAME@_EXPORT_DEFINE
# else
/* We are using this library */
# define @EXPORT_MACRO_NAME@_TEMPLATE_EXPORT @EXPORT_MACRO_NAME@_IMPORT_DEFINE
# endif
#endif
#ifndef @EXPORT_MACRO_NAME@_NO_EXPORT
#define @EXPORT_MACRO_NAME@_NO_EXPORT @EXPORT_MACRO_NAME@_NO_EXPORT_DEFINE
#endif
#endif

@ -19,7 +19,6 @@
##============================================================================
include(CMakeParseArguments)
include(GenerateExportHeader)
# Utility to build a kit name from the current directory.
function(vtkm_get_kit_name kitvar)
@ -110,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
)
@ -264,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})
@ -279,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})
@ -396,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})
@ -406,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})
@ -508,7 +518,7 @@ function(vtkm_benchmarks device_adapter)
set(is_cuda TRUE)
endif()
if(VTKm_ENABLE_BENCHMARKS AND VTKm_ENABLE_TESTING)
if(VTKm_ENABLE_BENCHMARKS)
string(REPLACE "VTKM_DEVICE_ADAPTER_" "" device_type ${device_adapter})
if(is_cuda)
@ -523,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()
@ -533,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})
@ -574,10 +588,13 @@ function(vtkm_wrap_sources_for_cuda cuda_source_list_var)
list(APPEND cuda_sources ${wrapped_file})
endforeach(source_file)
# Set original sources as header files (which they basically are) so that
# we can add them to the file list and they will show up in IDE but they will
# not be compiled separately.
set_source_files_properties(${original_sources}
PROPERTIES HEADER_FILE_ONLY TRUE
)
set(${cuda_source_list_var} ${cuda_sources} PARENT_SCOPE)
set(${cuda_source_list_var} ${cuda_sources} ${original_sources} PARENT_SCOPE)
endfunction(vtkm_wrap_sources_for_cuda)
# Add a VTK-m library. The name of the library will match the "kit" name
@ -586,13 +603,15 @@ endfunction(vtkm_wrap_sources_for_cuda)
# vtkm_library(
# [NAME <name>]
# SOURCES <source_list>
# [HEADERS <headers_list>]
# [CUDA]
# [WRAP_FOR_CUDA <source_list>]
# [LIBRARIES <dependent_library_list>]
# )
function(vtkm_library)
set(options CUDA)
set(oneValueArgs NAME)
set(multiValueArgs SOURCES WRAP_FOR_CUDA)
set(multiValueArgs SOURCES HEADERS WRAP_FOR_CUDA)
cmake_parse_arguments(VTKm_LIB
"${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}
@ -605,19 +624,42 @@ function(vtkm_library)
set(lib_name ${kit})
endif()
list(APPEND VTKm_LIB_SOURCES ${VTKm_LIB_HEADERS})
set_source_files_properties(${VTKm_LIB_HEADERS}
PROPERTIES HEADER_FILE_ONLY TRUE
)
if(VTKm_LIB_WRAP_FOR_CUDA)
if(VTKm_ENABLE_CUDA)
# If we have some sources marked as WRAP_FOR_CUDA and we support CUDA,
# then we need to turn on CDUA, wrap those sources, and add the wrapped
# code to the sources list.
set(VTKm_LIB_CUDA TRUE)
vtkm_wrap_sources_for_cuda(cuda_sources ${VTKm_LIB_WRAP_FOR_CUDA})
list(APPEND VTKm_LIB_SOURCES ${cuda_sources})
else()
# If we have some sources marked as WRAP_FOR_CUDA but we do not support
# CUDA, then just compile these sources normally by adding them to the
# sources list.
list(APPEND VTKm_LIB_SOURCES ${VTKm_LIB_WRAP_FOR_CUDA})
endif()
endif()
if(VTKm_LIB_CUDA)
vtkm_setup_nvcc_flags(old_nvcc_flags old_cxx_flags)
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)
endif()
cuda_add_library(${lib_name} ${VTKm_LIB_SOURCES} ${cuda_sources}
cuda_add_library(${lib_name} ${VTKm_LIB_SOURCES}
OPTIONS "${compile_options}")
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
@ -626,12 +668,11 @@ 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} )
target_link_libraries(${lib_name} ${VTKm_LIBRARIES})
target_link_libraries(${lib_name} PUBLIC vtkm)
target_link_libraries(${lib_name} PRIVATE
${VTKm_BACKEND_LIBRARIES}
${VTKm_LIB_LIBRARIES}
)
set(cxx_args ${VTKm_COMPILE_OPTIONS})
separate_arguments(cxx_args)
@ -657,15 +698,34 @@ function(vtkm_library)
)
endif(VTKm_EXTRA_COMPILER_WARNINGS)
generate_export_header(${lib_name})
#Now generate a header that holds the macros needed to easily export
#template classes. This
string(TOUPPER ${lib_name} BASE_NAME_UPPER)
set(EXPORT_MACRO_NAME "${BASE_NAME_UPPER}")
#generate_export_header creates the header in CMAKE_CURRENT_BINARY_DIR.
#The build expects it in the install directory.
file(COPY
${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_export.h
DESTINATION
${CMAKE_BINARY_DIR}/${VTKm_INSTALL_INCLUDE_DIR}/${dir_prefix}
)
set(EXPORT_IS_BUILT_STATIC 0)
get_target_property(is_static ${lib_name} TYPE)
if(${is_static} STREQUAL "STATIC_LIBRARY")
#If we are building statically set the define symbol
set(EXPORT_IS_BUILT_STATIC 1)
endif()
unset(is_static)
get_target_property(EXPORT_IMPORT_CONDITION ${lib_name} DEFINE_SYMBOL)
if(NOT EXPORT_IMPORT_CONDITION)
#set EXPORT_IMPORT_CONDITION to what the DEFINE_SYMBOL would be when
#building shared
set(EXPORT_IMPORT_CONDITION ${lib_name}_EXPORTS)
endif()
configure_file(
${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
${CMAKE_BINARY_DIR}/${VTKm_INSTALL_INCLUDE_DIR}/${dir_prefix}/${lib_name}_export.h
@ONLY)
unset(EXPORT_MACRO_NAME)
unset(EXPORT_IS_BUILT_STATIC)
unset(EXPORT_IMPORT_CONDITION)
install(TARGETS ${lib_name}
EXPORT ${VTKm_EXPORT_NAME}
@ -675,6 +735,7 @@ function(vtkm_library)
)
vtkm_install_headers("${dir_prefix}"
${CMAKE_BINARY_DIR}/${VTKm_INSTALL_INCLUDE_DIR}/${dir_prefix}/${lib_name}_export.h
${VTKm_LIB_HEADERS}
)
endfunction(vtkm_library)

@ -27,11 +27,6 @@ cmake_minimum_required(VERSION 3.3)
project (VTKm)
set(VTKm_MAJOR_VERSION 1)
set(VTKm_MINOR_VERSION 1)
set(VTKm_PATCH_VERSION 0)
set(VTKm_VERSION "${VTKm_MAJOR_VERSION}.${VTKm_MINOR_VERSION}.${VTKm_PATCH_VERSION}")
set(VTKm_INSTALL_INCLUDE_DIR "include")
set(VTKm_INSTALL_CONFIG_DIR "lib")
set(VTKm_INSTALL_LIB_DIR "lib")
@ -43,14 +38,18 @@ set(VTKm_EXPORT_NAME "VTKmTargets")
set(VTKm_CMAKE_MODULE_PATH ${VTKm_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
# Determine VTK-m version
include(Utilities/Git/Git.cmake)
include(VTKmDetermineVersion)
# Load hardcoded version in case this is not a Git repository
file(STRINGS version.txt version_txt)
extract_version_components("${version_txt}" "VTKm")
# Get the version from git if we can
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
@ -60,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
@ -104,6 +108,18 @@ option(VTKm_USE_DOUBLE_PRECISION
)
option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON)
if (VTKm_ENABLE_CUDA)
option(VTKm_USE_UNIFIED_MEMORY
"Use CUDA unified memory"
OFF
)
endif (VTKm_ENABLE_CUDA)
if (VTKm_USE_UNIFIED_MEMORY)
set(CMAKE_CXX_FLAGS "-DVTKM_USE_UNIFIED_MEMORY ${CMAKE_CXX_FLAGS}")
endif()
option(BUILD_SHARED_LIBS "Build VTK-m with shared libraries" ON)
set(VTKm_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
@ -297,6 +313,7 @@ install(
${VTKm_SOURCE_DIR}/CMake/VTKmConfigureComponents.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmCompilerOptimizations.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmDetectCUDAVersion.cu
${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
)
@ -313,9 +330,9 @@ install(EXPORT ${VTKm_EXPORT_NAME}
set(CPACK_PACKAGE_DESCRIPTION_FILE ${VTKm_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The VTKm Toolkit")
set(CPACK_PACKAGE_NAME "VTKm")
set(CPACK_PACKAGE_VERSION_MAJOR ${VTKm_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_PATCH_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${VTKm_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME "VTKm-${VTKm_VERSION}")
set(CPACK_RESOURCE_FILE_LICENSE ${VTKm_SOURCE_DIR}/LICENSE.txt)
set(CPACK_RESOURCE_FILE_README ${VTKm_SOURCE_DIR}/README.md)

@ -72,6 +72,9 @@ licenses.
- - - - - - - - - - - - - - - - - - - - - - - - do not remove this line
CMake/FindTBB.cmake
CMake/FindGLEW.cmake
Utilities
vtkm/cont/tbb/internal/parallel_sort.h
vtkm/testing/OptionParser.h
vtkm/internal/brigand.hpp
vtkm/internal/brigand.hpp
version.txt

1
Utilities/Git/.gitattributes vendored Normal file

@ -0,0 +1 @@
GitInfo crlf=input

2
Utilities/Git/.gitignore vendored Normal file

@ -0,0 +1,2 @@
# Generated in source tree by GitInfo script
GitInfo.cmake

31
Utilities/Git/Git.cmake Normal file

@ -0,0 +1,31 @@
#=============================================================================
# Copyright 2011 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Check for a hint left by the 'GitInfo' script.
if(NOT GIT_EXECUTABLE)
get_filename_component(_Git_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
include(${_Git_DIR}/GitInfo.cmake OPTIONAL)
if(GitInfo_GIT_EXECUTABLE)
if(EXISTS "${GitInfo_GIT_EXECUTABLE}")
set(GIT_EXECUTABLE "${GitInfo_GIT_EXECUTABLE}")
elseif(EXISTS "${GitInfo_GIT_EXECUTABLE}.exe")
set(GIT_EXECUTABLE "${GitInfo_GIT_EXECUTABLE}.exe")
endif()
endif()
endif()
# Find Git.
find_package(Git)

57
Utilities/Git/GitInfo Normal file

@ -0,0 +1,57 @@
#!/usr/bin/env bash
#=============================================================================
# Copyright 2011 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Path conversion function.
case "$(uname)" in
*CYGWIN*)
native_path() {
cygpath -m "$1"
}
;;
*MINGW*)
native_path() {
cmd //c echo "$1" | sed 's/^"//;s/"$//'
}
;;
*)
native_path() {
echo "$1"
}
;;
esac
# Compute native path to "git" executable.
if git="$(type -p git)"; then
git="$(native_path "${git}")"
else
git=''
fi
# Compute native path to ".git" dir.
if dir="$(git rev-parse --git-dir)"; then
dir="$(cd "$dir"; pwd)"
git_dir="$(native_path "${dir}")"
else
git_dir=''
fi
# Store the values in a CMake file next to this script.
echo >"${BASH_SOURCE%/*}/GitInfo.cmake" '# Generated by GitInfo
set(GitInfo 1)
set(GitInfo_GIT_EXECUTABLE "'"$git"'")
set(GitInfo_GIT_DIR "'"$git_dir"'")
'

202
Utilities/Git/LICENSE Normal file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

5
Utilities/Git/NOTICE Normal file

@ -0,0 +1,5 @@
Git Support Scripts
Copyright 2011 Kitware, Inc.
This product includes software developed at Kitware, Inc.
(http://www.kitware.com/).

3
data/tornado.vec Normal file

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

@ -24,6 +24,7 @@
set(CMAKE_PREFIX_PATH ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR})
add_subdirectory(clipping)
add_subdirectory(contour_tree)
add_subdirectory(demo)
add_subdirectory(dynamic_dispatcher)
add_subdirectory(hello_world)
@ -34,4 +35,5 @@ add_subdirectory(tetrahedra)
if(VTKm_ENABLE_RENDERING)
add_subdirectory(rendering)
endif()
add_subdirectory(unified_memory)

@ -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")

@ -0,0 +1,75 @@
##=============================================================================
##
## 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 2015 Sandia Corporation.
## Copyright 2015 UT-Battelle, LLC.
## Copyright 2015 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.
##
##=============================================================================
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET
OPTIONAL_COMPONENTS Serial CUDA TBB
)
add_executable(ContourTreeMesh2D_SERIAL ContourTreeMesh2D.cxx)
target_include_directories(ContourTreeMesh2D_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh2D_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh2D_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(ContourTreeMesh3D_SERIAL ContourTreeMesh3D.cxx)
target_include_directories(ContourTreeMesh3D_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh3D_SERIAL PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
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})
set (cudaSource "${CMAKE_CURRENT_BINARY_DIR}/ContourTreeMesh2D.cu")
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 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 PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
set(CMAKE_CXX_FLAGS ${old_cxx_flags})
endif()
if(VTKm_TBB_FOUND)
add_executable(ContourTreeMesh2D_TBB ContourTreeMesh2D.cxx)
target_include_directories(ContourTreeMesh2D_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh2D_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh2D_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
add_executable(ContourTreeMesh3D_TBB ContourTreeMesh3D.cxx)
target_include_directories(ContourTreeMesh3D_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(ContourTreeMesh3D_TBB PRIVATE ${VTKm_LIBRARIES})
target_compile_options(ContourTreeMesh3D_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -0,0 +1,128 @@
//============================================================================
// 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.
//============================================================================
// Copyright (c) 2016, Los Alamos National Security, LLC
// All rights reserved.
//
// Copyright 2016. Los Alamos National Security, LLC.
// This software was produced under U.S. Government contract DE-AC52-06NA25396
// for Los Alamos National Laboratory (LANL), which is operated by
// Los Alamos National Security, LLC for the U.S. Department of Energy.
// The U.S. Government has rights to use, reproduce, and distribute this
// software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC
// MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE
// USE OF THIS SOFTWARE. If software is modified to produce derivative works,
// such modified software should be clearly marked, so as not to confuse it
// with the version available from LANL.
//
// Additionally, redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Los Alamos National Security, LLC, Los Alamos
// National Laboratory, LANL, the U.S. Government, nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND
// CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS
// NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//============================================================================
// This code is based on the algorithm presented in the paper:
// “Parallel Peak Pruning for Scalable SMP Contour Tree Computation.”
// Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
// Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
// (LDAV), October 2016, Baltimore, Maryland.
#ifndef VTKM_DEVICE_ADAPTER
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/filter/ContourTreeUniform.h>
#include <fstream>
#include <vector>
// Compute and render an isosurface for a uniform grid example
int main(int argc, char* argv[])
{
std::cout << "ContourTreeMesh2D Example" << std::endl;
if (argc != 2) {
std::cout << "Parameter is fileName" << std::endl;
std::cout << "File is expected to be ASCII with xdim ydim integers " << std::endl;
std::cout << "followed by vector data last dimension varying fastest" << std::endl;
return 0;
}
// open input file
std::ifstream inFile(argv[1]);
if (inFile.bad()) return 0;
// read size of mesh
vtkm::Id2 vdims;
inFile >> vdims[0];
inFile >> vdims[1];
std::size_t nVertices = static_cast<std::size_t>(vdims[0] * vdims[1]);
// read data
std::vector<vtkm::Float32> values(nVertices);
for (std::size_t vertex = 0; vertex < nVertices; vertex++)
{
inFile >> values[vertex];
}
inFile.close();
// build the input dataset
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::cont::DataSet inDataSet = dsb.Create(vdims);
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddPointField(inDataSet, "values", values);
// Output data set is pairs of saddle and peak vertex IDs
vtkm::filter::ResultField result;
// Convert 2D mesh of values into contour tree, pairs of vertex ids
vtkm::filter::ContourTreeMesh2D filter;
result = filter.Execute(inDataSet, std::string("values"));
vtkm::cont::Field resultField = result.GetField();
vtkm::cont::ArrayHandle<vtkm::Pair<vtkm::Id, vtkm::Id> > saddlePeak;
resultField.GetData().CopyTo(saddlePeak);
return 0;
}

@ -0,0 +1,130 @@
//============================================================================
// 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.
//============================================================================
// Copyright (c) 2016, Los Alamos National Security, LLC
// All rights reserved.
//
// Copyright 2016. Los Alamos National Security, LLC.
// This software was produced under U.S. Government contract DE-AC52-06NA25396
// for Los Alamos National Laboratory (LANL), which is operated by
// Los Alamos National Security, LLC for the U.S. Department of Energy.
// The U.S. Government has rights to use, reproduce, and distribute this
// software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC
// MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE
// USE OF THIS SOFTWARE. If software is modified to produce derivative works,
// such modified software should be clearly marked, so as not to confuse it
// with the version available from LANL.
//
// Additionally, redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Los Alamos National Security, LLC, Los Alamos
// National Laboratory, LANL, the U.S. Government, nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND
// CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS
// NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//============================================================================
// This code is based on the algorithm presented in the paper:
// “Parallel Peak Pruning for Scalable SMP Contour Tree Computation.”
// Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
// Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
// (LDAV), October 2016, Baltimore, Maryland.
#ifndef VTKM_DEVICE_ADAPTER
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/filter/ContourTreeUniform.h>
#include <fstream>
#include <vector>
// Compute and render an isosurface for a uniform grid example
int main(int argc, char* argv[])
{
std::cout << "ContourTreeMesh3D Example" << std::endl;
if (argc != 2) {
std::cout << "Parameter is fileName" << std::endl;
std::cout << "File is expected to be ASCII with xdim ydim zdim integers " << std::endl;
std::cout << "followed by vector data last dimension varying fastest" << std::endl;
return 0;
}
// open input file
std::ifstream inFile(argv[1]);
if (inFile.bad()) return 0;
// read size of mesh
vtkm::Id3 vdims;
inFile >> vdims[0];
inFile >> vdims[1];
inFile >> vdims[2];
std::size_t nVertices =
static_cast<std::size_t>(vdims[0] * vdims[1] * vdims[2]);
// read data
std::vector<vtkm::Float32> values(nVertices);
for (std::size_t vertex = 0; vertex < nVertices; vertex++)
{
inFile >> values[vertex];
}
inFile.close();
// build the input dataset
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::cont::DataSet inDataSet = dsb.Create(vdims);
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddPointField(inDataSet, "values", values);
// Output data set is pairs of saddle and peak vertex IDs
vtkm::filter::ResultField result;
// Convert 3D mesh of values into contour tree, pairs of vertex ids
vtkm::filter::ContourTreeMesh3D filter;
result = filter.Execute(inDataSet, std::string("values"));
vtkm::cont::Field resultField = result.GetField();
vtkm::cont::ArrayHandle<vtkm::Pair<vtkm::Id, vtkm::Id> > saddlePeak;
resultField.GetData().CopyTo(saddlePeak);
return 0;
}

@ -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

@ -124,7 +124,7 @@ int main(int argc, char* argv[])
vtkm::filter::MarchingCubes filter;
filter.SetGenerateNormals(false);
filter.SetMergeDuplicatePoints(false);
filter.SetIsoValue(isovalue);
filter.SetIsoValue(0, isovalue);
vtkm::filter::ResultDataSet result = filter.Execute( inputData,
inputData.GetField(fieldName) );
filter.MapFieldOntoOutput(result, inputData.GetField(fieldName));

@ -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()

@ -48,12 +48,12 @@
#include <vector>
vtkm::Id3 dims(256, 256, 256);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > verticesArray, normalsArray;
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
Quaternion qrot;
int lastx, lasty;
int mouse_state = 1;
static vtkm::Id3 dims(256, 256, 256);
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > verticesArray, normalsArray;
static vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
static Quaternion qrot;
static int lastx, lasty;
static int mouse_state = 1;
namespace {
@ -234,8 +234,8 @@ int main(int argc, char* argv[])
vtkm::filter::MarchingCubes filter;
filter.SetGenerateNormals(true);
filter.SetMergeDuplicatePoints( false );
filter.SetIsoValue( 0.5 );
filter.SetMergeDuplicatePoints(false);
filter.SetIsoValue(0, 0.5);
vtkm::filter::ResultDataSet result =
filter.Execute( dataSet, dataSet.GetField("nodevar") );
@ -275,6 +275,9 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall);
glutMainLoop();
verticesArray.ReleaseResources();
normalsArray.ReleaseResources();
scalarsArray.ReleaseResources();
return 0;
}

@ -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()

@ -51,8 +51,8 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Output data set shared with opengl
vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> *streamLineFilter;
vtkm::cont::DataSet outDataSet;
static vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> *streamLineFilter;
static vtkm::cont::DataSet outDataSet;
// Input parameters
const vtkm::Id nSeeds = 25;
@ -61,7 +61,7 @@ const vtkm::Float32 tStep = 0.5f;
const vtkm::Id direction = vtkm::worklet::internal::BOTH;
// Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3> > vertexArray;
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3> > vertexArray;
// OpenGL display variables
Quaternion qrot;
@ -313,6 +313,9 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall);
glutMainLoop();
delete streamLineFilter;
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}

@ -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()

@ -22,7 +22,7 @@
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/worklet/TetrahedralizeExplicitGrid.h>
#include <vtkm/filter/Tetrahedralize.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
@ -49,11 +49,10 @@ typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
namespace {
// Takes input uniform grid and outputs unstructured grid of tets
vtkm::cont::DataSet outDataSet;
vtkm::Id numberOfInPoints;
static vtkm::cont::DataSet outDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
// OpenGL display variables
Quaternion qrot;
@ -206,7 +205,7 @@ void displayCall()
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfInPoints);
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the five tetrahedra belonging to each hexadron
@ -302,18 +301,11 @@ int main(int argc, char* argv[])
vtkm::cont::CellSetExplicit<> inCellSet;
inDataSet.GetCellSet(0).CopyTo(inCellSet);
numberOfInPoints = inCellSet.GetNumberOfPoints();
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
outDataSet.AddCellSet(cellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
// Convert cells to tetrahedra
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
tetrahedralizeFilter(inDataSet, outDataSet);
tetrahedralizeFilter.Run();
vtkm::filter::Tetrahedralize tetrahedralize;
vtkm::filter::ResultDataSet result = tetrahedralize.Execute(inDataSet);
outDataSet = result.GetDataSet();
// Render the output dataset of tets
lastx = lasty = 0;
@ -331,6 +323,8 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall);
glutMainLoop();
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}

@ -22,7 +22,7 @@
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/worklet/TetrahedralizeUniformGrid.h>
#include <vtkm/filter/Tetrahedralize.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
@ -46,21 +46,19 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Default size of the example
vtkm::Id3 dims(4,4,4);
vtkm::Id cellsToDisplay = 64;
vtkm::Id numberOfInPoints;
static vtkm::Id3 dims(4,4,4);
static vtkm::Id cellsToDisplay = 64;
// Takes input uniform grid and outputs unstructured grid of tets
vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet tetDataSet;
static vtkm::cont::DataSet tetDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
// OpenGL display variables
Quaternion qrot;
int lastx, lasty;
int mouse_state = 1;
static Quaternion qrot;
static int lastx, lasty;
static int mouse_state = 1;
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
@ -173,7 +171,7 @@ void displayCall()
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfInPoints);
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the five tetrahedra belonging to each hexadron
@ -289,19 +287,10 @@ int main(int argc, char* argv[])
// Create the input uniform cell set
vtkm::cont::DataSet inDataSet = MakeTetrahedralizeTestDataSet(dims);
// Set number of cells and vertices in input dataset
numberOfInPoints = (dims[0] + 1) * (dims[1] + 1) * (dims[2] + 1);
vtkm::filter::Tetrahedralize tetrahedralize;
vtkm::filter::ResultDataSet result = tetrahedralize.Execute(inDataSet);
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
tetDataSet.AddCellSet(cellSet);
tetDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
// Convert uniform hexahedra to tetrahedra
tetrahedralizeFilter = new vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter>
(inDataSet, tetDataSet);
tetrahedralizeFilter->Run();
tetDataSet = result.GetDataSet();
// Render the output dataset of tets
lastx = lasty = 0;
@ -319,6 +308,8 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall);
glutMainLoop();
tetDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}

@ -22,7 +22,7 @@
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/worklet/TetrahedralizeExplicitGrid.h>
#include <vtkm/filter/Triangulate.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
@ -46,12 +46,11 @@ typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
namespace {
// Takes input uniform grid and outputs unstructured grid of triangles
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet outDataSet;
vtkm::Id numberOfInPoints;
static vtkm::cont::DataSet outDataSet;
static vtkm::Id numberOfInPoints;
// Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
} // anonymous namespace
@ -225,15 +224,10 @@ int main(int argc, char* argv[])
numberOfInPoints = inCellSet.GetNumberOfPoints();
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(), "cells");;
outDataSet.AddCellSet(cellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
// Convert 2D explicit cells to triangles
tetrahedralizeFilter = new vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
(inDataSet, outDataSet);
tetrahedralizeFilter->Run();
vtkm::filter::Triangulate triangulate;
vtkm::filter::ResultDataSet result = triangulate.Execute(inDataSet);
outDataSet = result.GetDataSet();
// Render the output dataset of tets
glutInit(&argc, argv);
@ -248,6 +242,8 @@ int main(int argc, char* argv[])
glutDisplayFunc(displayCall);
glutMainLoop();
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}

@ -22,7 +22,7 @@
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
#include <vtkm/worklet/TetrahedralizeUniformGrid.h>
#include <vtkm/filter/Triangulate.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
@ -44,16 +44,14 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Default size of the example
vtkm::Id2 dims(4,4);
vtkm::Id cellsToDisplay = 16;
vtkm::Id numberOfInPoints;
static vtkm::Id2 dims(4,4);
static vtkm::Id cellsToDisplay = 16;
// Takes input uniform grid and outputs unstructured grid of triangles
vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet tetDataSet;
static vtkm::cont::DataSet triDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
@ -68,7 +66,7 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
const vtkm::Vec<vtkm::Float32, 3> spacing = vtkm::make_Vec(
1.0f/static_cast<vtkm::Float32>(dim[0]),
1.0f/static_cast<vtkm::Float32>(dim[1]),
1.0f/static_cast<vtkm::Float32>(dim[2]));
0.0f);
// Generate coordinate system
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
@ -131,12 +129,12 @@ void displayCall()
// Get the cellset, coordinate system and coordinate data
vtkm::cont::CellSetSingleType<> cellSet;
tetDataSet.GetCellSet(0).CopyTo(cellSet);
triDataSet.GetCellSet(0).CopyTo(cellSet);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfInPoints);
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(triDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the two triangles belonging to each quad
vtkm::Id triangle = 0;
@ -178,7 +176,7 @@ void displayCall()
glFlush();
}
// Tetrahedralize and render uniform grid example
// Triangulate and render uniform grid example
int main(int argc, char* argv[])
{
std::cout << "TrianguleUniformGrid Example" << std::endl;
@ -195,20 +193,15 @@ int main(int argc, char* argv[])
{
cellsToDisplay = atoi(argv[3]);
}
numberOfInPoints = (dims[0] + 1) * (dims[1] + 1);
// Create the input uniform cell set
vtkm::cont::DataSet inDataSet = MakeTriangulateTestDataSet(dims);
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(), "cells");
tetDataSet.AddCellSet(cellSet);
tetDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
// Convert uniform quad to triangle
vtkm::filter::Triangulate triangulate;
vtkm::filter::ResultDataSet result = triangulate.Execute(inDataSet);
// Convert uniform hexahedra to tetrahedra
tetrahedralizeFilter = new vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter>
(inDataSet, tetDataSet);
tetrahedralizeFilter->Run();
triDataSet = result.GetDataSet();
// Render the output dataset of tets
glutInit(&argc, argv);
@ -223,6 +216,8 @@ int main(int argc, char* argv[])
glutDisplayFunc(displayCall);
glutMainLoop();
triDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}

@ -0,0 +1,36 @@
##=============================================================================
##
## 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 2015 Sandia Corporation.
## Copyright 2015 UT-Battelle, LLC.
## Copyright 2015 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.
##
##=============================================================================
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET
OPTIONAL_COMPONENTS Serial CUDA TBB OpenGL GLUT
)
if(VTKm_CUDA_FOUND)
vtkm_disable_troublesome_thrust_warnings()
# Cuda compiles do not respect target_include_directories
cuda_include_directories(${VTKm_INCLUDE_DIRS})
cuda_add_executable(UnifiedMemory_CUDA UnifiedMemory.cu)
target_link_libraries(UnifiedMemory_CUDA PRIVATE ${VTKm_LIBRARIES})
target_compile_options(UnifiedMemory_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
endif()

@ -0,0 +1,223 @@
//============================================================================
// 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.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_CUDA
#include <vtkm/cont/ArrayHandleStreaming.h>
#include <vtkm/worklet/DispatcherStreamingMapField.h>
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Timer.h>
namespace {
// Define the tangle field for the input data
class TangleField : public vtkm::worklet::WorkletMapField
{
public:
typedef void ControlSignature(FieldIn<IdType> vertexId, FieldOut<Scalar> v);
typedef void ExecutionSignature(_1, _2);
typedef _1 InputDomain;
const vtkm::Id xdim, ydim, zdim;
const vtkm::Float32 xmin, ymin, zmin, xmax, ymax, zmax;
const vtkm::Id cellsPerLayer;
VTKM_CONT
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 maxs[3]) : xdim(dims[0]), ydim(dims[1]), zdim(dims[2]),
xmin(mins[0]), ymin(mins[1]), zmin(mins[2]), xmax(maxs[0]), ymax(maxs[1]), zmax(maxs[2]), cellsPerLayer((xdim) * (ydim)) { };
VTKM_EXEC
void operator()(const vtkm::Id &vertexId, vtkm::Float32 &v) const
{
const vtkm::Id x = vertexId % (xdim);
const vtkm::Id y = (vertexId / (xdim)) % (ydim);
const vtkm::Id z = vertexId / cellsPerLayer;
const vtkm::Float32 fx = static_cast<vtkm::Float32>(x) / static_cast<vtkm::Float32>(xdim-1);
const vtkm::Float32 fy = static_cast<vtkm::Float32>(y) / static_cast<vtkm::Float32>(xdim-1);
const vtkm::Float32 fz = static_cast<vtkm::Float32>(z) / static_cast<vtkm::Float32>(xdim-1);
const vtkm::Float32 xx = 3.0f*(xmin+(xmax-xmin)*(fx));
const vtkm::Float32 yy = 3.0f*(ymin+(ymax-ymin)*(fy));
const vtkm::Float32 zz = 3.0f*(zmin+(zmax-zmin)*(fz));
v = (xx*xx*xx*xx - 5.0f*xx*xx + yy*yy*yy*yy - 5.0f*yy*yy + zz*zz*zz*zz - 5.0f*zz*zz + 11.8f) * 0.2f + 0.5f;
}
};
// Construct an input data set using the tangle field worklet
vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
{
vtkm::cont::DataSet dataSet;
const vtkm::Id3 vdims(dims[0] + 1, dims[1] + 1, dims[2] + 1);
vtkm::Float32 mins[3] = {-1.0f, -1.0f, -1.0f};
vtkm::Float32 maxs[3] = {1.0f, 1.0f, 1.0f};
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(0, 1, vdims[0]*vdims[1]*vdims[2]);
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(TangleField(vdims, mins, maxs));
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, fieldArray);
vtkm::Vec<vtkm::FloatDefault,3> origin(0.0f, 0.0f, 0.0f);
vtkm::Vec<vtkm::FloatDefault,3> spacing(
1.0f/static_cast<vtkm::FloatDefault>(dims[0]),
1.0f/static_cast<vtkm::FloatDefault>(dims[2]),
1.0f/static_cast<vtkm::FloatDefault>(dims[1]));
vtkm::cont::ArrayHandleUniformPointCoordinates
coordinates(vdims, origin, spacing);
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", coordinates));
dataSet.AddField(vtkm::cont::Field("nodevar", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
static const vtkm::IdComponent ndim = 3;
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
return dataSet;
}
}
namespace vtkm
{
namespace worklet
{
class SineWorklet : public vtkm::worklet::WorkletMapField
{
public:
typedef void ControlSignature(FieldIn<>, FieldOut<>);
typedef _2 ExecutionSignature(_1, WorkIndex);
VTKM_EXEC
vtkm::Float32 operator()(vtkm::Int64 x, vtkm::Id& index) const {
return (vtkm::Sin(1.0*x));
}
};
}
}
// Run a simple worklet, and compute an isosurface
int main(int argc, char* argv[])
{
vtkm::Int64 N = 1024*1024*1024;
if (argc > 1) N = N*atoi(argv[1]);
else N = N*4;
std::cout << "Testing streaming worklet with size " << N << std::endl;
vtkm::cont::ArrayHandle<vtkm::Int64> input;
vtkm::cont::ArrayHandle<vtkm::Float32> output;
std::vector<vtkm::Int64> data(N);
for (vtkm::Int64 i=0; i<N; i++) data[i] = i;
input = vtkm::cont::make_ArrayHandle(data);
typedef vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> DeviceAlgorithms;
vtkm::worklet::SineWorklet sineWorklet;
#ifdef VTKM_USE_UNIFIED_MEMORY
std::cout << "Testing with unified memory" << std::endl;
vtkm::worklet::DispatcherMapField<vtkm::worklet::SineWorklet>
dispatcher(sineWorklet);
vtkm::cont::Timer<> timer;
dispatcher.Invoke(input, output);
std::cout << output.GetPortalConstControl().Get(output.GetNumberOfValues()-1) << std::endl;
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
std::cout << "Time: " << elapsedTime << std::endl;
#else
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet>
dispatcher(sineWorklet);
vtkm::Id NBlocks = N/(1024*1024*1024);
NBlocks *= 2;
dispatcher.SetNumberOfBlocks(NBlocks);
std::cout << "Testing with streaming (without unified memory) with " << NBlocks << " blocks" << std::endl;
vtkm::cont::Timer<> timer;
dispatcher.Invoke(input, output);
std::cout << output.GetPortalConstControl().Get(output.GetNumberOfValues()-1) << std::endl;
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
std::cout << "Time: " << elapsedTime << std::endl;
#endif
int dim = 128;
if (argc > 2) dim = atoi(argv[2]);
std::cout << "Testing Marching Cubes with size " << dim << "x" << dim << "x" << dim << std::endl;
vtkm::Id3 dims(dim, dim, dim);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > verticesArray, normalsArray;
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
vtkm::cont::DataSet dataSet = MakeIsosurfaceTestDataSet(dims);
vtkm::filter::MarchingCubes filter;
filter.SetGenerateNormals(true);
filter.SetMergeDuplicatePoints( false );
filter.SetIsoValue( 0.5 );
vtkm::filter::ResultDataSet result =
filter.Execute( dataSet, dataSet.GetField("nodevar") );
filter.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
//need to extract vertices, normals, and scalars
vtkm::cont::DataSet& outputData = result.GetDataSet();
typedef vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > VertType;
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
verticesArray = coords.GetData().Cast<VertType>();
normalsArray = outputData.GetField("normals").GetData().Cast<VertType>();
scalarsArray = outputData.GetField("nodevar").GetData().Cast< vtkm::cont::ArrayHandle<vtkm::Float32> >();
std::cout << "Number of output vertices: " << verticesArray.GetNumberOfValues() << std::endl;
std::cout << "vertices: ";
vtkm::cont::printSummary_ArrayHandle(verticesArray, std::cout);
std::cout << std::endl;
std::cout << "normals: ";
vtkm::cont::printSummary_ArrayHandle(normalsArray, std::cout);
std::cout << std::endl;
std::cout << "scalars: ";
vtkm::cont::printSummary_ArrayHandle(scalarsArray, std::cout);
std::cout << std::endl;
return 0;
}

1
version.txt Normal file

@ -0,0 +1 @@
1.0.0

74
vtkm/BaseComponent.h Normal file

@ -0,0 +1,74 @@
//============================================================================
// 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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_BaseComponent_h
#define vtk_m_BaseComponent_h
#include <vtkm/Matrix.h>
#include <vtkm/TypeTraits.h>
#include <vtkm/VecTraits.h>
namespace vtkm {
namespace detail {
template<typename VecType, typename DimensionalityTag>
struct BaseComponentImpl;
template<typename VecType>
struct BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
{
private:
using ComponentType = typename vtkm::VecTraits<VecType>::ComponentType;
public:
using Type =
typename BaseComponentImpl<
ComponentType,
typename vtkm::TypeTraits<ComponentType>::DimensionalityTag
>::Type;
};
template<typename VecType>
struct BaseComponentImpl<VecType, vtkm::TypeTraitsMatrixTag>
: BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
{ };
template<typename ScalarType>
struct BaseComponentImpl<ScalarType, vtkm::TypeTraitsScalarTag>
{
using Type = ScalarType;
};
} // namespace detail
// Finds the base component type of a Vec. If you have a Vec of Vecs, it will
// descend all Vecs until you get to the scalar type.
template<typename VecType>
struct BaseComponent
{
using Type =
typename detail::BaseComponentImpl<
VecType,
typename vtkm::TypeTraits<VecType>::DimensionalityTag>::Type;
};
} // namespace vtkm
#endif //vtk_m_BaseComponent_h

@ -18,8 +18,17 @@
## this software.
##============================================================================
# Configure version file. (Other configuration in internal/Configure.h)
vtkm_get_kit_name(kit_name kit_dir)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in
${CMAKE_BINARY_DIR}/include/${kit_dir}/Version.h
@ONLY)
vtkm_install_headers(
vtkm ${CMAKE_BINARY_DIR}/include/${kit_dir}/Version.h)
set(headers
Assert.h
BaseComponent.h
BinaryPredicates.h
BinaryOperators.h
Bounds.h

@ -21,6 +21,8 @@
#define vtk_m_ImplicitFunctions_h
#include <vtkm/Types.h>
#include <vtkm/Math.h>
#include <vtkm/VectorAnalysis.h>
#include <iostream>
namespace vtkm {
@ -153,6 +155,233 @@ private:
vtkm::Vec<FloatDefault, 3> Center;
};
/// \brief Implicit function for a box
class Box
{
public:
VTKM_CONT
Box() : MinPoint(vtkm::Vec<FloatDefault,3>(FloatDefault(0), FloatDefault(0), FloatDefault(0))),
MaxPoint(vtkm::Vec<FloatDefault,3>(FloatDefault(1), FloatDefault(1), FloatDefault(1)))
{ }
VTKM_CONT
Box(vtkm::Vec<FloatDefault, 3> minPoint, vtkm::Vec<FloatDefault, 3> maxPoint)
: MinPoint(minPoint), MaxPoint(maxPoint)
{ }
VTKM_CONT
Box(FloatDefault xmin, FloatDefault xmax,
FloatDefault ymin, FloatDefault ymax,
FloatDefault zmin, FloatDefault zmax)
{
MinPoint[0] = xmin; MaxPoint[0] = xmax;
MinPoint[1] = ymin; MaxPoint[1] = ymax;
MinPoint[2] = zmin; MaxPoint[2] = zmax;
}
VTKM_EXEC_CONT
const vtkm::Vec<FloatDefault, 3>& GetMinPoint() const
{
return this->MinPoint;
}
VTKM_EXEC_CONT
const vtkm::Vec<FloatDefault, 3>& GetMaxPoint() const
{
return this->MaxPoint;
}
VTKM_EXEC_CONT
FloatDefault Value(const vtkm::Vec<FloatDefault, 3> &x) const
{
FloatDefault minDistance = vtkm::NegativeInfinity32();
FloatDefault diff, t, dist;
FloatDefault distance = FloatDefault(0.0);
vtkm::IdComponent inside = 1;
for (vtkm::IdComponent d = 0; d < 3; d++)
{
diff = this->MaxPoint[d] - this->MinPoint[d];
if (diff != FloatDefault(0.0))
{
t = (x[d] - this->MinPoint[d]) / diff;
// Outside before the box
if (t < FloatDefault(0.0))
{
inside = 0;
dist = this->MinPoint[d] - x[d];
}
// Outside after the box
else if (t > FloatDefault(1.0))
{
inside = 0;
dist = x[d] - this->MaxPoint[d];
}
else
{
// Inside the box in lower half
if (t <= FloatDefault(0.5))
{
dist = MinPoint[d] - x[d];
}
// Inside the box in upper half
else
{
dist = x[d] - MaxPoint[d];
}
if (dist > minDistance)
{
minDistance = dist;
}
}
}
else
{
dist = vtkm::Abs(x[d] - MinPoint[d]);
if (dist > FloatDefault(0.0))
{
inside = 0;
}
}
if (dist > FloatDefault(0.0))
{
distance += dist*dist;
}
}
distance = vtkm::Sqrt(distance);
if (inside)
{
return minDistance;
}
else
{
return distance;
}
}
VTKM_EXEC_CONT
FloatDefault Value(FloatDefault x, FloatDefault y, FloatDefault z) const
{
return this->Value(vtkm::Vec<vtkm::FloatDefault,3>(x, y, z));
}
VTKM_EXEC_CONT
vtkm::Vec<FloatDefault, 3> Gradient(const vtkm::Vec<FloatDefault, 3> &x) const
{
vtkm::IdComponent minAxis = 0;
FloatDefault dist = 0.0;
FloatDefault minDist = vtkm::Infinity32();
vtkm::Vec<vtkm::IdComponent,3> location;
vtkm::Vec<FloatDefault,3> normal;
vtkm::Vec<FloatDefault,3> inside(FloatDefault(0), FloatDefault(0), FloatDefault(0));
vtkm::Vec<FloatDefault,3> outside(FloatDefault(0), FloatDefault(0), FloatDefault(0));
vtkm::Vec<FloatDefault,3> center((this->MaxPoint[0] + this->MinPoint[0]) * FloatDefault(0.5),
(this->MaxPoint[1] + this->MinPoint[1]) * FloatDefault(0.5),
(this->MaxPoint[2] + this->MinPoint[2]) * FloatDefault(0.5));
// Compute the location of the point with respect to the box
// Point will lie in one of 27 separate regions around or within the box
// Gradient vector is computed differently in each of the regions.
for (vtkm::IdComponent d = 0; d < 3; d++)
{
if (x[d] < this->MinPoint[d])
{
// Outside the box low end
location[d] = 0;
outside[d] = -1.0;
}
else if (x[d] > this->MaxPoint[d])
{
// Outside the box high end
location[d] = 2;
outside[d] = 1.0;
}
else
{
location[d] = 1;
if (x[d] <= center[d])
{
// Inside the box low end
dist = x[d] - this->MinPoint[d];
inside[d] = -1.0;
}
else
{
// Inside the box high end
dist = this->MaxPoint[d] - x[d];
inside[d] = 1.0;
}
if (dist < minDist) // dist is negative
{
minDist = dist;
minAxis = d;
}
}
}
vtkm::Id indx = location[0] + 3*location[1] + 9*location[2];
switch (indx)
{
// verts - gradient points away from center point
case 0: case 2: case 6: case 8: case 18: case 20: case 24: case 26:
for (vtkm::IdComponent d = 0; d < 3; d++)
{
normal[d] = x[d] - center[d];
}
vtkm::Normalize(normal);
break;
// edges - gradient points out from axis of cube
case 1: case 3: case 5: case 7:
case 9: case 11: case 15: case 17:
case 19: case 21: case 23: case 25:
for (vtkm::IdComponent d = 0; d < 3; d++)
{
if (outside[d] != 0.0)
{
normal[d] = x[d] - center[d];
}
else
{
normal[d] = 0.0;
}
}
vtkm::Normalize(normal);
break;
// faces - gradient points perpendicular to face
case 4: case 10: case 12: case 14: case 16: case 22:
for (vtkm::IdComponent d = 0; d < 3; d++)
{
normal[d] = outside[d];
}
break;
// interior - gradient is perpendicular to closest face
case 13:
normal[0] = normal[1] = normal[2] = 0.0;
normal[minAxis] = inside[minAxis];
break;
default:
VTKM_ASSERT(false);
break;
}
return normal;
}
VTKM_EXEC_CONT
vtkm::Vec<FloatDefault, 3> Gradient(FloatDefault x, FloatDefault y, FloatDefault z)
const
{
return this->Gradient(vtkm::Vec<FloatDefault, 3>(x, y, z));
}
private:
vtkm::Vec<FloatDefault, 3> MinPoint;
vtkm::Vec<FloatDefault, 3> MaxPoint;
};
/// \brief A function object that evaluates the contained implicit function
template <typename ImplicitFunction>
class ImplicitFunctionValue

@ -51,6 +51,13 @@ struct ListTagCheck : std::is_base_of<vtkm::detail::ListRoot,ListTag>
"Provided type is not a valid VTK-m list tag.")
/// A special tag for a list that represents holding all potential values
///
/// Note: Can not be used with ForEach for obvious reasons.
struct ListTagUniversal : detail::ListRoot {
using list = vtkm::detail::ListBase<vtkm::detail::UniversalTag>;
};
/// A special tag for an empty list.
///
struct ListTagEmpty : detail::ListRoot {
@ -61,7 +68,18 @@ struct ListTagEmpty : detail::ListRoot {
/// can be subclassed and still behave like a list tag.
template<typename ListTag1, typename ListTag2>
struct ListTagJoin : detail::ListRoot {
using list = typename detail::ListJoin<ListTag1,ListTag2>::type;
using list = typename detail::ListJoin<
typename ListTag1::list,
typename ListTag2::list>::type;
};
/// A tag that consits of elements that are found in both tags. This struct
/// can be subclassed and still behave like a list tag.
template<typename ListTag1, typename ListTag2>
struct ListTagIntersect : detail::ListRoot {
using list = typename detail::ListIntersect<
typename ListTag1::list,
typename ListTag2::list>::type;
};
/// For each typename represented by the list tag, call the functor with a
@ -98,7 +116,6 @@ struct ListContains
detail::ListContainsImpl<Type,typename ListTag::list>::value;
};
} // namespace vtkm
#endif //vtk_m_ListTag_h

File diff suppressed because it is too large Load Diff

@ -61,22 +61,25 @@ $# Ignore the following comment. It is meant for the generated file.
#define VTKM_CUDA_MATH_FUNCTION_64(func) func
$py(
def unary_function(name, type, returntype, cuda_expression, std_expression):
return '''static inline VTKM_EXEC_CONT
{2} {0}({1} x) {{
def unary_function(name, type, returntype, cuda_expression, std_expression, template_header, static_keywords):
return '''{5}
{6} VTKM_EXEC_CONT
{2}
{0}({1} x) {{
#ifdef VTKM_CUDA
return {3};
#else
return {4};
#endif
}}
'''.format(name, type, returntype, cuda_expression, std_expression)
'''.format(name, type, returntype, cuda_expression, std_expression, template_header, static_keywords)
def unary_Vec_function(vtkmname):
return '''template<typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,N> {0}(const vtkm::Vec<T,N> &x) {{
vtkm::Vec<T,N> result;
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,N>
{0}(const vtkm::Vec<T,N> &x) {{
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,N> result;
for (vtkm::IdComponent index = 0; index < N; index++)
{{
result[index] = vtkm::{0}(x[index]);
@ -85,38 +88,52 @@ vtkm::Vec<T,N> {0}(const vtkm::Vec<T,N> &x) {{
}}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,4> {0}(const vtkm::Vec<T,4> &x) {{
return vtkm::Vec<T,4>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]),
vtkm::{0}(x[2]),
vtkm::{0}(x[3]));
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,4>
{0}(const vtkm::Vec<T,4> &x) {{
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,4>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]),
vtkm::{0}(x[2]),
vtkm::{0}(x[3]));
}}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,3> {0}(const vtkm::Vec<T,3> &x) {{
return vtkm::Vec<T,3>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]),
vtkm::{0}(x[2]));
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>
{0}(const vtkm::Vec<T,3> &x) {{
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]),
vtkm::{0}(x[2]));
}}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,2> {0}(const vtkm::Vec<T,2> &x) {{
return vtkm::Vec<T,2>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]));
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,2>
{0}(const vtkm::Vec<T,2> &x) {{
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,2>(vtkm::{0}(x[0]),
vtkm::{0}(x[1]));
}}
'''.format(vtkmname)
def unary_math_function_no_vec(vtkmname, sysname, returntype = None):
return unary_function(vtkmname,
'T',
'typename detail::FloatingPointReturnType<T>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(static_cast<vtkm::Float64>(x))',
'std::' + sysname + '(static_cast<vtkm::Float64>(x))',
'template<typename T>',
'static inline') + \
unary_function(vtkmname,
'vtkm::Float32',
'vtkm::Float32' if returntype == None else returntype,
'detail::FloatingPointReturnType<vtkm::Float32>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_32(' + sysname + ')(x)',
'std::' + sysname + '(x)') + \
'std::' + sysname + '(x)',
'template<>',
'inline') + \
unary_function(vtkmname,
'vtkm::Float64',
'vtkm::Float64' if returntype == None else returntype,
'detail::FloatingPointReturnType<vtkm::Float64>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(x)',
'std::' + sysname + '(x)')
'std::' + sysname + '(x)',
'template<>',
'inline')
def unary_math_function(vtkmname, sysname):
return unary_math_function_no_vec(vtkmname, sysname) + \
@ -224,6 +241,29 @@ vtkm::Float64 Pi_4()
return 0.78539816339744830961566084581987572;
}
namespace detail {
template<typename T>
struct FloatingPointReturnCondition :
std::enable_if<std::is_same<typename vtkm::VecTraits<T>::ComponentType, vtkm::Float32>::value ||
std::is_same<typename vtkm::VecTraits<T>::ComponentType, const vtkm::Float32>::value>
{
};
template<typename T, typename = void>
struct FloatingPointReturnType
{
typedef vtkm::Float64 Type;
};
template<typename T>
struct FloatingPointReturnType<T, typename FloatingPointReturnCondition<T>::type>
{
typedef vtkm::Float32 Type;
};
}
/// Compute the sine of \p x.
///
$unary_math_function('Sin', 'sin')\
@ -306,6 +346,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 RSqrt(vtkm::Float64 x) {
return rsqrt(x);
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 RSqrt(T x) {
return rsqrt(static_cast<vtkm::Float64>(x));
}
#else // !VTKM_CUDA
static inline VTKM_EXEC_CONT
vtkm::Float32 RSqrt(vtkm::Float32 x) {
@ -315,6 +360,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 RSqrt(vtkm::Float64 x) {
return 1/vtkm::Sqrt(x);
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 RSqrt(T x) {
return 1/static_cast<vtkm::Float64>(x);
}
#endif // !VTKM_CUDA
$unary_Vec_function('RSqrt')\
@ -339,6 +389,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 RCbrt(vtkm::Float64 x) {
return rcbrt(x);
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 RCbrt(T x) {
return rcbrt(static_cast<vtkm::Float64>(x));
}
#else // !VTKM_CUDA
static inline VTKM_EXEC_CONT
vtkm::Float32 RCbrt(vtkm::Float32 x) {
@ -348,6 +403,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 RCbrt(vtkm::Float64 x) {
return 1/vtkm::Cbrt(x);
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 RCbrt(T x) {
return 1/vtkm::Cbrt(static_cast<vtkm::Float64>(x));
}
#endif // !VTKM_CUDA
$unary_Vec_function('RCbrt')\
@ -380,6 +440,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 Exp10(vtkm::Float64 x) {
return exp10(x);
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 Exp10(T x) {
return exp10(static_cast<vtkm::Float64>(x));
}
#else // !VTKM_CUDA
static inline VTKM_EXEC_CONT
vtkm::Float32 Exp10(vtkm::Float32 x) {
@ -389,6 +454,11 @@ static inline VTKM_EXEC_CONT
vtkm::Float64 Exp10(vtkm::Float64 x) {
return vtkm::Pow(10, x);;
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Float64 Exp10(T x) {
return vtkm::Pow(10, static_cast<vtkm::Float64>(x));;
}
#endif // !VTKM_CUDA
$unary_Vec_function('Exp10')\
@ -521,18 +591,18 @@ union IEEE754Bits32 {
vtkm::UInt32 bits;
vtkm::Float32 scalar;
};
#define VTKM_NAN_BITS_32 0x7FC00000
#define VTKM_INF_BITS_32 0x7F800000
#define VTKM_NEG_INF_BITS_32 0xFF800000
#define VTKM_NAN_BITS_32 0x7FC00000U
#define VTKM_INF_BITS_32 0x7F800000U
#define VTKM_NEG_INF_BITS_32 0xFF800000U
#define VTKM_EPSILON_32 1e-5f
union IEEE754Bits64 {
vtkm::UInt64 bits;
vtkm::Float64 scalar;
};
#define VTKM_NAN_BITS_64 0x7FF8000000000000LL
#define VTKM_INF_BITS_64 0x7FF0000000000000LL
#define VTKM_NEG_INF_BITS_64 0xFFF0000000000000LL
#define VTKM_NAN_BITS_64 0x7FF8000000000000ULL
#define VTKM_INF_BITS_64 0x7FF0000000000000ULL
#define VTKM_NEG_INF_BITS_64 0xFFF0000000000000ULL
#define VTKM_EPSILON_64 1e-9
template<typename T> struct FloatLimits;
@ -787,7 +857,9 @@ template<typename T>
static inline VTKM_EXEC_CONT
bool IsNan(T x)
{
#ifndef VTKM_CUDA
using std::isnan;
#endif
return (isnan(x) != 0);
}
@ -797,7 +869,9 @@ template<typename T>
static inline VTKM_EXEC_CONT
bool IsInf(T x)
{
#ifndef VTKM_CUDA
using std::isinf;
#endif
return (isinf(x) != 0);
}
@ -807,7 +881,9 @@ template<typename T>
static inline VTKM_EXEC_CONT
bool IsFinite(T x)
{
#ifndef VTKM_CUDA
using std::isfinite;
#endif
return (isfinite(x) != 0);
}
@ -918,7 +994,63 @@ vtkm::Int64 Abs(vtkm::Int64 x)
#error Unknown size of Int64.
#endif
}
$unary_math_function('Abs', 'fabs')\
static inline VTKM_EXEC_CONT
vtkm::Float32 Abs(vtkm::Float32 x) {
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(fabs)(x);
#else
return std::fabs(x);
#endif
}
static inline VTKM_EXEC_CONT
vtkm::Float64 Abs(vtkm::Float64 x) {
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(fabs)(x);
#else
return std::fabs(x);
#endif
}
template<typename T>
static inline VTKM_EXEC_CONT
typename detail::FloatingPointReturnType<T>::Type
Abs(T x) {
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(fabs)(static_cast<vtkm::Float64>(x));
#else
return std::fabs(static_cast<vtkm::Float64>(x));
#endif
}
template<typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,N> Abs(const vtkm::Vec<T,N> &x) {
vtkm::Vec<T,N> result;
for (vtkm::IdComponent index = 0; index < N; index++)
{
result[index] = vtkm::Abs(x[index]);
}
return result;
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,4> Abs(const vtkm::Vec<T,4> &x) {
return vtkm::Vec<T,4>(vtkm::Abs(x[0]),
vtkm::Abs(x[1]),
vtkm::Abs(x[2]),
vtkm::Abs(x[3]));
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,3> Abs(const vtkm::Vec<T,3> &x) {
return vtkm::Vec<T,3>(vtkm::Abs(x[0]),
vtkm::Abs(x[1]),
vtkm::Abs(x[2]));
}
template<typename T>
static inline VTKM_EXEC_CONT
vtkm::Vec<T,2> Abs(const vtkm::Vec<T,2> &x) {
return vtkm::Vec<T,2>(vtkm::Abs(x[0]),
vtkm::Abs(x[1]));
}
/// Returns a nonzero value if \p x is negative.
///

@ -61,7 +61,7 @@ public:
const vtkm::Vec<ComponentType, NUM_COLUMNS> &
operator[](vtkm::IdComponent rowIndex) const {
VTKM_ASSERT(rowIndex >= 0);
VTKM_ASSERT(rowIndex < this->NUM_ROWS);
VTKM_ASSERT(rowIndex < NUM_ROWS);
return this->Components[rowIndex];
}
@ -72,7 +72,7 @@ public:
vtkm::Vec<ComponentType, NUM_COLUMNS> &
operator[](vtkm::IdComponent rowIndex) {
VTKM_ASSERT(rowIndex >= 0);
VTKM_ASSERT(rowIndex < this->NUM_ROWS);
VTKM_ASSERT(rowIndex < NUM_ROWS);
return this->Components[rowIndex];
}
@ -83,9 +83,9 @@ public:
const ComponentType &
operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) const {
VTKM_ASSERT(rowIndex >= 0);
VTKM_ASSERT(rowIndex < this->NUM_ROWS);
VTKM_ASSERT(rowIndex < NUM_ROWS);
VTKM_ASSERT(colIndex >= 0);
VTKM_ASSERT(colIndex < this->NUM_COLUMNS);
VTKM_ASSERT(colIndex < NUM_COLUMNS);
return (*this)[rowIndex][colIndex];
}
@ -96,9 +96,9 @@ public:
ComponentType &
operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) {
VTKM_ASSERT(rowIndex >= 0);
VTKM_ASSERT(rowIndex < this->NUM_ROWS);
VTKM_ASSERT(rowIndex < NUM_ROWS);
VTKM_ASSERT(colIndex >= 0);
VTKM_ASSERT(colIndex < this->NUM_COLUMNS);
VTKM_ASSERT(colIndex < NUM_COLUMNS);
return (*this)[rowIndex][colIndex];
}

@ -131,7 +131,9 @@ struct TypeTraits<vtkm::Vec<T,Size> >
VTKM_EXEC_CONT
static vtkm::Vec<T,Size> ZeroInitialization()
{ return vtkm::Vec<T,Size>( (T()) ); }
{
return vtkm::Vec<T,Size>(vtkm::TypeTraits<T>::ZeroInitialization());
}
};
/// Traits for VecCConst types.

@ -256,6 +256,9 @@ struct BindLeftBinaryOp
return static_cast<ReturnT>(this->BinaryOp(this->LeftValue,
static_cast<T>(rightValue)));
}
private:
void operator=(const BindLeftBinaryOp<T,BinaryOpType,ReturnT> &) = delete;
};
template<typename T, typename BinaryOpType, typename ReturnT = T>
@ -275,6 +278,9 @@ struct BindRightBinaryOp
return static_cast<ReturnT>(this->BinaryOp(static_cast<T>(leftValue),
this->RightValue));
}
private:
void operator=(const BindRightBinaryOp<T,BinaryOpType,ReturnT> &) = delete;
};
} // namespace internal
@ -342,13 +348,13 @@ struct Negate
// Pre declaration
template <typename T, vtkm::IdComponent Size>
class Vec;
class VTKM_ALWAYS_EXPORT Vec;
template<typename T>
class VecC;
class VTKM_ALWAYS_EXPORTVecC;
template<typename T>
class VecCConst;
class VTKM_ALWAYS_EXPORT VecCConst;
namespace detail {
@ -371,7 +377,7 @@ namespace detail {
#endif // gcc || clang
#endif // use cuda < 8
template <typename T, typename DerivedClass>
class VecBaseCommon
class VTKM_ALWAYS_EXPORT VecBaseCommon
{
public:
typedef T ComponentType;
@ -647,7 +653,7 @@ public:
/// Base implementation of all Vec classes.
///
template <typename T, vtkm::IdComponent Size, typename DerivedClass>
class VecBase : public vtkm::detail::VecBaseCommon<T, DerivedClass>
class VTKM_ALWAYS_EXPORT VecBase : public vtkm::detail::VecBaseCommon<T, DerivedClass>
{
public:
typedef T ComponentType;
@ -689,14 +695,14 @@ public:
const ComponentType& operator[](vtkm::IdComponent idx) const
{
VTKM_ASSERT(idx >= 0);
VTKM_ASSERT(idx < this->NUM_COMPONENTS);
VTKM_ASSERT(idx < NUM_COMPONENTS);
return this->Components[idx];
}
VTKM_EXEC_CONT
ComponentType& operator[](vtkm::IdComponent idx)
{
VTKM_ASSERT(idx >= 0);
VTKM_ASSERT(idx < this->NUM_COMPONENTS);
VTKM_ASSERT(idx < NUM_COMPONENTS);
return this->Components[idx];
}
@ -792,7 +798,7 @@ protected:
/// Base of all VecC and VecCConst classes.
///
template <typename T, typename DerivedClass>
class VecCBase : public vtkm::detail::VecBaseCommon<T, DerivedClass>
class VTKM_ALWAYS_EXPORT VecCBase : public vtkm::detail::VecBaseCommon<T, DerivedClass>
{
protected:
VTKM_EXEC_CONT
@ -821,7 +827,7 @@ protected:
/// designed for small sequences (seldom more than 10).
///
template<typename T, vtkm::IdComponent Size>
class Vec : public detail::VecBase<T, Size, Vec<T,Size> >
class VTKM_ALWAYS_EXPORT Vec : public detail::VecBase<T, Size, Vec<T,Size> >
{
typedef detail::VecBase<T, Size, Vec<T,Size> > Superclass;
public:
@ -846,7 +852,7 @@ public:
// zero length array which troubles compilers. Vecs of size 0 are a bit
// pointless but might occur in some generic functions or classes.
template<typename T>
class Vec<T, 0>
class VTKM_ALWAYS_EXPORT Vec<T, 0>
{
public:
typedef T ComponentType;
@ -886,7 +892,7 @@ public:
// Vectors of size 1 should implicitly convert between the scalar and the
// vector. Otherwise, it should behave the same.
template<typename T>
class Vec<T,1> : public detail::VecBase<T, 1, Vec<T,1> >
class VTKM_ALWAYS_EXPORT Vec<T,1> : public detail::VecBase<T, 1, Vec<T,1> >
{
typedef detail::VecBase<T, 1, Vec<T,1> > Superclass;
@ -910,7 +916,7 @@ public:
// Specializations for common tuple sizes (with special names).
template<typename T>
class Vec<T,2> : public detail::VecBase<T, 2, Vec<T,2> >
class VTKM_ALWAYS_EXPORT Vec<T,2> : public detail::VecBase<T, 2, Vec<T,2> >
{
typedef detail::VecBase<T, 2, Vec<T,2> > Superclass;
@ -934,7 +940,7 @@ typedef vtkm::Vec<vtkm::Id,2> Id2;
template<typename T>
class Vec<T,3> : public detail::VecBase<T, 3, Vec<T,3> >
class VTKM_ALWAYS_EXPORT Vec<T,3> : public detail::VecBase<T, 3, Vec<T,3> >
{
typedef detail::VecBase<T, 3, Vec<T,3> > Superclass;
public:
@ -959,7 +965,7 @@ typedef vtkm::Vec<vtkm::Id,3> Id3;
template<typename T>
class Vec<T,4> : public detail::VecBase<T, 4, Vec<T,4> >
class VTKM_ALWAYS_EXPORT Vec<T,4> : public detail::VecBase<T, 4, Vec<T,4> >
{
typedef detail::VecBase<T, 4, Vec<T,4> > Superclass;
public:
@ -1040,7 +1046,7 @@ vtkm::Vec<T,4> make_Vec(const T &x, const T &y, const T &z, const T &w)
/// <tt>VecCConst<vtkm::Id></tt>).
///
template<typename T>
class VecC : public detail::VecCBase<T, VecC<T> >
class VTKM_ALWAYS_EXPORT VecC : public detail::VecCBase<T, VecC<T> >
{
using Superclass = detail::VecCBase<T, VecC<T> >;
@ -1129,7 +1135,7 @@ private:
/// need to be changed.
///
template<typename T>
class VecCConst : public detail::VecCBase<T, VecCConst<T> >
class VTKM_ALWAYS_EXPORT VecCConst : public detail::VecCBase<T, VecCConst<T> >
{
using Superclass = detail::VecCBase<T, VecCConst<T> >;
@ -1194,16 +1200,18 @@ private:
// You are not allowed to assign to a VecCConst, so these operators are not
// implemented and are disallowed.
void operator=(const VecCConst<T> &);
void operator+=(const VecCConst<T> &);
void operator-=(const VecCConst<T> &);
void operator*=(const VecCConst<T> &);
void operator/=(const VecCConst<T> &);
void operator=(const VecCConst<T> &) = delete;
void operator+=(const VecCConst<T> &) = delete;
void operator-=(const VecCConst<T> &) = delete;
void operator*=(const VecCConst<T> &) = delete;
void operator/=(const VecCConst<T> &) = delete;
};
/// Creates a \c VecC from an input array.
///
template<typename T>
VTKM_EXEC_CONT
static inline
vtkm::VecC<T> make_VecC(T *array, vtkm::IdComponent size)
{
return vtkm::VecC<T>(array, size);
@ -1212,6 +1220,8 @@ vtkm::VecC<T> make_VecC(T *array, vtkm::IdComponent size)
/// Creates a \c VecCConst from a constant input array.
///
template<typename T>
VTKM_EXEC_CONT
static inline
vtkm::VecCConst<T> make_VecC(const T *array, vtkm::IdComponent size)
{
return vtkm::VecCConst<T>(array, size);

@ -85,18 +85,20 @@ MagnitudeSquared(const T &x)
namespace detail {
template<typename T>
VTKM_EXEC_CONT
T MagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
typename detail::FloatingPointReturnType<T>::Type
MagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
{
return vtkm::Abs(x);
return static_cast<typename detail::FloatingPointReturnType<T>::Type>(vtkm::Abs(x));
}
template<typename T>
VTKM_EXEC_CONT
typename vtkm::VecTraits<T>::ComponentType
typename detail::FloatingPointReturnType<T>::Type
MagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
{
return vtkm::Sqrt(vtkm::MagnitudeSquared(x));
}
} // namespace detail
/// \brief Returns the magnitude of a vector.
@ -109,7 +111,7 @@ MagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
///
template<typename T>
VTKM_EXEC_CONT
typename vtkm::VecTraits<T>::ComponentType
typename detail::FloatingPointReturnType<T>::Type
Magnitude(const T &x)
{
return detail::MagnitudeTemplate(
@ -120,14 +122,15 @@ Magnitude(const T &x)
namespace detail {
template<typename T>
VTKM_EXEC_CONT
T RMagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
typename detail::FloatingPointReturnType<T>::Type
RMagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
{
return T(1)/vtkm::Abs(x);
}
template<typename T>
VTKM_EXEC_CONT
typename vtkm::VecTraits<T>::ComponentType
typename detail::FloatingPointReturnType<T>::Type
RMagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
{
return vtkm::RSqrt(vtkm::MagnitudeSquared(x));
@ -141,7 +144,7 @@ RMagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
///
template<typename T>
VTKM_EXEC_CONT
typename vtkm::VecTraits<T>::ComponentType
typename detail::FloatingPointReturnType<T>::Type
RMagnitude(const T &x)
{
return detail::RMagnitudeTemplate(
@ -194,11 +197,12 @@ void Normalize(T &x)
///
template<typename T>
VTKM_EXEC_CONT
vtkm::Vec<T,3> Cross(const vtkm::Vec<T,3> &x, const vtkm::Vec<T,3> &y)
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>
Cross(const vtkm::Vec<T,3> &x, const vtkm::Vec<T,3> &y)
{
return vtkm::Vec<T,3>(x[1]*y[2] - x[2]*y[1],
x[2]*y[0] - x[0]*y[2],
x[0]*y[1] - x[1]*y[0]);
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>(x[1]*y[2] - x[2]*y[1],
x[2]*y[0] - x[0]*y[2],
x[0]*y[1] - x[1]*y[0]);
}
//-----------------------------------------------------------------------------
@ -210,9 +214,10 @@ vtkm::Vec<T,3> Cross(const vtkm::Vec<T,3> &x, const vtkm::Vec<T,3> &y)
///
template<typename T>
VTKM_EXEC_CONT
vtkm::Vec<T,3> TriangleNormal(const vtkm::Vec<T,3> &a,
const vtkm::Vec<T,3> &b,
const vtkm::Vec<T,3> &c)
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>
TriangleNormal(const vtkm::Vec<T,3> &a,
const vtkm::Vec<T,3> &b,
const vtkm::Vec<T,3> &c)
{
return vtkm::Cross(b-a, c-a);
}

29
vtkm/Version.h.in Normal file

@ -0,0 +1,29 @@
//============================================================================
// 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_Version_h
#define vtk_m_Version_h
#define VTKM_VERSION_MAJOR @VTKm_VERSION_MAJOR@
#define VTKM_VERSION_MINOR @VTKm_VERSION_MINOR@
#define VTKM_VERSION_PATCH @VTKm_VERSION_PATCH@
#define VTKM_VERSION_FULL "@VTKm_VERSION_FULL@"
#define VTKM_VERSION "@VTKm_VERSION@"
#endif //vtk_m_Version_h

@ -49,20 +49,19 @@ namespace benchmarking {
const static std::string DIVIDER(40, '-');
enum BenchmarkName {
LOWER_BOUNDS = 1,
REDUCE = 1 << 1,
REDUCE_BY_KEY = 1 << 2,
SCAN_INCLUSIVE = 1 << 3,
SCAN_EXCLUSIVE = 1 << 4,
SORT = 1 << 5,
SORT_BY_KEY = 1 << 6,
STREAM_COMPACT = 1 << 7,
UNIQUE = 1 << 8,
UPPER_BOUNDS = 1 << 9,
COPY = 1 << 10,
ALL = LOWER_BOUNDS | REDUCE | REDUCE_BY_KEY | SCAN_INCLUSIVE
| SCAN_EXCLUSIVE | SORT | SORT_BY_KEY | STREAM_COMPACT | UNIQUE
| UPPER_BOUNDS | COPY
COPY = 1,
COPY_IF = 1 << 1,
LOWER_BOUNDS = 1 << 2,
REDUCE = 1 << 3,
REDUCE_BY_KEY = 1 << 4,
SCAN_INCLUSIVE = 1 << 5,
SCAN_EXCLUSIVE = 1 << 6,
SORT = 1 << 7,
SORT_BY_KEY = 1 << 8,
UNIQUE = 1 << 9,
UPPER_BOUNDS = 1 << 10,
ALL = COPY | COPY_IF | LOWER_BOUNDS | REDUCE | REDUCE_BY_KEY | SCAN_INCLUSIVE
| SCAN_EXCLUSIVE | SORT | SORT_BY_KEY | UNIQUE | UPPER_BOUNDS
};
/// This class runs a series of micro-benchmarks to measure
@ -183,6 +182,47 @@ private:
};
VTKM_MAKE_BENCHMARK(Copy, BenchCopy);
template<typename Value>
struct BenchCopyIf {
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
const vtkm::Id N_VALID;
ValueArrayHandle ValueHandle, OutHandle;
IdArrayHandle StencilHandle;
VTKM_CONT
BenchCopyIf(vtkm::Id percent_valid) : N_VALID((ARRAY_SIZE * percent_valid) / 100)
{
vtkm::Id modulo = ARRAY_SIZE / N_VALID;
Algorithm::Schedule(FillTestValueKernel<Value>(
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
Algorithm::Schedule(FillBinaryTestValueKernel<vtkm::Id>(modulo,
StencilHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
}
VTKM_CONT
vtkm::Float64 operator()() {
Timer timer;
Algorithm::CopyIf(ValueHandle, StencilHandle, OutHandle);
return timer.GetElapsedTime();
}
VTKM_CONT
std::string Description() const {
std::stringstream description;
description << "CopyIf on " << ARRAY_SIZE << " "
<< " values with " << OutHandle.GetNumberOfValues()
<< " valid values";
return description.str();
}
};
VTKM_MAKE_BENCHMARK(CopyIf5, BenchCopyIf, 5);
VTKM_MAKE_BENCHMARK(CopyIf10, BenchCopyIf, 10);
VTKM_MAKE_BENCHMARK(CopyIf15, BenchCopyIf, 15);
VTKM_MAKE_BENCHMARK(CopyIf20, BenchCopyIf, 20);
VTKM_MAKE_BENCHMARK(CopyIf25, BenchCopyIf, 25);
VTKM_MAKE_BENCHMARK(CopyIf30, BenchCopyIf, 30);
template<typename Value>
struct BenchLowerBounds {
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
@ -418,86 +458,6 @@ private:
VTKM_MAKE_BENCHMARK(SortByKey25, BenchSortByKey, 25);
VTKM_MAKE_BENCHMARK(SortByKey30, BenchSortByKey, 30);
template<typename Value>
struct BenchStreamCompact {
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
const vtkm::Id N_VALID;
ValueArrayHandle ValueHandle;
IdArrayHandle OutHandle;
VTKM_CONT
BenchStreamCompact(vtkm::Id percent_valid) : N_VALID((ARRAY_SIZE * percent_valid) / 100)
{
vtkm::Id modulo = ARRAY_SIZE / N_VALID;
Algorithm::Schedule(FillBinaryTestValueKernel<Value>(modulo,
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
}
VTKM_CONT
vtkm::Float64 operator()() {
Timer timer;
Algorithm::StreamCompact(ValueHandle, OutHandle);
return timer.GetElapsedTime();
}
VTKM_CONT
std::string Description() const {
std::stringstream description;
description << "StreamCompact on " << ARRAY_SIZE << " "
<< " values with " << OutHandle.GetNumberOfValues()
<< " valid values";
return description.str();
}
};
VTKM_MAKE_BENCHMARK(StreamCompact5, BenchStreamCompact, 5);
VTKM_MAKE_BENCHMARK(StreamCompact10, BenchStreamCompact, 10);
VTKM_MAKE_BENCHMARK(StreamCompact15, BenchStreamCompact, 15);
VTKM_MAKE_BENCHMARK(StreamCompact20, BenchStreamCompact, 20);
VTKM_MAKE_BENCHMARK(StreamCompact25, BenchStreamCompact, 25);
VTKM_MAKE_BENCHMARK(StreamCompact30, BenchStreamCompact, 30);
template<typename Value>
struct BenchStreamCompactStencil {
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
const vtkm::Id N_VALID;
ValueArrayHandle ValueHandle;
IdArrayHandle StencilHandle, OutHandle;
VTKM_CONT
BenchStreamCompactStencil(vtkm::Id percent_valid) : N_VALID((ARRAY_SIZE * percent_valid) / 100)
{
vtkm::Id modulo = ARRAY_SIZE / N_VALID;
Algorithm::Schedule(FillTestValueKernel<Value>(
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
Algorithm::Schdule(FillBinaryTestValueKernel<vtkm::Id>(modulo,
StencilHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
}
VTKM_CONT
vtkm::Float64 operator()() {
Timer timer;
Algorithm::StreamCompact(ValueHandle, StencilHandle, OutHandle);
return timer.GetElapsedTime();
}
VTKM_CONT
std::string Description() const {
std::stringstream description;
description << "StreamCompactStencil on " << ARRAY_SIZE << " "
<< " values with " << OutHandle.GetNumberOfValues()
<< " valid values";
return description.str();
}
};
VTKM_MAKE_BENCHMARK(StreamCompactStencil5, BenchStreamCompactStencil, 5);
VTKM_MAKE_BENCHMARK(StreamCompactStencil10, BenchStreamCompactStencil, 10);
VTKM_MAKE_BENCHMARK(StreamCompactStencil15, BenchStreamCompactStencil, 15);
VTKM_MAKE_BENCHMARK(StreamCompactStencil20, BenchStreamCompactStencil, 20);
VTKM_MAKE_BENCHMARK(StreamCompactStencil25, BenchStreamCompactStencil, 25);
VTKM_MAKE_BENCHMARK(StreamCompactStencil30, BenchStreamCompactStencil, 30);
template<typename Value>
struct BenchUnique {
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
@ -589,6 +549,16 @@ public:
VTKM_RUN_BENCHMARK(Copy, ValueTypes());
}
if (benchmarks & COPY_IF){
std::cout << "\n" << DIVIDER << "\nBenchmarking CopyIf\n";
VTKM_RUN_BENCHMARK(CopyIf5, ValueTypes());
VTKM_RUN_BENCHMARK(CopyIf10, ValueTypes());
VTKM_RUN_BENCHMARK(CopyIf15, ValueTypes());
VTKM_RUN_BENCHMARK(CopyIf20, ValueTypes());
VTKM_RUN_BENCHMARK(CopyIf25, ValueTypes());
VTKM_RUN_BENCHMARK(CopyIf30, ValueTypes());
}
if (benchmarks & LOWER_BOUNDS){
std::cout << DIVIDER << "\nBenchmarking LowerBounds\n";
VTKM_RUN_BENCHMARK(LowerBounds5, ValueTypes());
@ -639,16 +609,6 @@ public:
VTKM_RUN_BENCHMARK(SortByKey30, ValueTypes());
}
if (benchmarks & STREAM_COMPACT){
std::cout << "\n" << DIVIDER << "\nBenchmarking StreamCompact\n";
VTKM_RUN_BENCHMARK(StreamCompact5, ValueTypes());
VTKM_RUN_BENCHMARK(StreamCompact10, ValueTypes());
VTKM_RUN_BENCHMARK(StreamCompact15, ValueTypes());
VTKM_RUN_BENCHMARK(StreamCompact20, ValueTypes());
VTKM_RUN_BENCHMARK(StreamCompact25, ValueTypes());
VTKM_RUN_BENCHMARK(StreamCompact30, ValueTypes());
}
if (benchmarks & UNIQUE){
std::cout << "\n" << DIVIDER << "\nBenchmarking Unique\n";
VTKM_RUN_BENCHMARK(Unique5, ValueTypes());
@ -687,7 +647,13 @@ int main(int argc, char *argv[])
for (int i = 1; i < argc; ++i){
std::string arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower);
if (arg == "lowerbounds"){
if (arg == "copy"){
benchmarks |= vtkm::benchmarking::COPY;
}
else if (arg == "copyif"){
benchmarks |= vtkm::benchmarking::COPY_IF;
}
else if (arg == "lowerbounds"){
benchmarks |= vtkm::benchmarking::LOWER_BOUNDS;
}
else if (arg == "reduce"){
@ -708,18 +674,12 @@ int main(int argc, char *argv[])
else if (arg == "sortbykey"){
benchmarks |= vtkm::benchmarking::SORT_BY_KEY;
}
else if (arg == "streamcompact"){
benchmarks |= vtkm::benchmarking::STREAM_COMPACT;
}
else if (arg == "unique"){
benchmarks |= vtkm::benchmarking::UNIQUE;
}
else if (arg == "upperbounds"){
benchmarks |= vtkm::benchmarking::UPPER_BOUNDS;
}
else if (arg == "copy"){
benchmarks |= vtkm::benchmarking::COPY;
}
else {
std::cout << "Unrecognized benchmark: " << argv[i] << std::endl;
return 1;

@ -221,6 +221,7 @@ private:
dispatcher.Invoke( this->InputHandle,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}
@ -257,6 +258,7 @@ private:
dispatcher.Invoke( dinput,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}
@ -301,6 +303,7 @@ private:
dispatcher.Invoke( this->InputHandle,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}
@ -336,6 +339,7 @@ private:
dispatcher.Invoke( dinput,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}
@ -385,6 +389,7 @@ private:
dispatcher.Invoke( dinput,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}
@ -418,6 +423,7 @@ private:
dispatcher.Invoke( this->InputHandle,
cellSet,
result);
//result.SyncControlArray();
return timer.GetElapsedTime();
}

86
vtkm/cont/ArrayHandle.cxx Normal file

@ -0,0 +1,86 @@
//============================================================================
// 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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.
//============================================================================
#define vtkm_cont_ArrayHandle_cxx
#include <vtkm/cont/ArrayHandle.h>
#ifdef VTKM_MSVC
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<char, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int16, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt16, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int32, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt32, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int64, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt64, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int64,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int32,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int64,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int32,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<char,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int8,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::UInt8,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
#endif
namespace vtkm {
namespace cont {
template class VTKM_CONT_EXPORT ArrayHandle<char, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Int8, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::UInt8, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Int16, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::UInt16, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Int32, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::UInt32, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Int64, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::UInt64, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Float32, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Float64, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int64,2>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int32,2>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,2>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,2>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int64,3>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int32,3>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,3>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,3>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<char,4>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int8,4>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::UInt8,4>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,4>, StorageTagBasic>;
template class VTKM_CONT_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,4>, StorageTagBasic>;
}
}

@ -20,12 +20,14 @@
#ifndef vtk_m_cont_ArrayHandle_h
#define vtk_m_cont_ArrayHandle_h
#include <vtkm/cont/vtkm_cont_export.h>
#include <vtkm/Assert.h>
#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>
@ -36,7 +38,6 @@
#include <vector>
#include <iterator>
namespace vtkm {
namespace cont {
@ -48,7 +49,7 @@ namespace internal {
/// ArrayHandle class (or at least something that behaves exactly like one).
/// The \c ArrayHandle template class inherits from this.
///
class ArrayHandleBase { };
class VTKM_CONT_EXPORT ArrayHandleBase { };
/// Checks to see if the given type and storage can form a valid array handle
/// (some storage objects cannot support all types). This check is compatible
@ -141,9 +142,6 @@ struct GetTypeInParentheses<void(T)>
classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, typename__ Superclass::StorageTag> &src) : Superclass(src) { } \
\
VTKM_CONT \
virtual ~classname() { } \
\
VTKM_CONT \
Thisclass &operator=(const Thisclass &src) \
{ \
this->Superclass::operator=(src); \
@ -224,7 +222,7 @@ struct GetTypeInParentheses<void(T)>
template<
typename T,
typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
class ArrayHandle : public internal::ArrayHandleBase
class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
{
private:
typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase<T,StorageTag_>
@ -247,11 +245,7 @@ public:
/// Constructs an empty ArrayHandle. Typically used for output or
/// intermediate arrays that will be filled by a VTKm algorithm.
///
VTKM_CONT ArrayHandle() : Internals(new InternalStruct)
{
this->Internals->ControlArrayValid = false;
this->Internals->ExecutionArrayValid = false;
}
VTKM_CONT ArrayHandle();
/// Copy constructor.
///
@ -260,22 +254,23 @@ public:
/// with CUDA), then the automatically generated copy constructor could be
/// created for all devices, and it would not be valid for all devices.
///
VTKM_CONT
ArrayHandle(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src)
: Internals(src.Internals)
{ }
ArrayHandle(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src);
/// Move constructor.
///
/// Implemented so that it is defined exclusively in the control environment.
/// If there is a separate device for the execution environment (for example,
/// with CUDA), then the automatically generated move constructor could be
/// created for all devices, and it would not be valid for all devices.
///
ArrayHandle(vtkm::cont::ArrayHandle<ValueType,StorageTag> &&src);
/// Special constructor for subclass specializations that need to set the
/// initial state of the control array. When this constructor is used, it
/// is assumed that the control array is valid.
///
ArrayHandle(const StorageType &storage)
: Internals(new InternalStruct)
{
this->Internals->ControlArray = storage;
this->Internals->ControlArrayValid = true;
this->Internals->ExecutionArrayValid = false;
}
ArrayHandle(const StorageType &storage);
/// Destructs an empty ArrayHandle.
///
@ -284,154 +279,66 @@ public:
/// with CUDA), then the automatically generated destructor could be
/// created for all devices, and it would not be valid for all devices.
///
virtual ~ArrayHandle() { }
~ArrayHandle();
/// \brief Copies an ArrayHandle
///
VTKM_CONT
vtkm::cont::ArrayHandle<ValueType,StorageTag> &
operator=(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src)
operator=(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src);
/// \brief Move and Assignment of an ArrayHandle
///
VTKM_CONT
vtkm::cont::ArrayHandle<ValueType,StorageTag> &
operator=(vtkm::cont::ArrayHandle<ValueType,StorageTag> &&src);
/// Like a pointer, two \c ArrayHandles are considered equal if they point
/// to the same location in memory.
///
VTKM_CONT
bool operator==(const ArrayHandle<ValueType,StorageTag> &rhs) const
{
this->Internals = src.Internals;
return *this;
return (this->Internals == rhs.Internals);
}
VTKM_CONT
bool operator!=(const ArrayHandle<ValueType,StorageTag> &rhs) const
{
return (this->Internals != rhs.Internals);
}
/// Get the storage.
///
VTKM_CONT StorageType& GetStorage()
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
VTKM_CONT StorageType& GetStorage();
/// Get the storage.
///
VTKM_CONT const StorageType& GetStorage() const
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
VTKM_CONT const StorageType& GetStorage() const;
/// Get the array portal of the control array.
///
VTKM_CONT PortalControl GetPortalControl()
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
// If the user writes into the iterator we return, then the execution
// array will become invalid. Play it safe and release the execution
// resources. (Use the const version to preserve the execution array.)
this->ReleaseResourcesExecutionInternal();
return this->Internals->ControlArray.GetPortal();
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
VTKM_CONT PortalControl GetPortalControl();
/// Get the array portal of the control array.
///
VTKM_CONT PortalConstControl GetPortalConstControl() const
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray.GetPortalConst();
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
VTKM_CONT PortalConstControl GetPortalConstControl() const;
/// Returns the number of entries in the array.
///
VTKM_CONT vtkm::Id GetNumberOfValues() const
{
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray.GetNumberOfValues();
}
else if (this->Internals->ExecutionArrayValid)
{
return this->Internals->ExecutionArray->GetNumberOfValues();
}
else
{
return 0;
}
}
VTKM_CONT vtkm::Id GetNumberOfValues() const;
/// Copies data into the given iterator for the control environment. This
/// method can skip copying into an internally managed control array.
///
template<typename IteratorType, typename DeviceAdapterTag>
VTKM_CONT void CopyInto(IteratorType dest, DeviceAdapterTag) const
{
using pointer_type = typename std::iterator_traits<IteratorType>::pointer;
using value_type = typename std::remove_pointer<pointer_type>::type;
static_assert( !std::is_const<value_type>::value,
"CopyInto requires a non const iterator." );
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid &&
!this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandle has no data to copy into Iterator.");
}
if (!this->Internals->ControlArrayValid &&
this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
{
/// Dynamically cast ArrayHandleExecutionManagerBase into a concrete
/// class and call CopyInto. The dynamic conversion will be sucessful
/// becuase the check to ensure the ExecutionArray is of the type
/// DeviceAdapterTag has already passed
typedef vtkm::cont::internal::ArrayHandleExecutionManager<
T, StorageTag, DeviceAdapterTag> ConcreteType;
ConcreteType *ConcreteExecutionArray =
dynamic_cast<ConcreteType*>(this->Internals->ExecutionArray.get());
ConcreteExecutionArray->CopyInto(dest);
}
else
{
PortalConstControl portal = this->GetPortalConstControl();
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(portal),
vtkm::cont::ArrayPortalToIteratorEnd(portal),
dest);
}
}
VTKM_CONT void CopyInto(IteratorType dest, DeviceAdapterTag) const;
/// \brief Allocates an array large enough to hold the given number of values.
///
/// 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
@ -450,33 +357,7 @@ public:
/// \c numberOfValues must be equal or less than the preexisting size
/// (returned from GetNumberOfValues). That is, this method can only be used
/// to shorten the array, not lengthen.
void Shrink(vtkm::Id numberOfValues)
{
vtkm::Id originalNumberOfValues = this->GetNumberOfValues();
if (numberOfValues < originalNumberOfValues)
{
if (this->Internals->ControlArrayValid)
{
this->Internals->ControlArray.Shrink(numberOfValues);
}
if (this->Internals->ExecutionArrayValid)
{
this->Internals->ExecutionArray->Shrink(numberOfValues);
}
}
else if (numberOfValues == originalNumberOfValues)
{
// Nothing to do.
}
else // numberOfValues > originalNumberOfValues
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandle::Shrink cannot be used to grow array.");
}
VTKM_ASSERT(this->GetNumberOfValues() == numberOfValues);
}
void Shrink(vtkm::Id numberOfValues);
/// Releases any resources being used in the execution environment (that are
/// not being shared by the control environment).
@ -512,26 +393,7 @@ public:
template<typename DeviceAdapterTag>
VTKM_CONT
typename ExecutionTypes<DeviceAdapterTag>::PortalConst
PrepareForInput(DeviceAdapterTag) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandle has no data when PrepareForInput called.");
}
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::PortalConst portal =
this->Internals->ExecutionArray->PrepareForInput(
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
this->Internals->ExecutionArrayValid = true;
return portal;
}
PrepareForInput(DeviceAdapterTag) const;
/// Prepares (allocates) this array to be used as an output from an operation
/// in the execution environment. The internal state of this class is set to
@ -543,33 +405,7 @@ public:
template<typename DeviceAdapterTag>
VTKM_CONT
typename ExecutionTypes<DeviceAdapterTag>::Portal
PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag)
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
// Invalidate any control arrays.
// Should the control array resource be released? Probably not a good
// idea when shared with execution.
this->Internals->ControlArrayValid = false;
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
this->Internals->ExecutionArray->PrepareForOutput(numberOfValues,
DeviceAdapterTag());
// We are assuming that the calling code will fill the array using the
// iterators we are returning, so go ahead and mark the execution array as
// having valid data. (A previous version of this class had a separate call
// to mark the array as filled, but that was onerous to call at the the
// right time and rather pointless since it is basically always the case
// that the array is going to be filled before anything else. In this
// implementation the only access to the array is through the iterators
// returned from this method, so you would have to work to invalidate this
// assumption anyway.)
this->Internals->ExecutionArrayValid = true;
return portal;
}
PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag);
/// Prepares this array to be used in an in-place operation (both as input
/// and output) in the execution environment. If necessary, copies data to
@ -580,48 +416,36 @@ public:
template<typename DeviceAdapterTag>
VTKM_CONT
typename ExecutionTypes<DeviceAdapterTag>::Portal
PrepareForInPlace(DeviceAdapterTag)
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
PrepareForInPlace(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandle has no data when PrepareForInPlace called.");
}
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
this->Internals->ExecutionArray->PrepareForInPlace(
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
this->Internals->ExecutionArrayValid = true;
// Invalidate any control arrays since their data will become invalid when
// the execution data is overwritten. Don't actually release the control
// array. It may be shared as the execution array.
this->Internals->ControlArrayValid = false;
return portal;
}
/// Like a pointer, two \c ArrayHandles are considered equal if they point
/// to the same location in memory.
/// Gets this array handle ready to interact with the given device. If the
/// array handle has already interacted with this device, then this method
/// does nothing. Although the internal state of this class can change, the
/// method is declared const because logically the data does not.
///
template<typename DeviceAdapterTag>
VTKM_CONT
bool operator==(const ArrayHandle<ValueType,StorageTag> &rhs) const
{
return (this->Internals.get() == rhs.Internals.get());
}
void PrepareForDevice(DeviceAdapterTag) const;
/// Synchronizes the control array with the execution array. If either the
/// user array or control array is already valid, this method does nothing
/// (because the data is already available in the control environment).
/// Although the internal state of this class can change, the method is
/// declared const because logically the data does not.
///
VTKM_CONT void SyncControlArray() const;
VTKM_CONT
bool operator!=(const ArrayHandle<ValueType,StorageTag> &rhs) const
void ReleaseResourcesExecutionInternal()
{
return (this->Internals.get() != rhs.Internals.get());
if (this->Internals->ExecutionArrayValid)
{
this->Internals->ExecutionArray->ReleaseResources();
this->Internals->ExecutionArrayValid = false;
}
}
// private:
struct InternalStruct
struct VTKM_ALWAYS_EXPORT InternalStruct
{
StorageType ControlArray;
bool ControlArrayValid;
@ -637,91 +461,6 @@ public:
: Internals(i)
{ }
/// Gets this array handle ready to interact with the given device. If the
/// array handle has already interacted with this device, then this method
/// does nothing. Although the internal state of this class can change, the
/// method is declared const because logically the data does not.
///
template<typename DeviceAdapterTag>
VTKM_CONT
void PrepareForDevice(DeviceAdapterTag) const
{
if (this->Internals->ExecutionArray != nullptr)
{
if (this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
{
// Already have manager for correct device adapter. Nothing to do.
return;
}
else
{
// Have the wrong manager. Delete the old one and create a new one
// of the right type. (BTW, it would be possible for the array handle
// to hold references to execution arrays on multiple devices. However,
// there is not a clear use case for that yet and it is unclear what
// the behavior of "dirty" arrays should be, so it is not currently
// implemented.)
this->SyncControlArray();
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
internals->ExecutionArray.reset();
internals->ExecutionArrayValid = false;
}
}
VTKM_ASSERT(this->Internals->ExecutionArray == nullptr);
VTKM_ASSERT(!this->Internals->ExecutionArrayValid);
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
internals->ExecutionArray.reset(
new vtkm::cont::internal::ArrayHandleExecutionManager<
T, StorageTag, DeviceAdapterTag>(&internals->ControlArray));
}
/// Synchronizes the control array with the execution array. If either the
/// user array or control array is already valid, this method does nothing
/// (because the data is already available in the control environment).
/// Although the internal state of this class can change, the method is
/// declared const because logically the data does not.
///
VTKM_CONT void SyncControlArray() const
{
if (!this->Internals->ControlArrayValid)
{
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
if (this->Internals->ExecutionArrayValid)
{
internals->ExecutionArray->RetrieveOutputData(&internals->ControlArray);
internals->ControlArrayValid = true;
}
else
{
// This array is in the null state (there is nothing allocated), but
// the calling function wants to do something with the array. Put this
// class into a valid state by allocating an array of size 0.
internals->ControlArray.Allocate(0);
internals->ControlArrayValid = true;
}
}
}
VTKM_CONT
void ReleaseResourcesExecutionInternal()
{
if (this->Internals->ExecutionArrayValid)
{
this->Internals->ExecutionArray->ReleaseResources();
this->Internals->ExecutionArrayValid = false;
}
}
std::shared_ptr<InternalStruct> Internals;
};
@ -748,64 +487,207 @@ VTKM_CONT
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
make_ArrayHandle(const std::vector<T,Allocator> &array)
{
return make_ArrayHandle(&array.front(), static_cast<vtkm::Id>(array.size()));
if (!array.empty())
{
return make_ArrayHandle(&array.front(),
static_cast<vtkm::Id>(array.size()));
}
else
{
// Vector empty. Just return an empty array handle.
return vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>();
}
}
template<typename T, typename StorageT>
namespace detail {
template<typename T>
VTKM_NEVER_EXPORT
VTKM_CONT
void
inline void printSummary_ArrayHandle_Value(const T &value,
std::ostream &out,
vtkm::VecTraitsTagSingleComponent)
{
out << value;
}
template<typename T>
VTKM_NEVER_EXPORT
VTKM_CONT
inline void printSummary_ArrayHandle_Value(const T &value,
std::ostream &out,
vtkm::VecTraitsTagMultipleComponents)
{
using Traits = vtkm::VecTraits<T>;
using ComponentType = typename Traits::ComponentType;
using IsVecOfVec = typename vtkm::VecTraits<ComponentType>::HasMultipleComponents;
vtkm::IdComponent numComponents = Traits::GetNumberOfComponents(value);
out << "(";
printSummary_ArrayHandle_Value(Traits::GetComponent(value,0), out, IsVecOfVec());
for (vtkm::IdComponent index = 1; index < numComponents; ++index)
{
out << ",";
printSummary_ArrayHandle_Value(Traits::GetComponent(value,index), out, IsVecOfVec());
}
out << ")";
}
VTKM_NEVER_EXPORT
VTKM_CONT
inline void printSummary_ArrayHandle_Value(UInt8 value,
std::ostream &out,
vtkm::VecTraitsTagSingleComponent)
{
out << static_cast<int>(value);
}
VTKM_NEVER_EXPORT
VTKM_CONT
inline void printSummary_ArrayHandle_Value(Int8 value,
std::ostream &out,
vtkm::VecTraitsTagSingleComponent)
{
out << static_cast<int>(value);
}
template<typename T1, typename T2>
VTKM_NEVER_EXPORT
VTKM_CONT
inline void printSummary_ArrayHandle_Value(const vtkm::Pair<T1,T2> &value,
std::ostream &out,
vtkm::VecTraitsTagSingleComponent)
{
out << "{";
printSummary_ArrayHandle_Value(
value.first,
out,
typename vtkm::VecTraits<T1>::HasMultipleComponents());
out << ",";
printSummary_ArrayHandle_Value(
value.second,
out,
typename vtkm::VecTraits<T2>::HasMultipleComponents());
out << "}";
}
} // namespace detail
template<typename T, typename StorageT>
VTKM_NEVER_EXPORT
VTKM_CONT
inline void
printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
std::ostream &out)
{
vtkm::Id sz = array.GetNumberOfValues();
out<<"sz= "<<sz<<" [";
if (sz <= 7)
for (vtkm::Id i = 0 ; i < sz; i++)
{
out<<array.GetPortalConstControl().Get(i);
if (i != (sz-1)) out<<" ";
}
else
{
out<<array.GetPortalConstControl().Get(0)<<" ";
out<<array.GetPortalConstControl().Get(1)<<" ";
out<<array.GetPortalConstControl().Get(2);
out<<" ... ";
out<<array.GetPortalConstControl().Get(sz-3)<<" ";
out<<array.GetPortalConstControl().Get(sz-2)<<" ";
out<<array.GetPortalConstControl().Get(sz-1);
}
out<<"]";
}
using ArrayType = vtkm::cont::ArrayHandle<T,StorageT>;
using PortalType = typename ArrayType::PortalConstControl;
using IsVec = typename vtkm::VecTraits<T>::HasMultipleComponents;
template<typename StorageT>
VTKM_CONT
void
printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<vtkm::UInt8,StorageT> &array,
std::ostream &out)
{
vtkm::Id sz = array.GetNumberOfValues();
out<<"sz= "<<sz<<" [";
if (sz <= 7)
for (vtkm::Id i = 0 ; i < sz; i++)
{
out<<static_cast<int>(array.GetPortalConstControl().Get(i));
if (i != (sz-1)) out<<" ";
}
else
vtkm::Id sz = array.GetNumberOfValues();
out << "valueType=" << typeid(T).name()
<< " storageType=" << typeid(StorageT).name()
<< " numValues=" << sz
<< " [";
PortalType portal = array.GetPortalConstControl();
if (sz <= 7)
{
for (vtkm::Id i = 0 ; i < sz; i++)
{
out<<static_cast<int>(array.GetPortalConstControl().Get(0))<<" ";
out<<static_cast<int>(array.GetPortalConstControl().Get(1))<<" ";
out<<static_cast<int>(array.GetPortalConstControl().Get(2));
out<<" ... ";
out<<static_cast<int>(array.GetPortalConstControl().Get(sz-3))<<" ";
out<<static_cast<int>(array.GetPortalConstControl().Get(sz-2))<<" ";
out<<static_cast<int>(array.GetPortalConstControl().Get(sz-1));
detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
if (i != (sz-1))
{
out<<" ";
}
}
out<<"]";
}
else
{
detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
out << " ";
detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
out << " ";
detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
out << " ... ";
detail::printSummary_ArrayHandle_Value(portal.Get(sz-3), out, IsVec());
out << " ";
detail::printSummary_ArrayHandle_Value(portal.Get(sz-2), out, IsVec());
out << " ";
detail::printSummary_ArrayHandle_Value(portal.Get(sz-1), out, IsVec());
}
out<<"]\n";
}
}
} //namespace vtkm::cont
#ifndef vtkm_cont_ArrayHandle_cxx
#ifdef VTKM_MSVC
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<char, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int16, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt16, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int32, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt32, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Int64, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::UInt64, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int64,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int32,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,2>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int64,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int32,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<char,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Int8,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::UInt8,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
#endif
namespace vtkm {
namespace cont {
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<char, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Int8, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::UInt8, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Int16, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::UInt16, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Int32, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::UInt32, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Int64, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::UInt64, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Float32, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Float64, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int64,2>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int32,2>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,2>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,2>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int64,3>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int32,3>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,3>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,3>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<char,4>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Int8,4>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::UInt8,4>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float32,4>, StorageTagBasic>;
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle< vtkm::Vec<vtkm::Float64,4>, StorageTagBasic>;
}
}
#endif
#include <vtkm/cont/ArrayHandle.hxx>
#endif //vtk_m_cont_ArrayHandle_h

396
vtkm/cont/ArrayHandle.hxx Normal file

@ -0,0 +1,396 @@
//============================================================================
// 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.
//============================================================================
namespace vtkm {
namespace cont {
template<typename T, typename S>
ArrayHandle<T,S>::ArrayHandle()
: Internals(new InternalStruct)
{
this->Internals->ControlArrayValid = false;
this->Internals->ExecutionArrayValid = false;
}
template<typename T, typename S>
ArrayHandle<T,S>::ArrayHandle(const ArrayHandle<T,S> &src)
: Internals(src.Internals)
{ }
template<typename T, typename S>
ArrayHandle<T,S>::ArrayHandle(ArrayHandle<T,S> &&src)
: Internals(std::move(src.Internals))
{ }
template<typename T, typename S>
ArrayHandle<T,S>::ArrayHandle(const typename ArrayHandle<T,S>::StorageType &storage)
: Internals(new InternalStruct)
{
this->Internals->ControlArray = storage;
this->Internals->ControlArrayValid = true;
this->Internals->ExecutionArrayValid = false;
}
template<typename T, typename S>
ArrayHandle<T,S>::~ArrayHandle()
{
}
template<typename T, typename S>
ArrayHandle<T,S>&
ArrayHandle<T,S>::operator=(const ArrayHandle<T,S> &src)
{
this->Internals = src.Internals;
return *this;
}
template<typename T, typename S>
ArrayHandle<T,S>&
ArrayHandle<T,S>::operator=(ArrayHandle<T,S> &&src)
{
this->Internals = std::move(src.Internals);
return *this;
}
template<typename T, typename S>
typename ArrayHandle<T,S>::StorageType&
ArrayHandle<T,S>::GetStorage()
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
template<typename T, typename S>
const typename ArrayHandle<T,S>::StorageType&
ArrayHandle<T,S>::GetStorage() const
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
template<typename T, typename S>
typename ArrayHandle<T,S>::PortalControl
ArrayHandle<T,S>::GetPortalControl()
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
// If the user writes into the iterator we return, then the execution
// array will become invalid. Play it safe and release the execution
// resources. (Use the const version to preserve the execution array.)
this->ReleaseResourcesExecutionInternal();
return this->Internals->ControlArray.GetPortal();
}
else
{
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
template<typename T, typename S>
typename ArrayHandle<T,S>::PortalConstControl
ArrayHandle<T,S>::GetPortalConstControl() const
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray.GetPortalConst();
}
else
{
throw vtkm::cont::ErrorInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
template<typename T, typename S>
vtkm::Id ArrayHandle<T,S>::GetNumberOfValues() const
{
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray.GetNumberOfValues();
}
else if (this->Internals->ExecutionArrayValid)
{
return this->Internals->ExecutionArray->GetNumberOfValues();
}
else
{
return 0;
}
}
template<typename T, typename S>
template<typename IteratorType, typename DeviceAdapterTag>
void ArrayHandle<T,S>::CopyInto(IteratorType dest, DeviceAdapterTag) const
{
using pointer_type = typename std::iterator_traits<IteratorType>::pointer;
using value_type = typename std::remove_pointer<pointer_type>::type;
static_assert( !std::is_const<value_type>::value,
"CopyInto requires a non const iterator." );
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid &&
!this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorBadValue(
"ArrayHandle has no data to copy into Iterator.");
}
if (!this->Internals->ControlArrayValid &&
this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
{
/// Dynamically cast ArrayHandleExecutionManagerBase into a concrete
/// class and call CopyInto. The dynamic conversion will be sucessful
/// becuase the check to ensure the ExecutionArray is of the type
/// DeviceAdapterTag has already passed
typedef vtkm::cont::internal::ArrayHandleExecutionManager<
T, StorageTag, DeviceAdapterTag> ConcreteType;
ConcreteType *ConcreteExecutionArray =
dynamic_cast<ConcreteType*>(this->Internals->ExecutionArray.get());
ConcreteExecutionArray->CopyInto(dest);
}
else
{
PortalConstControl portal = this->GetPortalConstControl();
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(portal),
vtkm::cont::ArrayPortalToIteratorEnd(portal),
dest);
}
}
template<typename T, typename S>
void ArrayHandle<T,S>::Shrink(vtkm::Id numberOfValues)
{
VTKM_ASSERT(numberOfValues >= 0);
if (numberOfValues > 0)
{
vtkm::Id originalNumberOfValues = this->GetNumberOfValues();
if (numberOfValues < originalNumberOfValues)
{
if (this->Internals->ControlArrayValid)
{
this->Internals->ControlArray.Shrink(numberOfValues);
}
if (this->Internals->ExecutionArrayValid)
{
this->Internals->ExecutionArray->Shrink(numberOfValues);
}
}
else if (numberOfValues == originalNumberOfValues)
{
// Nothing to do.
}
else // numberOfValues > originalNumberOfValues
{
throw vtkm::cont::ErrorBadValue(
"ArrayHandle::Shrink cannot be used to grow array.");
}
VTKM_ASSERT(this->GetNumberOfValues() == numberOfValues);
}
else // numberOfValues == 0
{
// If we are shrinking to 0, there is nothing to save and we might as well
// free up memory. Plus, some storage classes expect that data will be
// deallocated when the size goes to zero.
this->Allocate(0);
}
}
template<typename T, typename S>
template<typename DeviceAdapterTag>
typename ArrayHandle<T,S>::template ExecutionTypes<DeviceAdapterTag>::PortalConst
ArrayHandle<T,S>::PrepareForInput(DeviceAdapterTag) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
// Want to use an empty array.
// Set up ArrayHandle state so this actually works.
this->Internals->ControlArray.Allocate(0);
this->Internals->ControlArrayValid = true;
}
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::PortalConst portal =
this->Internals->ExecutionArray->PrepareForInput(
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
this->Internals->ExecutionArrayValid = true;
return portal;
}
template<typename T, typename S>
template<typename DeviceAdapterTag>
typename ArrayHandle<T,S>::template ExecutionTypes<DeviceAdapterTag>::Portal
ArrayHandle<T,S>::PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag)
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
// Invalidate any control arrays.
// Should the control array resource be released? Probably not a good
// idea when shared with execution.
this->Internals->ControlArrayValid = false;
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
this->Internals->ExecutionArray->PrepareForOutput(numberOfValues,
DeviceAdapterTag());
// We are assuming that the calling code will fill the array using the
// iterators we are returning, so go ahead and mark the execution array as
// having valid data. (A previous version of this class had a separate call
// to mark the array as filled, but that was onerous to call at the the
// right time and rather pointless since it is basically always the case
// that the array is going to be filled before anything else. In this
// implementation the only access to the array is through the iterators
// returned from this method, so you would have to work to invalidate this
// assumption anyway.)
this->Internals->ExecutionArrayValid = true;
return portal;
}
template<typename T, typename S>
template<typename DeviceAdapterTag>
typename ArrayHandle<T,S>::template ExecutionTypes<DeviceAdapterTag>::Portal
ArrayHandle<T,S>::PrepareForInPlace(DeviceAdapterTag)
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
{
// Want to use an empty array.
// Set up ArrayHandle state so this actually works.
this->Internals->ControlArray.Allocate(0);
this->Internals->ControlArrayValid = true;
}
this->PrepareForDevice(DeviceAdapterTag());
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
this->Internals->ExecutionArray->PrepareForInPlace(
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
this->Internals->ExecutionArrayValid = true;
// Invalidate any control arrays since their data will become invalid when
// the execution data is overwritten. Don't actually release the control
// array. It may be shared as the execution array.
this->Internals->ControlArrayValid = false;
return portal;
}
template<typename T, typename S>
template<typename DeviceAdapterTag>
void ArrayHandle<T,S>::PrepareForDevice(DeviceAdapterTag) const
{
if (this->Internals->ExecutionArray != nullptr)
{
if (this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
{
// Already have manager for correct device adapter. Nothing to do.
return;
}
else
{
// Have the wrong manager. Delete the old one and create a new one
// of the right type. (BTW, it would be possible for the array handle
// to hold references to execution arrays on multiple devices. However,
// there is not a clear use case for that yet and it is unclear what
// the behavior of "dirty" arrays should be, so it is not currently
// implemented.)
this->SyncControlArray();
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
internals->ExecutionArray.reset();
internals->ExecutionArrayValid = false;
}
}
VTKM_ASSERT(this->Internals->ExecutionArray == nullptr);
VTKM_ASSERT(!this->Internals->ExecutionArrayValid);
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
internals->ExecutionArray.reset(
new vtkm::cont::internal::ArrayHandleExecutionManager<
T, StorageTag, DeviceAdapterTag>(&internals->ControlArray));
}
template<typename T, typename S>
void ArrayHandle<T,S>::SyncControlArray() const
{
if (!this->Internals->ControlArrayValid)
{
// Need to change some state that does not change the logical state from
// an external point of view.
InternalStruct *internals
= const_cast<InternalStruct*>(this->Internals.get());
if (this->Internals->ExecutionArrayValid)
{
internals->ExecutionArray->RetrieveOutputData(&internals->ControlArray);
internals->ControlArrayValid = true;
}
else
{
// This array is in the null state (there is nothing allocated), but
// the calling function wants to do something with the array. Put this
// class into a valid state by allocating an array of size 0.
internals->ControlArray.Allocate(0);
internals->ControlArrayValid = true;
}
}
}
}
}

@ -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 {
@ -35,7 +35,7 @@ template<typename ValueType_,
typename PortalTypeFirst_,
typename PortalTypeSecond_,
typename PortalTypeThird_>
class ArrayPortalCartesianProduct
class VTKM_ALWAYS_EXPORT ArrayPortalCartesianProduct
{
public:
typedef ValueType_ ValueType;
@ -151,7 +151,7 @@ namespace cont {
namespace internal {
template<typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
struct StorageTagCartesianProduct { };
struct VTKM_ALWAYS_EXPORT StorageTagCartesianProduct { };
/// This helper struct defines the value type for a zip container containing
/// the given two array handles.
@ -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

@ -30,7 +30,7 @@ namespace cont {
namespace internal {
template<typename FromType, typename ToType>
struct Cast
struct VTKM_ALWAYS_EXPORT Cast
{
VTKM_EXEC_CONT
ToType operator()(const FromType &val) const

@ -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>
@ -39,7 +39,7 @@ namespace internal {
namespace detail {
template<typename ValueType>
struct CompositeVectorSwizzleFunctor
struct VTKM_ALWAYS_EXPORT CompositeVectorSwizzleFunctor
{
static const vtkm::IdComponent NUM_COMPONENTS =
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
@ -92,7 +92,7 @@ struct CompositeVectorSwizzleFunctor
};
template<typename ReturnValueType>
struct CompositeVectorPullValueFunctor
struct VTKM_ALWAYS_EXPORT CompositeVectorPullValueFunctor
{
vtkm::Id Index;
@ -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());
}
}
};
@ -170,7 +170,7 @@ struct CheckArraySizeFunctor {
/// This is the portal used within ArrayHandleCompositeVector.
///
template<typename SignatureWithPortals>
class ArrayPortalCompositeVector
class VTKM_ALWAYS_EXPORT ArrayPortalCompositeVector
{
typedef vtkm::internal::FunctionInterface<SignatureWithPortals> PortalTypes;
@ -213,13 +213,24 @@ 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;
};
template<typename SignatureWithArrays>
struct StorageTagCompositeVector { };
struct VTKM_ALWAYS_EXPORT StorageTagCompositeVector { };
/// A convenience class that provides a typedef to the appropriate tag for
/// a composite storage.
@ -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.");
}

@ -29,7 +29,7 @@ namespace cont {
namespace internal {
template< typename PortalType1, typename PortalType2 >
class ArrayPortalConcatenate
class VTKM_ALWAYS_EXPORT ArrayPortalConcatenate
{
public:
typedef typename PortalType1::ValueType ValueType;
@ -38,7 +38,7 @@ public:
ArrayPortalConcatenate() : portal1(), portal2() {}
VTKM_EXEC_CONT
ArrayPortalConcatenate( const PortalType1 &p1, const PortalType2 &p2 )
ArrayPortalConcatenate( const PortalType1 &p1, const PortalType2 &p2 )
: portal1( p1 ), portal2( p2 ) {}
// Copy constructor
@ -53,7 +53,7 @@ public:
return this->portal1.GetNumberOfValues() +
this->portal2.GetNumberOfValues() ;
}
VTKM_EXEC_CONT
ValueType Get( vtkm::Id index) const
{
@ -112,11 +112,11 @@ public:
VTKM_CONT
Storage() : valid( false ) { }
VTKM_CONT
Storage( const ArrayHandleType1 &a1, const ArrayHandleType2 &a2 )
Storage( const ArrayHandleType1 &a1, const ArrayHandleType2 &a2 )
: array1( a1 ), array2( a2 ), valid( true ) {};
VTKM_CONT
PortalConstType GetPortalConst() const
{
@ -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. " );
}
@ -176,7 +176,7 @@ public:
}
VTKM_CONT
const ArrayHandleType2 &GetArray2() const
const ArrayHandleType2 &GetArray2() const
{
VTKM_ASSERT( this->valid );
return this->array2;
@ -184,7 +184,7 @@ public:
private:
ArrayHandleType1 array1;
ArrayHandleType2 array2;
ArrayHandleType2 array2;
bool valid;
}; // class Storage
@ -196,7 +196,7 @@ class ArrayTransfer< typename ArrayHandleType1::ValueType,
{
public:
typedef typename ArrayHandleType1::ValueType ValueType;
private:
typedef StorageTagConcatenate< ArrayHandleType1, ArrayHandleType2 > StorageTag;
typedef vtkm::cont::internal::Storage< ValueType, StorageTag> StorageType;
@ -205,17 +205,17 @@ public:
typedef typename StorageType::PortalType PortalControl;
typedef typename StorageType::PortalConstType PortalConstControl;
typedef ArrayPortalConcatenate<
typedef ArrayPortalConcatenate<
typename ArrayHandleType1::template ExecutionTypes< Device >::Portal,
typename ArrayHandleType2::template ExecutionTypes< Device >::Portal >
typename ArrayHandleType2::template ExecutionTypes< Device >::Portal >
PortalExecution;
typedef ArrayPortalConcatenate<
typedef ArrayPortalConcatenate<
typename ArrayHandleType1::template ExecutionTypes< Device >::PortalConst,
typename ArrayHandleType2::template ExecutionTypes< Device >::PortalConst >
typename ArrayHandleType2::template ExecutionTypes< Device >::PortalConst >
PortalConstExecution;
VTKM_CONT
ArrayTransfer( StorageType* storage )
ArrayTransfer( StorageType* storage )
: array1( storage->GetArray1() ), array2( storage->GetArray2() ) {}
VTKM_CONT
@ -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. " );
}
@ -268,7 +268,7 @@ public:
{
this->array1.ReleaseResourcesExecution();
this->array2.ReleaseResourcesExecution();
}
}
private:
ArrayHandleType1 array1;
@ -286,14 +286,14 @@ namespace vtkm {
namespace cont {
template< typename ArrayHandleType1, typename ArrayHandleType2 >
class ArrayHandleConcatenate
class ArrayHandleConcatenate
: public vtkm::cont::ArrayHandle< typename ArrayHandleType1::ValueType,
StorageTagConcatenate< ArrayHandleType1, ArrayHandleType2> >
{
public:
VTKM_ARRAY_HANDLE_SUBCLASS( ArrayHandleConcatenate,
VTKM_ARRAY_HANDLE_SUBCLASS( ArrayHandleConcatenate,
( ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2> ),
( vtkm::cont::ArrayHandle< typename ArrayHandleType1::ValueType,
( vtkm::cont::ArrayHandle< typename ArrayHandleType1::ValueType,
StorageTagConcatenate< ArrayHandleType1, ArrayHandleType2 > > ));
protected:
@ -302,21 +302,21 @@ protected:
public:
VTKM_CONT
ArrayHandleConcatenate( const ArrayHandleType1 &array1,
ArrayHandleConcatenate( const ArrayHandleType1 &array1,
const ArrayHandleType2 &array2 )
: Superclass( StorageType( array1, array2 ) )
{}
};
template< typename ArrayHandleType1, typename ArrayHandleType2 >
VTKM_CONT
ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2 >
make_ArrayHandleConcatenate( const ArrayHandleType1 &array1,
make_ArrayHandleConcatenate( const ArrayHandleType1 &array1,
const ArrayHandleType2 &array2 )
{
return ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2 >( array1, array2 );
return ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2 >( array1, array2 );
}
}

@ -30,7 +30,7 @@ namespace cont {
namespace detail {
template<typename ValueType>
struct ConstantFunctor
struct VTKM_ALWAYS_EXPORT ConstantFunctor
{
VTKM_EXEC_CONT
ConstantFunctor(const ValueType &value = ValueType()) : Value(value) { }

@ -32,7 +32,7 @@ namespace internal {
/// \brief An implicit array portal that returns an counting value.
template <class CountingValueType>
class ArrayPortalCounting
class VTKM_ALWAYS_EXPORT ArrayPortalCounting
{
typedef typename vtkm::VecTraits<CountingValueType>::ComponentType
ComponentType;
@ -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 {
@ -30,7 +30,7 @@ namespace exec {
namespace internal {
template<typename _SourcePortalType, vtkm::IdComponent _NUM_COMPONENTS>
class ArrayPortalGroupVec
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVec
{
public:
static const vtkm::IdComponent NUM_COMPONENTS = _NUM_COMPONENTS;
@ -115,7 +115,7 @@ namespace cont {
namespace internal {
template<typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
struct StorageTagGroupVec { };
struct VTKM_ALWAYS_EXPORT StorageTagGroupVec { };
template<typename SourceArrayHandleType,
vtkm::IdComponent NUM_COMPONENTS>
@ -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>
@ -38,7 +38,7 @@ namespace exec {
namespace internal {
template<typename SourcePortalType, typename OffsetsPortalType>
class ArrayPortalGroupVecVariable
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVecVariable
{
public:
using ComponentType =
@ -180,7 +180,7 @@ namespace cont {
namespace internal {
template<typename SourceArrayHandleType, typename OffsetsArrayHandleType>
struct StorageTagGroupVecVariable { };
struct VTKM_ALWAYS_EXPORT StorageTagGroupVecVariable { };
template<typename SourceArrayHandleType, typename OffsetsArrayHandleType>
class Storage<
@ -211,6 +211,20 @@ public:
const OffsetsArrayHandleType &offsetsArray)
: SourceArray(sourceArray), OffsetsArray(offsetsArray), Valid(true) { }
VTKM_CONT
PortalType GetPortal()
{
return PortalType(this->SourceArray.GetPortalControl(),
this->OffsetsArray.GetPortalControl());
}
VTKM_CONT
PortalConstType GetPortalConst() const
{
return PortalConstType(this->SourceArray.GetPortalConstControl(),
this->OffsetsArray.GetPortalConstControl());
}
VTKM_CONT
vtkm::Id GetNumberOfValues() const
{
@ -291,7 +305,7 @@ public:
using PortalExecution =
vtkm::exec::internal::ArrayPortalGroupVecVariable<
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal,
typename OffsetsArrayHandleType::template ExecutionTypes<Device>::Portal>;
typename OffsetsArrayHandleType::template ExecutionTypes<Device>::PortalConst>;
using PortalConstExecution =
vtkm::exec::internal::ArrayPortalGroupVecVariable<
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst,
@ -320,7 +334,7 @@ public:
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
{
return PortalExecution(this->SourceArray.PrepareForInPlace(Device()),
this->OffsetsArray.PrepareForInPlace(Device()));
this->OffsetsArray.PrepareForInput(Device()));
}
VTKM_CONT
@ -330,8 +344,7 @@ public:
VTKM_ASSERT(numberOfValues == this->OffsetsArray.GetNumberOfValues());
return PortalExecution(this->SourceArray.PrepareForOutput(
this->SourceArray.GetNumberOfValues(), Device()),
this->OffsetsArray.PrepareForOutput(
numberOfValues, Device()));
this->OffsetsArray.PrepareForInput(Device()));
}
VTKM_CONT
@ -487,7 +500,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.");
}

@ -40,7 +40,7 @@ namespace detail {
/// \c StorageImplicit container.
///
template <class ValueType_, class FunctorType_ >
class ArrayPortalImplicit
class VTKM_ALWAYS_EXPORT ArrayPortalImplicit
{
public:
typedef ValueType_ ValueType;
@ -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;

@ -29,7 +29,7 @@ namespace cont {
namespace detail {
struct IndexFunctor {
struct VTKM_ALWAYS_EXPORT IndexFunctor {
VTKM_EXEC_CONT
vtkm::Id operator()(vtkm::Id index) const { return index; }
};

@ -23,15 +23,15 @@
#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 {
namespace internal {
template<typename IndexPortalType, typename ValuePortalType>
class ArrayPortalPermutation
class VTKM_ALWAYS_EXPORT ArrayPortalPermutation
{
public:
typedef typename ValuePortalType::ValueType ValueType;
@ -104,7 +104,7 @@ namespace cont {
namespace internal {
template<typename IndexArrayType, typename ValueArrayType>
struct StorageTagPermutation { };
struct VTKM_ALWAYS_EXPORT StorageTagPermutation { };
template<typename IndexArrayType, typename ValueArrayType>
class Storage<
@ -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.");
}

@ -28,7 +28,7 @@ namespace cont {
namespace internal {
template<typename P>
class ArrayPortalStreaming
class VTKM_ALWAYS_EXPORT ArrayPortalStreaming
{
public:
typedef P PortalType;
@ -38,14 +38,14 @@ public:
ArrayPortalStreaming() : InputPortal(), BlockIndex(0), BlockSize(0), CurBlockSize(0) { }
VTKM_CONT
ArrayPortalStreaming(const PortalType &inputPortal, vtkm::Id blockIndex,
vtkm::Id blockSize, vtkm::Id curBlockSize) :
InputPortal(inputPortal), BlockIndex(blockIndex),
ArrayPortalStreaming(const PortalType &inputPortal, vtkm::Id blockIndex,
vtkm::Id blockSize, vtkm::Id curBlockSize) :
InputPortal(inputPortal), BlockIndex(blockIndex),
BlockSize(blockSize), CurBlockSize(curBlockSize) { }
template<typename OtherP>
VTKM_CONT
ArrayPortalStreaming(const ArrayPortalStreaming<OtherP> &src) :
ArrayPortalStreaming(const ArrayPortalStreaming<OtherP> &src) :
InputPortal(src.GetPortal()),
BlockIndex(src.GetBlockIndex()),
BlockSize(src.GetBlockSize()),
@ -53,7 +53,7 @@ public:
VTKM_CONT
vtkm::Id GetNumberOfValues() const {
return this->CurBlockSize;
return this->CurBlockSize;
}
VTKM_CONT
@ -97,7 +97,7 @@ private:
} // internal
template<typename ArrayHandleInputType>
struct StorageTagStreaming { };
struct VTKM_ALWAYS_EXPORT StorageTagStreaming { };
namespace internal {
@ -118,29 +118,29 @@ public:
Storage() : Valid(false) { }
VTKM_CONT
Storage(const ArrayHandleInputType inputArray, vtkm::Id blockSize,
vtkm::Id blockIndex, vtkm::Id curBlockSize) :
InputArray(inputArray), BlockSize(blockSize),
Storage(const ArrayHandleInputType inputArray, vtkm::Id blockSize,
vtkm::Id blockIndex, vtkm::Id curBlockSize) :
InputArray(inputArray), BlockSize(blockSize),
BlockIndex(blockIndex), CurBlockSize(curBlockSize), Valid(true) { }
VTKM_CONT
PortalType GetPortal() {
VTKM_ASSERT(this->Valid);
return PortalType(this->InputArray.GetPortalControl(),
return PortalType(this->InputArray.GetPortalControl(),
BlockSize, BlockIndex, CurBlockSize);
}
VTKM_CONT
PortalConstType GetPortalConst() const {
VTKM_ASSERT(this->Valid);
return PortalConstType(this->InputArray.GetPortalConstControl(),
return PortalConstType(this->InputArray.GetPortalConstControl(),
BlockSize, BlockIndex, CurBlockSize);
}
VTKM_CONT
vtkm::Id GetNumberOfValues() const {
VTKM_ASSERT(this->Valid);
return CurBlockSize;
return CurBlockSize;
}
VTKM_CONT
@ -208,10 +208,10 @@ private:
public:
VTKM_CONT
ArrayHandleStreaming(const ArrayHandleInputType &inputArray,
const vtkm::Id blockIndex, const vtkm::Id blockSize,
const vtkm::Id blockIndex, const vtkm::Id blockSize,
const vtkm::Id curBlockSize)
: Superclass(StorageType(inputArray, blockIndex, blockSize, curBlockSize))
{
: Superclass(StorageType(inputArray, blockIndex, blockSize, curBlockSize))
{
this->GetPortalConstControl().SetBlockIndex(blockIndex);
this->GetPortalConstControl().SetBlockSize(blockSize);
this->GetPortalConstControl().SetCurBlockSize(curBlockSize);

@ -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 {
@ -47,10 +47,10 @@ typedef vtkm::cont::internal::NullFunctorType NullFunctorType;
///
template<typename ValueType_, typename PortalType_, typename FunctorType_,
typename InverseFunctorType_=NullFunctorType>
class ArrayPortalTransform;
class VTKM_ALWAYS_EXPORT ArrayPortalTransform;
template<typename ValueType_, typename PortalType_, typename FunctorType_>
class ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
class VTKM_ALWAYS_EXPORT ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
{
public:
typedef PortalType_ PortalType;
@ -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; }
@ -103,7 +113,7 @@ protected:
template<typename ValueType_, typename PortalType_,
typename FunctorType_, typename InverseFunctorType_>
class ArrayPortalTransform : public ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
class VTKM_ALWAYS_EXPORT ArrayPortalTransform : public ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
{
public:
typedef ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType> Superclass;
@ -155,7 +165,7 @@ namespace internal {
template<typename ValueType, typename ArrayHandleType, typename FunctorType,
typename InverseFunctorType=NullFunctorType>
struct StorageTagTransform {};
struct VTKM_ALWAYS_EXPORT StorageTagTransform {};
template<typename T, typename ArrayHandleType, typename FunctorType>
class Storage<T, StorageTagTransform<T, ArrayHandleType, FunctorType, NullFunctorType > >
@ -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.");
}

@ -101,7 +101,7 @@ namespace cont {
namespace internal {
template<typename FirstHandleType, typename SecondHandleType>
struct StorageTagZip { };
struct VTKM_ALWAYS_EXPORT StorageTagZip { };
/// This helper struct defines the value type for a zip container containing
/// the given two array handles.
@ -253,9 +253,8 @@ public:
VTKM_CONT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData)) {
const vtkm::Id numberOfValues = this->GetNumberOfValues();
return PortalExecution(this->FirstArray.PrepareForOutput(numberOfValues, Device()),
this->SecondArray.PrepareForOutput(numberOfValues, Device()));
return PortalExecution(this->FirstArray.PrepareForInPlace(Device()),
this->SecondArray.PrepareForInPlace(Device()));
}
VTKM_CONT

@ -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,141 @@
//============================================================================
// 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/ArrayRangeCompute.hxx>
namespace vtkm {
namespace cont {
#define VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(T, Storage) \
VTKM_CONT \
vtkm::cont::ArrayHandle<vtkm::Range> \
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T, Storage> &input, \
vtkm::cont::RuntimeDeviceTracker tracker) \
{ \
return detail::ArrayRangeComputeImpl(input,tracker); \
} \
struct SwallowSemicolon
#define VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(T, N, Storage) \
VTKM_CONT \
vtkm::cont::ArrayHandle<vtkm::Range> \
ArrayRangeCompute(const vtkm::cont::ArrayHandle<vtkm::Vec<T,N>, Storage> &input, \
vtkm::cont::RuntimeDeviceTracker tracker) \
{ \
return detail::ArrayRangeComputeImpl(input,tracker); \
} \
struct SwallowSemicolon
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(char, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Int8, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::UInt8, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Int16, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::UInt16, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Int32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::UInt32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Int64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::UInt64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Float32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(vtkm::Float64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Int32, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Int64, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float32, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float64, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Int32, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Int64, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float32, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float64, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(char, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Int8, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::UInt8, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float32, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float64, 4, vtkm::cont::StorageTagBasic);
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_T
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC
// Special implementation for regular point coordinates, which are easy
// to determine.
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::FloatDefault,3>,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>
&array,
vtkm::cont::RuntimeDeviceTracker)
{
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;
}
// Special implementation for composite vectors.
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::Float32,3>,
typename vtkm::cont::ArrayHandleCompositeVector<
vtkm::Vec<vtkm::Float32,3>(
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>)
>::StorageTag
> &input,
vtkm::cont::RuntimeDeviceTracker tracker)
{
return detail::ArrayRangeComputeImpl(input,tracker);
}
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::Float64,3>,
typename vtkm::cont::ArrayHandleCompositeVector<
vtkm::Vec<vtkm::Float64,3>(
vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>)
>::StorageTag
> &input,
vtkm::cont::RuntimeDeviceTracker tracker)
{
return detail::ArrayRangeComputeImpl(input,tracker);
}
}
} // namespace vtkm::cont

@ -0,0 +1,178 @@
//============================================================================
// 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/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
namespace vtkm {
namespace cont {
/// \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 optionally takes a \c RuntimeDeviceTracker to control which
///devices to try.
///
/// 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>
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const ArrayHandleType &input,
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker());
// Precompiled versions of ArrayRangeCompute
#define VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(T, Storage) \
VTKM_CONT_EXPORT \
VTKM_CONT \
vtkm::cont::ArrayHandle<vtkm::Range> \
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T, Storage> &input, \
vtkm::cont::RuntimeDeviceTracker tracker = \
vtkm::cont::GetGlobalRuntimeDeviceTracker())
#define VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(T, N, Storage) \
VTKM_CONT_EXPORT \
VTKM_CONT \
vtkm::cont::ArrayHandle<vtkm::Range> \
ArrayRangeCompute(const vtkm::cont::ArrayHandle<vtkm::Vec<T,N>, Storage> &input, \
vtkm::cont::RuntimeDeviceTracker tracker = \
vtkm::cont::GetGlobalRuntimeDeviceTracker())
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(char, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Int8, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::UInt8, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Int16, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::UInt16, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Int32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::UInt32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Int64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::UInt64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Float32, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Float64, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Int32, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Int64, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float32, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float64, 2, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Int32, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Int64, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float32, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float64, 3, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(char, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Int8, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::UInt8, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float32, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float64, 4, vtkm::cont::StorageTagBasic);
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(
vtkm::FloatDefault, 3,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag);
#undef VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T
#undef VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC
// Implementation of composite vectors
VTKM_CONT_EXPORT
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::Float32,3>,
typename vtkm::cont::ArrayHandleCompositeVector<
vtkm::Vec<vtkm::Float32,3>(
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>)
>::StorageTag
> &input,
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker());
VTKM_CONT_EXPORT
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
vtkm::Vec<vtkm::Float64,3>,
typename vtkm::cont::ArrayHandleCompositeVector<
vtkm::Vec<vtkm::Float64,3>(
vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>)
>::StorageTag
> &input,
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker());
// Implementation of cartesian products
template<typename T,
typename ArrayType1,
typename ArrayType2,
typename ArrayType3>
VTKM_CONT
inline
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T,
vtkm::cont::internal::StorageTagCartesianProduct<
ArrayType1,ArrayType2,ArrayType3
> > &input,
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker())
{
vtkm::cont::ArrayHandle<vtkm::Range> result;
result.Allocate(3);
vtkm::cont::ArrayHandle<vtkm::Range> componentRangeArray;
vtkm::Range componentRange;
ArrayType1 firstArray = input.GetStorage().GetFirstArray();
componentRangeArray = vtkm::cont::ArrayRangeCompute(firstArray, tracker);
componentRange = componentRangeArray.GetPortalConstControl().Get(0);
result.GetPortalControl().Set(0, componentRange);
ArrayType2 secondArray = input.GetStorage().GetSecondArray();
componentRangeArray = vtkm::cont::ArrayRangeCompute(secondArray, tracker);
componentRange = componentRangeArray.GetPortalConstControl().Get(0);
result.GetPortalControl().Set(1, componentRange);
ArrayType3 thirdArray = input.GetStorage().GetThirdArray();
componentRangeArray = vtkm::cont::ArrayRangeCompute(thirdArray, tracker);
componentRange = componentRangeArray.GetPortalConstControl().Get(0);
result.GetPortalControl().Set(2, componentRange);
return result;
}
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ArrayRangeCompute_h

@ -0,0 +1,124 @@
//============================================================================
// 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_ArrayRangeCompute_hxx
#define vtk_m_cont_ArrayRangeCompute_hxx
#include <vtkm/cont/ArrayRangeCompute.h>
#include <vtkm/BinaryOperators.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/TryExecute.h>
namespace vtkm {
namespace cont {
namespace detail {
template<typename ArrayHandleType>
struct ArrayRangeComputeFunctor
{
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
ArrayHandleType InputArray;
vtkm::cont::ArrayHandle<vtkm::Range> RangeArray;
VTKM_CONT
ArrayRangeComputeFunctor(const ArrayHandleType &input)
: InputArray(input)
{ }
template<typename Device>
VTKM_CONT
bool operator()(Device)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
using ValueType = typename ArrayHandleType::ValueType;
using VecTraits = vtkm::VecTraits<ValueType>;
const vtkm::IdComponent NumberOfComponents = VecTraits::NUM_COMPONENTS;
typedef vtkm::cont::DeviceAdapterAlgorithm<Device> Algorithm;
if (this->InputArray.GetNumberOfValues() < 1)
{
throw vtkm::cont::ErrorBadValue(
"Called ArrayComputeRange on empty array (which has no range).");
}
vtkm::Vec<ValueType,2> initial(
this->InputArray.GetPortalConstControl().Get(0));
vtkm::Vec<ValueType, 2> result =
Algorithm::Reduce(this->InputArray,
initial,
vtkm::MinAndMax<ValueType>());
this->RangeArray.Allocate(NumberOfComponents);
for (vtkm::IdComponent i = 0; i < NumberOfComponents; ++i)
{
this->RangeArray.GetPortalControl().Set(
i, vtkm::Range(VecTraits::GetComponent(result[0], i),
VecTraits::GetComponent(result[1], i)));
}
return true;
}
};
template<typename ArrayHandleType>
inline
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeComputeImpl(const ArrayHandleType &input,
vtkm::cont::RuntimeDeviceTracker tracker)
{
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
detail::ArrayRangeComputeFunctor<ArrayHandleType> functor(input);
if (!vtkm::cont::TryExecute(functor, tracker))
{
throw vtkm::cont::ErrorExecution(
"Failed to run ArrayRangeComputation on any device.");
}
return functor.RangeArray;
}
} // namespace detail
template<typename ArrayHandleType>
inline
vtkm::cont::ArrayHandle<vtkm::Range>
ArrayRangeCompute(const ArrayHandleType &input,
vtkm::cont::RuntimeDeviceTracker tracker)
{
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
return detail::ArrayRangeComputeImpl(input, tracker);
}
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ArrayRangeCompute_hxx

@ -25,6 +25,7 @@ set(headers
ArrayHandleCompositeVector.h
ArrayHandleConstant.h
ArrayHandleCounting.h
ArrayHandleDiscard.h
ArrayHandleGroupVec.h
ArrayHandleGroupVecVariable.h
ArrayHandleImplicit.h
@ -37,6 +38,8 @@ set(headers
ArrayPortal.h
ArrayPortalToIterators.h
ArrayHandleConcatenate.h
ArrayRangeCompute.h
ArrayRangeCompute.hxx
CellSet.h
CellSetExplicit.h
CellSetListTag.h
@ -55,15 +58,14 @@ 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
LogicalStructure.h
RuntimeDeviceInformation.h
RuntimeDeviceTracker.h
Storage.h
StorageBasic.h
StorageImplicit.h
@ -72,11 +74,41 @@ set(headers
TryExecute.h
)
set(header_impls
ArrayHandle.hxx
CellSetStructured.hxx
StorageBasic.hxx
)
set(sources
ArrayHandle.cxx
CellSet.cxx
CellSetStructured.cxx
CoordinateSystem.cxx
DynamicArrayHandle.cxx
Field.cxx
internal/SimplePolymorphicContainer.cxx
StorageBasic.cxx
)
# This list of sources has code that uses devices and so might need to be
# compiled with a device-specific compiler (like CUDA).
set(device_sources
ArrayRangeCompute.cxx
RuntimeDeviceTracker.cxx
)
vtkm_library(
SOURCES ${sources}
WRAP_FOR_CUDA ${device_sources}
HEADERS ${header_impls})
target_include_directories(vtkm_cont PRIVATE ${VTKm_BACKEND_INCLUDE_DIRS})
#-----------------------------------------------------------------------------
add_subdirectory(internal)
add_subdirectory(arg)
vtkm_declare_headers(${impl_headers} ${headers})
vtkm_declare_headers(${headers})
add_subdirectory(serial)
add_subdirectory(cuda)

@ -17,17 +17,17 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_LogicalStructure_h
#define vtk_m_cont_LogicalStructure_h
#include <vtkm/cont/CellSet.h>
namespace vtkm {
namespace cont {
class LogicalStructure
CellSet::~CellSet()
{
};
} // namespace cont
} // namespace vtkm
}
#endif
}
} // namespace vtkm::cont

@ -20,60 +20,51 @@
#ifndef vtk_m_cont_CellSet_h
#define vtk_m_cont_CellSet_h
#include <vtkm/cont/vtkm_cont_export.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <vtkm/cont/LogicalStructure.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
namespace vtkm {
namespace cont {
class CellSet
class VTKM_CONT_EXPORT CellSet
{
public:
VTKM_CONT
CellSet(const std::string &name)
: Name(name), LogicalStructure()
: Name(name)
{
}
VTKM_CONT
CellSet(const vtkm::cont::CellSet &src)
: Name(src.Name),
LogicalStructure(src.LogicalStructure)
: Name(src.Name)
{ }
VTKM_CONT
CellSet &operator=(const vtkm::cont::CellSet &src)
{
this->Name = src.Name;
this->LogicalStructure = src.LogicalStructure;
return *this;
}
virtual ~CellSet()
{
}
virtual ~CellSet();
virtual std::string GetName() const
std::string GetName() const
{
return this->Name;
}
virtual vtkm::Id GetNumberOfCells() const = 0;
virtual vtkm::Id GetNumberOfFaces() const
{
return 0;
}
virtual vtkm::Id GetNumberOfFaces() const = 0;
virtual vtkm::Id GetNumberOfEdges() const
{
return 0;
}
virtual vtkm::Id GetNumberOfEdges() const = 0;
virtual vtkm::Id GetNumberOfPoints() const = 0;
@ -81,7 +72,6 @@ public:
protected:
std::string Name;
vtkm::cont::LogicalStructure LogicalStructure;
};
namespace internal {

@ -70,7 +70,7 @@ template<typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG,
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG >
class CellSetExplicit : public CellSet
class VTKM_ALWAYS_EXPORT CellSetExplicit : public CellSet
{
typedef CellSetExplicit< ShapeStorageTag,
NumIndicesStorageTag,
@ -106,21 +106,11 @@ public:
typedef typename PointToCellConnectivityType::IndexOffsetArrayType IndexOffsetArrayType;
VTKM_CONT
CellSetExplicit(vtkm::Id numpoints = 0,
const std::string &name = std::string())
CellSetExplicit(const std::string &name = std::string())
: CellSet(name),
ConnectivityLength(-1),
NumberOfCells(-1),
NumberOfPoints(numpoints)
{
}
VTKM_CONT
CellSetExplicit(vtkm::Id numpoints)
: CellSet(std::string()),
ConnectivityLength(-1),
NumberOfCells(-1),
NumberOfPoints(numpoints)
ConnectivityAdded(-1),
NumberOfCellsAdded(-1),
NumberOfPoints(0)
{
}
@ -129,8 +119,8 @@ public:
: CellSet(src),
PointToCell(src.PointToCell),
CellToPoint(src.CellToPoint),
ConnectivityLength(src.ConnectivityLength),
NumberOfCells(src.NumberOfCells),
ConnectivityAdded(src.ConnectivityAdded),
NumberOfCellsAdded(src.NumberOfCellsAdded),
NumberOfPoints(src.NumberOfPoints)
{ }
@ -140,24 +130,28 @@ public:
this->CellSet::operator=(src);
this->PointToCell = src.PointToCell;
this->CellToPoint = src.CellToPoint;
this->ConnectivityLength = src.ConnectivityLength;
this->NumberOfCells = src.NumberOfCells;
this->ConnectivityAdded = src.ConnectivityAdded;
this->NumberOfCellsAdded = src.NumberOfCellsAdded;
this->NumberOfPoints = src.NumberOfPoints;
return *this;
}
virtual ~CellSetExplicit() { }
virtual vtkm::Id GetNumberOfCells() const
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE
{
return this->PointToCell.GetNumberOfElements();
}
virtual vtkm::Id GetNumberOfPoints() const
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE
{
return this->NumberOfPoints;
}
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE { return -1; }
vtkm::Id GetNumberOfEdges() const VTKM_OVERRIDE { return -1; }
VTKM_CONT
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
{
@ -177,7 +171,7 @@ public:
}
VTKM_CONT
vtkm::Id GetCellShape(vtkm::Id cellIndex) const
vtkm::UInt8 GetCellShape(vtkm::Id cellIndex) const
{
return this->PointToCell.Shapes.GetPortalConstControl().Get(cellIndex);
}
@ -197,54 +191,88 @@ public:
/// First method to add cells -- one at a time.
VTKM_CONT
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen)
{
this->PointToCell.Shapes.Allocate(numShapes);
this->PointToCell.NumIndices.Allocate(numShapes);
this->PointToCell.Shapes.Allocate(numCells);
this->PointToCell.NumIndices.Allocate(numCells);
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->PointToCell.IndexOffsets.Allocate(numShapes);
this->NumberOfCells = 0;
this->ConnectivityLength = 0;
this->PointToCell.IndexOffsets.Allocate(numCells);
this->NumberOfCellsAdded = 0;
this->ConnectivityAdded = 0;
}
template <typename IndexableType>
template <typename IdVecType>
VTKM_CONT
void AddCell(vtkm::UInt8 cellType,
vtkm::IdComponent numVertices,
const IndexableType &ids)
const IdVecType &ids)
{
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCells, cellType);
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCells, numVertices);
for (vtkm::IdComponent i=0; i < numVertices; ++i)
using Traits = vtkm::VecTraits<IdVecType>;
VTKM_STATIC_ASSERT_MSG(
(std::is_same<typename Traits::ComponentType,vtkm::Id>::value),
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
if (Traits::GetNumberOfComponents(ids) < numVertices)
{
throw vtkm::cont::ErrorBadValue(
"Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue(
"Added more cells then expected.");
}
if (this->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCellsAdded, cellType);
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCellsAdded, numVertices);
for (vtkm::IdComponent iVec=0; iVec < numVertices; ++iVec)
{
this->PointToCell.Connectivity.GetPortalControl().Set(
this->ConnectivityLength+i,ids[i]);
this->ConnectivityAdded+iVec, Traits::GetComponent(ids,iVec));
}
this->PointToCell.IndexOffsets.GetPortalControl().Set(
this->NumberOfCells, this->ConnectivityLength);
this->NumberOfCells++;
this->ConnectivityLength += numVertices;
this->NumberOfCellsAdded, this->ConnectivityAdded);
this->NumberOfCellsAdded++;
this->ConnectivityAdded += numVertices;
}
VTKM_CONT
void CompleteAddingCells()
void CompleteAddingCells(vtkm::Id numPoints)
{
this->PointToCell.Connectivity.Shrink(ConnectivityLength);
this->NumberOfPoints = numPoints;
this->PointToCell.Connectivity.Shrink(ConnectivityAdded);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorBadValue(
"Did not add as many cells as expected.");
}
this->NumberOfCellsAdded = -1;
this->ConnectivityAdded = -1;
}
/// Second method to add cells -- all at once.
/// Assigns the array handles to the explicit connectivity. This is
/// the way you can fill the memory from another system without copying
VTKM_CONT
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
void Fill(vtkm::Id numPoints,
const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity,
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag> &offsets
= vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>() )
{
this->NumberOfPoints = numPoints;
this->PointToCell.Shapes = cellTypes;
this->PointToCell.NumIndices = numIndices;
this->PointToCell.Connectivity = connectivity;
@ -261,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.");
}
@ -434,13 +462,13 @@ public:
this->CellToPoint.IndexOffsetsValid = false;
}
virtual void PrintSummary(std::ostream &out) const
void PrintSummary(std::ostream &out) const VTKM_OVERRIDE
{
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
}
template<typename FromTopology, typename ToTopology>
@ -518,8 +546,8 @@ protected:
// These are used in the AddCell and related methods to incrementally add
// cells. They need to be protected as subclasses of CellSetExplicit
// need to set these values when implementing Fill()
vtkm::Id ConnectivityLength;
vtkm::Id NumberOfCells;
vtkm::Id ConnectivityAdded;
vtkm::Id NumberOfCellsAdded;
vtkm::Id NumberOfPoints;
};

@ -33,20 +33,20 @@
namespace vtkm {
namespace cont {
struct CellSetListTagStructured1D
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured1D
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<1> > { };
struct CellSetListTagStructured2D
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured2D
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<2> > { };
struct CellSetListTagStructured3D
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured3D
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<3> > { };
template<typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG,
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG >
struct CellSetListTagExplicit
struct VTKM_ALWAYS_EXPORT CellSetListTagExplicit
: vtkm::ListTagBase<
vtkm::cont::CellSetExplicit<
ShapeStorageTag,
@ -54,11 +54,11 @@ struct CellSetListTagExplicit
ConnectivityStorageTag,
OffsetsStorageTag> > { };
struct CellSetListTagExplicitDefault
struct VTKM_ALWAYS_EXPORT CellSetListTagExplicitDefault
: CellSetListTagExplicit<> { };
struct CellSetListTagCommon
struct VTKM_ALWAYS_EXPORT CellSetListTagCommon
: vtkm::ListTagBase<
vtkm::cont::CellSetStructured<2>,
vtkm::cont::CellSetStructured<3>,
@ -66,13 +66,13 @@ struct CellSetListTagCommon
vtkm::cont::CellSetSingleType<>
> { };
struct CellSetListTagStructured
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured
: vtkm::ListTagBase<
vtkm::cont::CellSetStructured<2>,
vtkm::cont::CellSetStructured<3>
> { };
struct CellSetListTagUnstructured
struct VTKM_ALWAYS_EXPORT CellSetListTagUnstructured
: vtkm::ListTagBase<
vtkm::cont::CellSetExplicit<>,
vtkm::cont::CellSetSingleType<>

@ -57,17 +57,21 @@ public:
}
VTKM_CONT
vtkm::Id GetNumberOfCells() const
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE
{
return this->ValidCellIds.GetNumberOfValues();
}
VTKM_CONT
vtkm::Id GetNumberOfPoints() const
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE
{
return this->FullCellSet.GetNumberOfPoints();
}
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE { return -1; }
vtkm::Id GetNumberOfEdges() const VTKM_OVERRIDE { return -1; }
//This is the way you can fill the memory from another system without copying
VTKM_CONT
void Fill(const PermutationArrayHandleType &validCellIds,
@ -111,7 +115,7 @@ public:
this->FullCellSet.PrepareForInput(d,f,t) );
}
virtual void PrintSummary(std::ostream &out) const
void PrintSummary(std::ostream &out) const VTKM_OVERRIDE
{
out << " CellSetGeneralPermutation of: "<< std::endl;
this->FullCellSet.PrintSummary(out);
@ -138,6 +142,7 @@ class CellSetPermutation : public vtkm::cont::internal::CellSetGeneralPermutatio
typedef typename vtkm::cont::internal::CellSetGeneralPermutation<
OriginalCellSet, PermutationArrayHandleType> ParentType;
public:
VTKM_CONT
CellSetPermutation(const PermutationArrayHandleType& validCellIds,
const OriginalCellSet& cellset,
@ -152,6 +157,14 @@ public:
{
}
VTKM_CONT
CellSetPermutation<OriginalCellSet,PermutationArrayHandleType>&
operator=(const CellSetPermutation<OriginalCellSet,PermutationArrayHandleType> &src)
{
ParentType::operator=(src);
return *this;
}
};
template<typename OriginalCellSet, typename PermutationArrayHandleType>

@ -37,7 +37,7 @@ namespace cont {
//Only works with fixed sized cell sets
template< typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG >
class CellSetSingleType :
class VTKM_ALWAYS_EXPORT CellSetSingleType :
public vtkm::cont::CellSetExplicit<
typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag, //ShapeStorageTag
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag, //NumIndicesStorageTag
@ -54,47 +54,29 @@ class CellSetSingleType :
public:
template<typename CellShapeTag>
VTKM_CONT
CellSetSingleType(CellShapeTag, vtkm::Id numpoints, const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTag::Id)
{
}
template<typename CellShapeTag>
VTKM_CONT
CellSetSingleType(CellShapeTag, const std::string &name = std::string())
: Superclass(0, name),
CellTypeAsId(CellShapeTag::Id)
{
}
VTKM_CONT
CellSetSingleType(vtkm::Id numpoints,
const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTagEmpty::Id)
{
}
VTKM_CONT
CellSetSingleType(const std::string &name = std::string())
: Superclass(0, name),
CellTypeAsId(CellShapeTagEmpty::Id)
: Superclass(name),
ExpectedNumberOfCellsAdded(-1),
CellShapeAsId(CellShapeTagEmpty::Id),
NumberOfPointsPerCell(0)
{
}
VTKM_CONT
CellSetSingleType(const Thisclass &src)
: Superclass(src), CellTypeAsId(src.CellTypeAsId)
: Superclass(src),
ExpectedNumberOfCellsAdded(-1),
CellShapeAsId(src.CellShapeAsId),
NumberOfPointsPerCell(src.NumberOfPointsPerCell)
{ }
VTKM_CONT
Thisclass &operator=(const Thisclass &src)
{
this->Superclass::operator=(src);
this->CellTypeAsId = src.CellTypeAsId;
this->CellShapeAsId = src.CellShapeAsId;
this->NumberOfPointsPerCell = src.NumberOfPointsPerCell;
return *this;
}
@ -102,109 +84,201 @@ public:
/// First method to add cells -- one at a time.
VTKM_CONT
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
void PrepareToAddCells(vtkm::Id numCells,
vtkm::Id connectivityMaxLen)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, numShapes);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
numShapes);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
static_cast<vtkm::Id>(numberOfPointsPerCell),
numShapes );
this->CellShapeAsId = vtkm::CELL_SHAPE_EMPTY;
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->NumberOfCells = 0;
this->ConnectivityLength = 0;
this->NumberOfCellsAdded = 0;
this->ConnectivityAdded = 0;
this->ExpectedNumberOfCellsAdded = numCells;
}
/// Second method to add cells -- one at a time.
template <vtkm::IdComponent ItemTupleLength>
template <typename IdVecType>
VTKM_CONT
void AddCell(vtkm::UInt8 vtkmNotUsed(cellType),
void AddCell(vtkm::UInt8 shapeId,
vtkm::IdComponent numVertices,
const vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
const IdVecType &ids)
{
for (vtkm::IdComponent i=0; i < numVertices; ++i)
using Traits = vtkm::VecTraits<IdVecType>;
VTKM_STATIC_ASSERT_MSG(
(std::is_same<typename Traits::ComponentType,vtkm::Id>::value),
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
if (Traits::GetNumberOfComponents(ids) < numVertices)
{
throw vtkm::cont::ErrorBadValue(
"Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
if (this->CellShapeAsId == vtkm::CELL_SHAPE_EMPTY)
{
if (shapeId == vtkm::CELL_SHAPE_EMPTY)
{
throw vtkm::cont::ErrorBadValue(
"Cannot create cells of type empty.");
}
this->CellShapeAsId = shapeId;
this->CheckNumberOfPointsPerCell(numVertices);
this->NumberOfPointsPerCell = numVertices;
}
else
{
if (shapeId != this->GetCellShape(0))
{
throw vtkm::cont::ErrorBadValue(
"Cannot have differing shapes in CellSetSingleType.");
}
if (numVertices != this->NumberOfPointsPerCell)
{
throw vtkm::cont::ErrorBadValue(
"Inconsistent number of points in cells for CellSetSingleType.");
}
}
for (vtkm::IdComponent iVert=0; iVert < numVertices; ++iVert)
{
this->PointToCell.Connectivity.GetPortalControl().Set(
this->ConnectivityLength+i,ids[i]);
this->ConnectivityAdded+iVert, Traits::GetComponent(ids,iVert));
}
this->NumberOfCells++;
this->ConnectivityLength += numVertices;
this->NumberOfCellsAdded++;
this->ConnectivityAdded += numVertices;
}
/// Third and final method to add cells -- one at a time.
VTKM_CONT
void CompleteAddingCells()
void CompleteAddingCells(vtkm::Id numPoints)
{
this->PointToCell.Connectivity.Shrink(this->ConnectivityLength);
this->NumberOfPoints = numPoints;
this->PointToCell.Connectivity.Shrink(this->ConnectivityAdded);
vtkm::Id numCells = this->NumberOfCellsAdded;
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(this->GetCellShape(0), numCells);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(this->NumberOfPointsPerCell,
numCells);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(
vtkm::Id(0),
static_cast<vtkm::Id>(this->NumberOfPointsPerCell),
numCells);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorBadValue(
"Did not add the expected number of cells.");
}
this->NumberOfCellsAdded = -1;
this->ConnectivityAdded = -1;
this->ExpectedNumberOfCellsAdded = -1;
}
//This is the way you can fill the memory from another system without copying
VTKM_CONT
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id,
ConnectivityStorageTag> &connectivity)
void Fill(vtkm::Id numPoints,
vtkm::UInt8 shapeId,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id,ConnectivityStorageTag>
&connectivity)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::Id length = connectivity.GetNumberOfValues() / numberOfPointsPerCell;
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
this->NumberOfPoints = numPoints;
this->CellShapeAsId = shapeId;
this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
const vtkm::Id numCells =
connectivity.GetNumberOfValues() / numberOfPointsPerCell;
VTKM_ASSERT((connectivity.GetNumberOfValues() % numberOfPointsPerCell) == 0);
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, length);
vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
length);
numCells);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
static_cast<vtkm::Id>(numberOfPointsPerCell),
length );
numCells );
this->PointToCell.Connectivity = connectivity;
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
}
VTKM_CONT
vtkm::Id GetCellShapeAsId() const
{
return this->CellShapeAsId;
}
VTKM_CONT
vtkm::UInt8 GetCellShape(vtkm::Id vtkmNotUsed(cellIndex)) const
{
return static_cast<vtkm::UInt8>(this->CellShapeAsId);
}
virtual void PrintSummary(std::ostream &out) const
{
out << " ExplicitSingleCellSet: " << this->Name << " Type "<<this->CellShapeAsId<<std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->CellToPoint.PrintSummary(out);
}
private:
template< typename CellShapeTag>
void DetermineNumberOfPoints(CellShapeTag,
vtkm::CellTraitsTagSizeFixed,
vtkm::IdComponent& numberOfPoints) const
void CheckNumberOfPointsPerCell(CellShapeTag,
vtkm::CellTraitsTagSizeFixed,
vtkm::IdComponent numVertices) const
{
numberOfPoints = vtkm::CellTraits<CellShapeTag>::NUM_POINTS;
if (numVertices != vtkm::CellTraits<CellShapeTag>::NUM_POINTS)
{
throw vtkm::cont::ErrorBadValue(
"Passed invalid number of points for cell shape.");
}
}
template< typename CellShapeTag>
void DetermineNumberOfPoints(CellShapeTag,
vtkm::CellTraitsTagSizeVariable,
vtkm::IdComponent& numberOfPoints) const
{ //variable length cells can't be used with this class
numberOfPoints = -1;
void CheckNumberOfPointsPerCell(CellShapeTag,
vtkm::CellTraitsTagSizeVariable,
vtkm::IdComponent vtkmNotUsed(numVertices)) const
{
// Technically, a shape with a variable number of points probably has a
// minimum number of points, but we are not being sophisticated enough to
// check that. Instead, just pass the check by returning without error.
}
vtkm::IdComponent DetermineNumberOfPoints() const
void CheckNumberOfPointsPerCell(vtkm::IdComponent numVertices) const
{
vtkm::IdComponent numberOfPointsPerCell = -1;
switch (this->CellTypeAsId)
switch (this->CellShapeAsId)
{
vtkmGenericCellShapeMacro( this->DetermineNumberOfPoints(CellShapeTag(),
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
numberOfPointsPerCell) );
vtkmGenericCellShapeMacro(
this->CheckNumberOfPointsPerCell(CellShapeTag(),
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
numVertices) );
default:
throw vtkm::cont::ErrorControlBadValue(
throw vtkm::cont::ErrorBadValue(
"CellSetSingleType unable to determine the cell type");
}
return numberOfPointsPerCell;
}
vtkm::Id CellTypeAsId;
vtkm::Id ExpectedNumberOfCellsAdded;
vtkm::Id CellShapeAsId;
vtkm::IdComponent NumberOfPointsPerCell;
};
}

@ -0,0 +1,32 @@
//============================================================================
// 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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.
//============================================================================
#define vtkm_cont_CellSetStructured_cxx
#include <vtkm/cont/CellSetStructured.h>
namespace vtkm {
namespace cont {
template class VTKM_CONT_EXPORT CellSetStructured<1>;
template class VTKM_CONT_EXPORT CellSetStructured<2>;
template class VTKM_CONT_EXPORT CellSetStructured<3>;
}
}

@ -20,6 +20,8 @@
#ifndef vtk_m_cont_CellSetStructured_h
#define vtk_m_cont_CellSetStructured_h
#include <vtkm/cont/vtkm_cont_export.h>
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/TopologyElementTag.h>
@ -29,10 +31,8 @@
namespace vtkm {
namespace cont {
template<vtkm::IdComponent DIMENSION>
class CellSetStructured : public CellSet
class VTKM_ALWAYS_EXPORT CellSetStructured : public CellSet
{
private:
typedef vtkm::cont::CellSetStructured<DIMENSION> Thisclass;
@ -44,26 +44,14 @@ public:
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
VTKM_CONT
CellSetStructured(const std::string &name = std::string())
: CellSet(name)
: CellSet(name), Structure()
{
}
VTKM_CONT
CellSetStructured(const Thisclass &src)
: CellSet(src), Structure(src.Structure)
{ }
CellSetStructured(const Thisclass &src);
VTKM_CONT
Thisclass &operator=(const Thisclass &src)
{
this->CellSet::operator=(src);
this->Structure = src.Structure;
return *this;
}
virtual ~CellSetStructured() { }
Thisclass &operator=(const Thisclass &src);
virtual vtkm::Id GetNumberOfCells() const
{
@ -75,6 +63,10 @@ public:
return this->Structure.GetNumberOfPoints();
}
virtual vtkm::Id GetNumberOfFaces() const { return -1; }
virtual vtkm::Id GetNumberOfEdges() const { return -1; }
void SetPointDimensions(SchedulingRangeType dimensions)
{
this->Structure.SetPointDimensions(dimensions);
@ -90,25 +82,19 @@ public:
return this->Structure.GetCellDimensions();
}
VTKM_CONT
vtkm::IdComponent
GetNumberOfPointsInCell(vtkm::Id vtkmNotUsed(cellIndex)=0) const
{
return this->Structure.GetNumberOfPointsInCell();
}
VTKM_CONT
vtkm::IdComponent GetCellShape() const
{
return this->Structure.GetCellShape();
}
template<typename TopologyElement>
VTKM_CONT
SchedulingRangeType GetSchedulingRange(TopologyElement) const {
VTKM_IS_TOPOLOGY_ELEMENT_TAG(TopologyElement);
return this->Structure.GetSchedulingRange(TopologyElement());
}
SchedulingRangeType GetSchedulingRange(TopologyElement) const;
template<typename DeviceAdapter, typename FromTopology, typename ToTopology>
struct ExecutionTypes {
@ -120,26 +106,23 @@ public:
template<typename DeviceAdapter, typename FromTopology, typename ToTopology>
typename ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const
{
typedef typename
ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
ConnectivityType;
return ConnectivityType(this->Structure);
}
PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const;
virtual void PrintSummary(std::ostream &out) const
{
out << " StructuredCellSet: " << this->GetName() << std::endl;
this->Structure.PrintSummary(out);
}
virtual void PrintSummary(std::ostream &out) const;
private:
InternalsType Structure;
};
#ifndef vtkm_cont_CellSetStructured_cxx
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<1>;
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<2>;
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<3>;
#endif
}
} // namespace vtkm::cont
#include <vtkm/cont/CellSetStructured.hxx>
#endif //vtk_m_cont_CellSetStructured_h

@ -0,0 +1,69 @@
//============================================================================
// 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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.
//============================================================================
namespace vtkm {
namespace cont {
template<vtkm::IdComponent DIMENSION>
CellSetStructured<DIMENSION>::CellSetStructured(const CellSetStructured<DIMENSION> &src)
: CellSet(src), Structure(src.Structure)
{
}
template<vtkm::IdComponent DIMENSION>
CellSetStructured<DIMENSION>&
CellSetStructured<DIMENSION>::operator=(const CellSetStructured<DIMENSION> &src)
{
this->CellSet::operator=(src);
this->Structure = src.Structure;
return *this;
}
template<vtkm::IdComponent DIMENSION>
template<typename TopologyElement>
typename CellSetStructured<DIMENSION>::SchedulingRangeType
CellSetStructured<DIMENSION>::GetSchedulingRange(TopologyElement) const
{
VTKM_IS_TOPOLOGY_ELEMENT_TAG(TopologyElement);
return this->Structure.GetSchedulingRange(TopologyElement());
}
template<vtkm::IdComponent DIMENSION>
template<typename DeviceAdapter, typename FromTopology, typename ToTopology>
typename CellSetStructured<DIMENSION>::template ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
CellSetStructured<DIMENSION>::PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const
{
typedef typename
ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
ConnectivityType;
return ConnectivityType(this->Structure);
}
template<vtkm::IdComponent DIMENSION>
void CellSetStructured<DIMENSION>::PrintSummary(std::ostream &out) const
{
out << " StructuredCellSet: " << this->GetName() << std::endl;
this->Structure.PrintSummary(out);
}
}
}

@ -0,0 +1,59 @@
//============================================================================
// 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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/CoordinateSystem.h>
namespace vtkm {
namespace cont {
VTKM_CONT
void CoordinateSystem::PrintSummary(std::ostream &out) const
{
out << " Coordinate System ";
this->Superclass::PrintSummary(out);
}
VTKM_CONT
void CoordinateSystem::GetRange(vtkm::Range *range) const
{
this->Superclass::GetRange(
range,
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>&
CoordinateSystem::GetRange() const
{
return this->Superclass::GetRange(
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
VTKM_CONT
vtkm::Bounds CoordinateSystem::GetBounds() const
{
return this->GetBounds(VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
}
} // namespace vtkm::cont

@ -78,7 +78,7 @@ typedef vtkm::cont::DynamicArrayHandleBase<
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG>
DynamicArrayHandleCoordinateSystem;
class CoordinateSystem : public vtkm::cont::Field
class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
{
typedef vtkm::cont::Field Superclass;
@ -125,6 +125,9 @@ public:
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
{ }
VTKM_CONT
CoordinateSystem &operator=(const vtkm::cont::CoordinateSystem &src) = default;
VTKM_CONT
vtkm::cont::DynamicArrayHandleCoordinateSystem GetData() const
{
@ -139,105 +142,83 @@ public:
this->Superclass::GetData());
}
template<typename DeviceAdapterTag>
VTKM_CONT
void GetRange(vtkm::Range *range, DeviceAdapterTag) const
{
this->Superclass::GetRange(
range,
DeviceAdapterTag(),
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
void GetRange(vtkm::Range *range) const;
template<typename DeviceAdapterTag, typename TypeList>
template<typename TypeList>
VTKM_CONT
void GetRange(vtkm::Range *range, DeviceAdapterTag, TypeList) const
void GetRange(vtkm::Range *range, TypeList) const
{
this->Superclass::GetRange(
range,
DeviceAdapterTag(),
TypeList(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename DeviceAdapterTag, typename TypeList, typename StorageList>
VTKM_CONT
void GetRange(vtkm::Range *range, DeviceAdapterTag, TypeList, StorageList) const
{
this->Superclass::GetRange(
range,
DeviceAdapterTag(),
TypeList(),
StorageList());
}
template<typename DeviceAdapterTag>
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(DeviceAdapterTag) const
{
return this->Superclass::GetRange(
DeviceAdapterTag(),
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename DeviceAdapterTag, typename TypeList>
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(DeviceAdapterTag,
TypeList) const
{
return this->Superclass::GetRange(
DeviceAdapterTag(),
TypeList(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename DeviceAdapterTag, typename TypeList, typename StorageList>
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(DeviceAdapterTag,
TypeList,
StorageList) const
{
return this->Superclass::GetRange(
DeviceAdapterTag(),
TypeList(),
StorageList());
}
template<typename DeviceAdapterTag>
VTKM_CONT
vtkm::Bounds GetBounds(DeviceAdapterTag) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
return this->GetBounds(DeviceAdapterTag(),
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename DeviceAdapterTag, typename TypeList>
VTKM_CONT
vtkm::Bounds GetBounds(DeviceAdapterTag, TypeList) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
VTKM_IS_LIST_TAG(TypeList);
return this->GetBounds(DeviceAdapterTag(),
TypeList(),
this->Superclass::GetRange(
range,
TypeList(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename TypeList, typename StorageList>
VTKM_CONT
void GetRange(vtkm::Range *range, TypeList, StorageList) const
{
VTKM_IS_LIST_TAG(TypeList);
VTKM_IS_LIST_TAG(StorageList);
this->Superclass::GetRange(
range,
TypeList(),
StorageList());
}
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange() const;
template<typename TypeList>
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList) const
{
VTKM_IS_LIST_TAG(TypeList);
return this->Superclass::GetRange(
TypeList(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename TypeList, typename StorageList>
VTKM_CONT
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList,
StorageList) const
{
VTKM_IS_LIST_TAG(TypeList);
VTKM_IS_LIST_TAG(StorageList);
return this->Superclass::GetRange(
TypeList(),
StorageList());
}
VTKM_CONT
vtkm::Bounds GetBounds() const;
template<typename TypeList>
VTKM_CONT
vtkm::Bounds GetBounds(TypeList) const
{
VTKM_IS_LIST_TAG(TypeList);
return this->GetBounds(TypeList(),
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
}
template<typename DeviceAdapterTag, typename TypeList, typename StorageList>
template<typename TypeList, typename StorageList>
VTKM_CONT
vtkm::Bounds GetBounds(DeviceAdapterTag, TypeList, StorageList) const
vtkm::Bounds GetBounds(TypeList, StorageList) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
VTKM_IS_LIST_TAG(TypeList);
VTKM_IS_LIST_TAG(StorageList);
vtkm::cont::ArrayHandle<vtkm::Range> ranges =
this->GetRange(DeviceAdapterTag(), TypeList(), StorageList());
this->GetRange(TypeList(), StorageList());
VTKM_ASSERT(ranges.GetNumberOfValues() == 3);
@ -249,13 +230,7 @@ public:
rangePortal.Get(2));
}
VTKM_CONT
virtual void PrintSummary(std::ostream &out) const
{
out << " Coordinate System ";
this->Superclass::PrintSummary(out);
}
virtual void PrintSummary(std::ostream &out) const;
};
template<typename Functor>

@ -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");
}
}

@ -51,6 +51,23 @@ public:
//TODO
//Zoo explicit cell
template<typename T>
VTKM_CONT
static
vtkm::cont::DataSet
Create(const std::vector<T> &xVals,
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
std::vector<T> yVals(xVals.size(),0), zVals(xVals.size(),0);
return DataSetBuilderExplicit::Create(xVals,yVals,zVals,
shapes,numIndices,connectivity,
coordsNm,cellNm);
}
template<typename T>
VTKM_CONT
static
@ -138,6 +155,7 @@ public:
vtkm::cont::DataSet
Create(const std::vector<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells");
@ -148,12 +166,14 @@ public:
vtkm::cont::DataSet
Create(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
return DataSetBuilderExplicit::BuildDataSet(coords,
tag,
numberOfPointsPerCell,
connectivity,
coordsNm,
cellNm);
@ -189,6 +209,7 @@ private:
vtkm::cont::DataSet
BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm);
@ -249,9 +270,9 @@ DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::CoordinateSystem(coordsNm,
make_ArrayHandleCompositeVector(X,0, Y,0, Z,0)));
vtkm::Id nPts = X.GetNumberOfValues();
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
@ -296,9 +317,9 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm,
coords));
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
@ -309,6 +330,7 @@ inline VTKM_CONT
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
@ -319,7 +341,8 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
return DataSetBuilderExplicit::Create(coordsArray, tag, Cc, coordsNm, cellNm);
return DataSetBuilderExplicit::Create(
coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm, cellNm);
}
template<typename T, typename CellShapeTag>
@ -327,6 +350,7 @@ inline VTKM_CONT
vtkm::cont::DataSet
DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
@ -334,9 +358,12 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
vtkm::cont::DataSet dataSet;
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType<> cellSet(tag, coords.GetNumberOfValues(), cellNm);
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
cellSet.Fill(connectivity);
cellSet.Fill(coords.GetNumberOfValues(),
tag.Id,
numberOfPointsPerCell,
connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
@ -452,95 +479,6 @@ DataSetBuilderExplicitIterative::Create()
}
#if 0
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
const std::vector<T> &yVals,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
VTKM_CONT_ASSERT(xVals.size() == yVals.size() && xVals.size() > 0);
vtkm::cont::DataSet dataSet;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
std::vector<CoordType> coords(xVals.size());
for (size_t i=0; i < coords.size(); i++)
{
coords[i][0] = xVals[i];
coords[i][1] = yVals[i];
coords[i][2] = 0;
}
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
const std::vector<T> &yVals,
const std::vector<T> &zVals,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
VTKM_CONT_ASSERT(xVals.size() == yVals.size() &&
yVals.size() == zVals.size() &&
xVals.size() > 0);
vtkm::cont::DataSet dataSet;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
std::vector<CoordType> coords(xVals.size());
vtkm::Id nPts = static_cast<vtkm::Id>(coords.size());
for (vtkm::Id i=0; i < nPts; i++)
{
coords[i][0] = xVals[i];
coords[i][1] = yVals[i];
coords[i][2] = zVals[i];
}
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
vtkm::cont::DataSet dataSet;
vtkm::cont::ArrayHandle<Vec<T,3> > coordsArray;
CopyInto(coords, coordsArray);
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coordsArray));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
#endif
}
}

@ -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;
}

@ -24,6 +24,7 @@
// order in which the sub-files are loaded. (But the compile should still
// succeed of the order is changed.)
#include <vtkm/cont/internal/DeviceAdapterDefaultSelection.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
#include <vtkm/cont/internal/ArrayManagerExecution.h>

@ -58,6 +58,42 @@ struct DeviceAdapterAlgorithm
VTKM_CONT static void Copy(const vtkm::cont::ArrayHandle<T,CIn> &input,
vtkm::cont::ArrayHandle<U, COut> &output);
/// \brief Conditionally copy elements in the input array to the output array.
///
/// Calls the parallel primitive function of stream compaction on the \c
/// input to remove unwanted elements. The result of the stream compaction is
/// placed in \c output. The values in \c stencil are used to determine which
/// \c input values are placed into \c output, with all stencil values not
/// equal to the default constructor being considered valid.
/// The size of \c output will be modified after this call as we can't know
/// the number of elements that will be removed by the stream compaction
/// algorithm.
///
template<typename T, typename U, class CIn, class CStencil, class COut>
VTKM_CONT static void CopyIf(
const vtkm::cont::ArrayHandle<T,CIn> &input,
const vtkm::cont::ArrayHandle<U,CStencil> &stencil,
vtkm::cont::ArrayHandle<T,COut> &output);
/// \brief Conditionally copy elements in the input array to the output array.
///
/// Calls the parallel primitive function of stream compaction on the \c
/// input to remove unwanted elements. The result of the stream compaction is
/// placed in \c output. The values in \c stencil are passed to the unary
/// comparison object which is used to determine which /c input values are
/// placed into \c output.
/// The size of \c output will be modified after this call as we can't know
/// the number of elements that will be removed by the stream compaction
/// algorithm.
///
template<typename T, typename U, class CIn, class CStencil,
class COut, class UnaryPredicate>
VTKM_CONT static void CopyIf(
const vtkm::cont::ArrayHandle<T,CIn> &input,
const vtkm::cont::ArrayHandle<U,CStencil> &stencil,
vtkm::cont::ArrayHandle<T,COut> &output,
UnaryPredicate unary_predicate);
/// \brief Copy the contents of a section of one ArrayHandle to another
///
/// Copies the a range of elements of \c input to \c output. The number of
@ -341,57 +377,6 @@ struct DeviceAdapterAlgorithm
vtkm::cont::ArrayHandle<U,StorageU> &values,
BinaryCompare binary_compare)
/// \brief Performs stream compaction to remove unwanted elements in the input array. Output becomes the index values of input that are valid.
///
/// Calls the parallel primitive function of stream compaction on the \c
/// input to remove unwanted elements. The result of the stream compaction is
/// placed in \c output. The \c input values are used as the stream
/// compaction stencil while \c input indices are used as the values to place
/// into \c output. The size of \c output will be modified after this call as
/// we can't know the number of elements that will be removed by the stream
/// compaction algorithm.
///
template<typename T, class CStencil, class COut>
VTKM_CONT static void StreamCompact(
const vtkm::cont::ArrayHandle<T,CStencil> &stencil,
vtkm::cont::ArrayHandle<vtkm::Id,COut> &output);
/// \brief Performs stream compaction to remove unwanted elements in the input array.
///
/// Calls the parallel primitive function of stream compaction on the \c
/// input to remove unwanted elements. The result of the stream compaction is
/// placed in \c output. The values in \c stencil are used to determine which
/// \c input values are placed into \c output, with all stencil values not
/// equal to the default constructor being considered valid.
/// The size of \c output will be modified after this call as we can't know
/// the number of elements that will be removed by the stream compaction
/// algorithm.
///
template<typename T, typename U, class CIn, class CStencil, class COut>
VTKM_CONT static void StreamCompact(
const vtkm::cont::ArrayHandle<T,CIn> &input,
const vtkm::cont::ArrayHandle<U,CStencil> &stencil,
vtkm::cont::ArrayHandle<T,COut> &output);
/// \brief Performs stream compaction to remove unwanted elements in the input array.
///
/// Calls the parallel primitive function of stream compaction on the \c
/// input to remove unwanted elements. The result of the stream compaction is
/// placed in \c output. The values in \c stencil are passed to the unary
/// comparison object which is used to determine which /c input values are
/// placed into \c output.
/// The size of \c output will be modified after this call as we can't know
/// the number of elements that will be removed by the stream compaction
/// algorithm.
///
template<typename T, typename U, class CIn, class CStencil,
class COut, class UnaryPredicate>
VTKM_CONT static void StreamCompact(
const vtkm::cont::ArrayHandle<T,CIn> &input,
const vtkm::cont::ArrayHandle<U,CStencil> &stencil,
vtkm::cont::ArrayHandle<T,COut> &output,
UnaryPredicate unary_predicate);
/// \brief Completes any asynchronous operations running on the device.
///
/// Waits for any asynchronous operations running on the device to complete.
@ -584,20 +569,4 @@ class DeviceAdapterAtomicArrayImplementation;
}
} // namespace vtkm::cont
//-----------------------------------------------------------------------------
// These includes are intentionally placed here after the declaration of the
// DeviceAdapterAlgorithm template prototype, which all the implementations
// need.
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_SERIAL
#include <vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h>
#elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_CUDA
#include <vtkm/cont/cuda/internal/DeviceAdapterAlgorithmCuda.h>
// #elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_OPENMP
// #include <vtkm/openmp/cont/internal/DeviceAdapterAlgorithmOpenMP.h>
#elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_TBB
#include <vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h>
#endif
#endif //vtk_m_cont_DeviceAdapterAlgorithm_h

@ -6,9 +6,9 @@
// 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.
// Copyright 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 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.
@ -17,25 +17,23 @@
// 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>
#include <vtkm/cont/DynamicArrayHandle.h>
namespace vtkm {
namespace cont {
namespace detail {
/// The superclass of all exceptions thrown from within the VTKm control
/// environment.
///
class ErrorControl : public vtkm::cont::Error
PolymorphicArrayHandleContainerBase::PolymorphicArrayHandleContainerBase()
{
protected:
ErrorControl() { }
ErrorControl(const std::string message) : Error(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControl_h
PolymorphicArrayHandleContainerBase::~PolymorphicArrayHandleContainerBase()
{
}
}
}
} // namespace vtkm::cont::detail

@ -20,15 +20,19 @@
#ifndef vtk_m_cont_DynamicArrayHandle_h
#define vtk_m_cont_DynamicArrayHandle_h
#include <vtkm/cont/vtkm_cont_export.h>
#include <vtkm/TypeListTag.h>
#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>
#include <sstream>
namespace vtkm {
namespace cont {
@ -40,10 +44,12 @@ namespace detail {
/// \brief Base class for PolymorphicArrayHandleContainer
///
struct PolymorphicArrayHandleContainerBase
struct VTKM_CONT_EXPORT PolymorphicArrayHandleContainerBase
{
PolymorphicArrayHandleContainerBase();
// This must exist so that subclasses are destroyed correctly.
virtual ~PolymorphicArrayHandleContainerBase() { }
virtual ~PolymorphicArrayHandleContainerBase();
virtual vtkm::IdComponent GetNumberOfComponents() const = 0;
virtual vtkm::Id GetNumberOfValues() const = 0;
@ -63,7 +69,7 @@ struct PolymorphicArrayHandleContainerBase
/// simple questions about the object.
///
template<typename T, typename Storage>
struct PolymorphicArrayHandleContainer
struct VTKM_ALWAYS_EXPORT PolymorphicArrayHandleContainer
: public PolymorphicArrayHandleContainerBase
{
typedef vtkm::cont::ArrayHandle<T, Storage> ArrayHandleType;
@ -184,7 +190,7 @@ DynamicArrayHandleTryCast(
/// lists.
///
template<typename TypeList, typename StorageList>
class DynamicArrayHandleBase
class VTKM_ALWAYS_EXPORT DynamicArrayHandleBase
{
public:
VTKM_CONT
@ -256,7 +262,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.
///
///
@ -268,7 +274,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
@ -277,7 +283,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>
@ -294,7 +300,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
@ -399,7 +405,7 @@ public:
}
VTKM_CONT
virtual void PrintSummary(std::ostream &out) const
void PrintSummary(std::ostream &out) const
{
this->ArrayContainer->PrintSummary(out);
}
@ -452,6 +458,8 @@ private:
{
// This type of array handle cannot exist, so do nothing.
}
void operator=(const DynamicArrayHandleTryStorage<Functor,Type> &) = delete;
};
template<typename Functor, typename StorageList>
@ -478,6 +486,9 @@ struct DynamicArrayHandleTryType {
this->FoundCast = true;
}
}
private:
void operator=(const DynamicArrayHandleTryType<Functor,StorageList> &) = delete;
};
} // namespace detail
@ -505,8 +516,13 @@ void DynamicArrayHandleBase<TypeList,StorageList>::
vtkm::ListForEach(tryType, TypeList());
if (!tryType.FoundCast)
{
throw vtkm::cont::ErrorControlBadValue(
"Could not find appropriate cast for array in CastAndCall.");
std::ostringstream out;
out << "Could not find appropriate cast for array in CastAndCall1.\n"
"Array: ";
this->PrintSummary(out);
out << "TypeList: " << typeid(TypeList).name()
<< "\nStorageList: " << typeid(StorageList).name() << "\n";
throw vtkm::cont::ErrorBadValue(out.str());
}
}
@ -529,8 +545,8 @@ void DynamicArrayHandleBase<VTKM_DEFAULT_TYPE_LIST_TAG,
vtkm::ListForEach(tryType, VTKM_DEFAULT_TYPE_LIST_TAG());
if (!tryType.FoundCast)
{
throw vtkm::cont::ErrorControlBadValue(
"Could not find appropriate cast for array in CastAndCall.");
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>
@ -116,7 +116,7 @@ DynamicCellSetTryCast(
/// with the default cell set list.
///
template<typename CellSetList>
class DynamicCellSetBase
class VTKM_ALWAYS_EXPORT DynamicCellSetBase
{
VTKM_IS_LIST_TAG(CellSetList);
public:
@ -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
@ -254,37 +254,37 @@ public:
}
VTKM_CONT
virtual std::string GetName() const
std::string GetName() const
{
return this->CastToBase().GetName();
}
VTKM_CONT
virtual vtkm::Id GetNumberOfCells() const
vtkm::Id GetNumberOfCells() const
{
return this->CastToBase().GetNumberOfCells();
}
VTKM_CONT
virtual vtkm::Id GetNumberOfFaces() const
vtkm::Id GetNumberOfFaces() const
{
return this->CastToBase().GetNumberOfFaces();
}
VTKM_CONT
virtual vtkm::Id GetNumberOfEdges() const
vtkm::Id GetNumberOfEdges() const
{
return this->CastToBase().GetNumberOfEdges();
}
VTKM_CONT
virtual vtkm::Id GetNumberOfPoints() const
vtkm::Id GetNumberOfPoints() const
{
return this->CastToBase().GetNumberOfPoints();
}
VTKM_CONT
virtual void PrintSummary(std::ostream& stream) const
void PrintSummary(std::ostream& stream) const
{
return this->CastToBase().PrintSummary(stream);
}
@ -326,6 +326,9 @@ struct DynamicCellSetTryCellSet
}
}
}
private:
void operator=(const DynamicCellSetTryCellSet<Functor> &) = delete;
};
} // namespace detail
@ -341,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.");
}
}

@ -24,14 +24,19 @@
// templated. If there is any reason to create a VTKm control library,
// this class and its subclasses should probably go there.
#include <exception>
#include <string>
#include <vtkm/internal/ExportMacros.h> // For VTKM_OVERRIDE
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// The superclass of all exceptions thrown by any VTKm function or method.
///
class Error
class VTKM_ALWAYS_EXPORT Error : public std::exception
{
public:
//See note about GetMessage macro below.
@ -47,6 +52,12 @@ public:
const std::string &GetMessageW() const { return this->Message; }
#endif
// For std::exception compatibility:
const char* what() const VTKM_NOEXCEPT VTKM_OVERRIDE
{
return this->Message.c_str();
}
protected:
Error() { }
Error(const std::string message) : Message(message) { }
@ -60,6 +71,8 @@ private:
std::string Message;
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -17,25 +17,29 @@
// 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 {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when VTK-m attempts to manipulate memory that it should
/// not.
///
class 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) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlBadAllocation_h
#endif //vtk_m_cont_ErrorBadAllocation_h

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