diff --git a/.gitattributes b/.gitattributes index f67ede8d2..c9d57724b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,7 +10,8 @@ data/** filter=lfs diff=lfs merge=lfs -text /**/data/** filter=lfs diff=lfs merge=lfs -text *.cmake whitespace=tab-in-indent -*.md whitespace=tab-in-indent conflict-marker-size=79 -whitespace +*.md whitespace=tab-in-indent whitespace=-blank-at-eol conflict-marker-size=79 -whitespace +*.md.tmpl whitespace=tab-in-indent whitespace=-blank-at-eol conflict-marker-size=79 -whitespace *.rst whitespace=tab-in-indent conflict-marker-size=79 *.txt whitespace=tab-in-indent diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77324c664..765e67a0c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,51 +1,3 @@ - -# Docker Images: -# -# * .gitlab/ci/docker/centos7/cuda10.2/ -# - cuda -# - gcc 7.3.1 -# * .gitlab/ci/docker/centos8/base/ -# - gcc 8.3.1 -# - clang 8.0.1 -# - openmp -# - asan, ubsan -# * .gitlab/ci/docker/rhel8/cuda10.2/ -# - cuda -# - gcc 8.2.1 -# * .gitlab/ci/docker/ubuntu1604/base/ -# - gcc 5.4.0 -# - clang 3.8 -# - clang 5.0 -# - tbb -# - openmpi -# * .gitlab/ci/docker/ubuntu1604/cuda9.2/ -# - cuda -# - gcc 5.4 -# - tbb -# - openmp -# - openmpi -# * .gitlab/ci/docker/ubuntu1804/base/ -# - gcc 6.5 -# - gcc 7.4 -# - gcc 9 -# - clang 8 -# - tbb -# - openmp -# - mpich2 -# - hdf5 -# * .gitlab/ci/docker/ubuntu1804/cuda11.1/ -# - cuda -# - gcc 7 -# - gcc 8 -# - tbb -# - openmp -# - mpich2 -# * .gitlab/ci/docker/ubuntu2004/doxygen/ -# - gcc 9.3 -# - tbb -# - openmp -# - mpich2 - .docker_image: &docker_image variables: GIT_CLONE_PATH: $CI_BUILDS_DIR/gitlab-kitware-sciviz-ci @@ -81,7 +33,7 @@ - .docker_image .ubuntu1804_cuda: &ubuntu1804_cuda - image: "kitware/vtkm:ci-ubuntu1804_cuda11.6-20220407" + image: "kitware/vtkm:ci-ubuntu1804_cuda11-20220919" extends: - .docker_image @@ -96,7 +48,7 @@ - .docker_image .ubuntu2004: &ubuntu2004 - image: "kitware/vtkm:ci-ubuntu2004-20210920" + image: "kitware/vtkm:ci-ubuntu2004-20220623" extends: - .docker_image @@ -118,6 +70,12 @@ when: on_success - when: never +.run_only_merge_requests: &run_only_merge_requests + rules: + - if: '$CI_MERGE_REQUEST_ID && $CI_PROJECT_PATH == "vtk/vtk-m"' + when: on_success + - when: never + .run_scheduled: &run_scheduled rules: - if: '$CI_PROJECT_PATH == "vtk/vtk-m" && $CI_COMMIT_TAG' @@ -132,12 +90,18 @@ when: on_success - when: never -.run_ecp_ci: &run_ecp_ci +.run_ascent_ci: &run_ascent_ci rules: - if: '$CI_PROJECT_PATH == "ecpcitest/vtk-m"' when: on_success - when: never +.run_spock_ci: &run_spock_ci + rules: + - if: '$CI_PROJECT_PATH == "ci/csc331_crusher/dev/vtk-m"' + when: on_success + - when: never + # General Longer Term Tasks: # - Setup clang tidy as sub-pipeline # - Setup a machine to replicate the issue in https://gitlab.kitware.com/vtk/vtk-m/-/issues/447 @@ -250,6 +214,7 @@ stages: include: - local: '/.gitlab/ci/ascent.yml' + - local: '/.gitlab/ci/spock.yml' - local: '/.gitlab/ci/centos7.yml' - local: '/.gitlab/ci/centos8.yml' - local: '/.gitlab/ci/doxygen.yml' diff --git a/.gitlab/ci/ascent.yml b/.gitlab/ci/ascent.yml index 79049f1cb..569fb19b6 100644 --- a/.gitlab/ci/ascent.yml +++ b/.gitlab/ci/ascent.yml @@ -1,86 +1,83 @@ # Ad-hoc build that runs in the ECP Hardware, concretely in OLCF Ascent. +.ascent_gcc_cuda: + variables: + CCACHE_BASEDIR: "/gpfs/wolf/" + CCACHE_DIR: "/gpfs/wolf/proj-shared/csc331/vtk-m/ci/ccache/" + # -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it + CCACHE_IGNOREOPTIONS: "-isystem=*" + CCACHE_NOHASHDIR: "true" + + CC: "gcc" + CXX: "g++" + CMAKE_BUILD_TYPE: "RelWithDebInfo" + CMAKE_GENERATOR: "Ninja" + CUDAHOSTCXX: "g++" + CUSTOM_CI_BUILDS_DIR: "/gpfs/wolf/proj-shared/csc331/vtk-m/ci/runtime" + + VTKM_SETTINGS: cuda+ascent+ccache + JOB_MODULES: >- + git-lfs + zstd + cuda/11.4.2 + gcc/10.2.0 + ninja + spectrum-mpi + lsf-tools + cmake + interruptible: true + +.setup_env_ecpci: &setup_env_ecpci | + module purge + module load ${JOB_MODULES} + module list + export PATH="/gpfs/wolf/proj-shared/csc331/vtk-m/ci/utils:$PATH" build:ascent_gcc_cuda: + stage: build tags: [olcf, ascent, nobatch] extends: - .ascent_gcc_cuda - - .ascent_build - - .run_ecp_ci - - .cmake_build_artifacts + - .run_ascent_ci + before_script: + - *setup_env_ecpci + - ccache -z + - git remote add lfs https://gitlab.kitware.com/vtk/vtk-m.git + - git fetch lfs + - git-lfs install + - git-lfs pull lfs + script: + - CTEST_MAX_PARALLELISM=32 cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake + - ctest -VV -S .gitlab/ci/ctest_configure.cmake + artifacts: + expire_in: 24 hours + when: always + paths: + - build/ + timeout: 10 minutes test:ascent_gcc_cuda: + stage: test tags: [olcf, ascent, batch] extends: - .ascent_gcc_cuda - - .ascent_test - - .run_ecp_ci + - .run_ascent_ci - .cmake_test_artifacts needs: - build:ascent_gcc_cuda dependencies: - build:ascent_gcc_cuda - -.ascent_gcc_cuda: variables: - CCACHE_BASEDIR: /gpfs/wolf/ - CCACHE_DIR: "/gpfs/wolf/proj-shared/csc331/vtk-m/ci/ccache/" - - # -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it - CCACHE_IGNOREOPTIONS: "-isystem=*" - CCACHE_NOHASHDIR: "true" - - CMAKE_BUILD_TYPE: RelWithDebInfo - CMAKE_GENERATOR: Ninja - CUSTOM_CI_BUILDS_DIR: "/gpfs/wolf/proj-shared/csc331/vtk-m/ci/runtime" - - CC: gcc - CXX: g++ - CUDAHOSTCXX: g++ - JOB_MODULES: git cmake ninja gcc/10.2.0 spectrum-mpi lsf-tools cuda/11.4.2 - VTKM_SETTINGS: cuda+ascent+ccache - -.ascent_build: - stage: build - variables: - CTEST_MAX_PARALLELISM: 4 + SCHEDULER_PARAMETERS: -P CSC331 -W 2:00 -nnodes 1 -alloc_flags gpudefault + # We need this to skip ctest_submit from being run inside a jsrun job + GITLAB_CI_EMULATION: 1 before_script: - # Prep the environment - - module purge - - echo ${JOB_MODULES} - - module load git-lfs zstd ${JOB_MODULES} - - export PATH="/gpfs/wolf/proj-shared/csc331/vtk-m/ci/utils:$PATH" - - ccache -p - - ccache -z - - - git remote add lfs https://gitlab.kitware.com/vtk/vtk-m.git - - git fetch lfs - - git-lfs install - - git-lfs pull lfs - - # Start running the builds scripts - - cmake --version - - "cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake" - - "ctest -VV -S .gitlab/ci/ctest_configure.cmake" - + - *setup_env_ecpci script: - - "ctest -VV -S .gitlab/ci/ctest_build.cmake" + - jsrun -n1 -a1 -g1 -c42 ctest -VV -S .gitlab/ci/ctest_build.cmake + - CTEST_MAX_PARALLELISM=4 jsrun -n1 -a1 -g1 -c8 ctest -VV -S .gitlab/ci/ctest_test.cmake + after_script: + - *setup_env_ecpci - ccache -s - -.ascent_test: - stage: test - variables: - SCHEDULER_PARAMETERS: -P CSC331 -W 1:00 -nnodes 1 -alloc_flags gpudefault - CTEST_MAX_PARALLELISM: 8 - # Tests errors to address due to different env/arch in Ascent - # Refer to issue: https://gitlab.kitware.com/vtk/vtk-m/-/issues/652 - CTEST_EXCLUSIONS: >- - - before_script: - # Prep the environment - - module purge - - module load ${JOB_MODULES} - - script: - - "jsrun -n1 -r1 -a1 -g1 -c7 ctest -VV -S .gitlab/ci/ctest_test.cmake || test_output=$?" - - ctest -VV -S .gitlab/ci/ctest_test_submit.cmake - - $(exit $test_output) + - ctest -VV -S .gitlab/ci/ctest_submit_build.cmake + - ctest -VV -S .gitlab/ci/ctest_submit_test.cmake + timeout: 120 minutes diff --git a/.gitlab/ci/centos7.yml b/.gitlab/ci/centos7.yml index f07f38a29..7fb803fee 100644 --- a/.gitlab/ci/centos7.yml +++ b/.gitlab/ci/centos7.yml @@ -7,7 +7,6 @@ build:centos7_gcc73: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .centos7 @@ -31,6 +30,7 @@ test:centos7_gcc73: - .centos7 - .cmake_test_linux - .run_automatically + - .use_minimum_supported_cmake dependencies: - build:centos7_gcc73 needs: diff --git a/.gitlab/ci/centos8.yml b/.gitlab/ci/centos8.yml index 94fe3f4ea..70d3f74e0 100644 --- a/.gitlab/ci/centos8.yml +++ b/.gitlab/ci/centos8.yml @@ -53,4 +53,4 @@ build:centos8: variables: CMAKE_BUILD_TYPE: RelWithDebInfo CMAKE_GENERATOR: "Unix Makefiles" - VTKM_SETTINGS: "serial+no_testing" + VTKM_SETTINGS: "serial+no_testing+min_build" diff --git a/.gitlab/ci/config/ccache.cmake b/.gitlab/ci/config/ccache.cmake index 375bfce3c..5e5f90c66 100644 --- a/.gitlab/ci/config/ccache.cmake +++ b/.gitlab/ci/config/ccache.cmake @@ -43,14 +43,14 @@ if(NOT DEFINED full_url) endif() file(DOWNLOAD - "${full_url}" .gitlab/${tarball} + "${full_url}" $ENV{CCACHE_INSTALL_DIR}/${tarball} EXPECTED_HASH SHA256=${sha256sum} SHOW_PROGRESS ) execute_process( COMMAND ${CMAKE_COMMAND} -E tar xf ${tarball} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.gitlab + WORKING_DIRECTORY $ENV{CCACHE_INSTALL_DIR} RESULT_VARIABLE extract_results ) @@ -58,4 +58,4 @@ if(extract_results) message(FATAL_ERROR "Extracting `${tarball}` failed: ${extract_results}.") endif() -file(RENAME .gitlab/${filename} .gitlab/ccache) +file(RENAME $ENV{CCACHE_INSTALL_DIR}/${filename} $ENV{CCACHE_INSTALL_DIR}/ccache) diff --git a/.gitlab/ci/config/cmake.sh b/.gitlab/ci/config/cmake.sh index 1f2c74618..1de03fe72 100755 --- a/.gitlab/ci/config/cmake.sh +++ b/.gitlab/ci/config/cmake.sh @@ -1,31 +1,25 @@ #!/usr/bin/env bash # shellcheck disable=SC2079 -set -x +set -ex -version="${1:-3.21.1}" +version="${1:-3.23.4}" case "$( uname -s )" in Linux) - shatool="sha256sum" - # We require CMake >= 3.13 in the CI to support CUDA builds - readonly -A linuxParamsByVersion=( - ['3.13.5']='e2fd0080a6f0fc1ec84647acdcd8e0b4019770f48d83509e6a5b0b6ea27e5864 Linux' - ['3.21.1']='bf496ce869d0aa8c1f57e4d1a2e50c8f2fb12a6cd7ccb37ad743bb88f6b76a1e linux' + readonly -A sumsByVersion=( + # We require CMake >= 3.13 in the CI to support CUDA builds + ['3.13.5']='e2fd0080a6f0fc1ec84647acdcd8e0b4019770f48d83509e6a5b0b6ea27e5864' + ['3.23.4']='3fbcbff85043d63a8a83c8bdf8bd5b1b2fd5768f922de7dc4443de7805a2670d' ) - - if [ -z "${linuxParamsByVersion[$version]}" ] - then - echo "Given version ($version) is unsupported" - exit 1 - fi - sha256sum=$(cut -f 1 <<<"${linuxParamsByVersion[$version]}") - platform=$(cut -f 2 <<<"${linuxParamsByVersion[$version]}") + shatool="sha256sum" + sha256sum="${sumsByVersion[$version]}" + platform="linux" arch="x86_64" ;; Darwin) shatool="shasum -a 256" - sha256sum="9dc2978c4d94a44f71336fa88c15bb0eee47cf44b6ece51b10d1dfae95f82279" + sha256sum="98cac043cdf321caa4fd07f27da3316db6c8bc48c39997bf78e27e5c46c4eb68" platform="macos" arch="universal" ;; @@ -39,16 +33,17 @@ readonly sha256sum readonly platform readonly arch -readonly filename="cmake-$version-$platform-$arch" -readonly tarball="$filename.tar.gz" - cd .gitlab || exit +readonly tarball="cmake-$version-$platform-$arch.tar.gz" +curl -SOL "https://github.com/Kitware/CMake/releases/download/v$version/$tarball" + echo "$sha256sum $tarball" > cmake.sha256sum -curl -OL "https://github.com/Kitware/CMake/releases/download/v$version/$tarball" $shatool --check cmake.sha256sum -tar xf "$tarball" -mv "$filename" cmake + +# Extract cmake install root into director named cmake +mkdir cmake +tar xf "$tarball" --strip-components=1 -C cmake if [ "$( uname -s )" = "Darwin" ]; then ln -s CMake.app/Contents/bin cmake/bin diff --git a/.gitlab/ci/config/ecpci-amend-commit.sh b/.gitlab/ci/config/ecpci-amend-commit.sh new file mode 100755 index 000000000..912d89015 --- /dev/null +++ b/.gitlab/ci/config/ecpci-amend-commit.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e +# shellcheck disable=SC2155 + +git rev-parse @ > ./ORIGINAL_COMMIT_SHA +git add ./ORIGINAL_COMMIT_SHA + +readonly name="$(git show --quiet --format='%cn')" +readonly email="$(git show --quiet --format='%ce')" + +git config --global user.name "$name" +git config --global user.email "$email" +git commit --amend --no-edit -a + +git rev-parse @ > "$1" diff --git a/.gitlab/ci/config/ecpci-fetch-commit-trace.py b/.gitlab/ci/config/ecpci-fetch-commit-trace.py new file mode 100755 index 000000000..12358ca85 --- /dev/null +++ b/.gitlab/ci/config/ecpci-fetch-commit-trace.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import json +import ssl +import sys +import urllib.request + + +class ecpci_url_reader: + def __init__(self, base_url, token): + self.base_url = base_url + self.token = token + + def to_string(self, url): + opener = urllib.request.build_opener( + urllib.request.HTTPSHandler( + context=ssl._create_unverified_context())) + opener.addheaders = [('PRIVATE-TOKEN', token)] + return opener.open(base_url + url).read().decode('utf-8') + + def to_json(self, url): + return json.loads(self.to_string(url)) + + +base_url = sys.argv[1] +commit = sys.argv[2] +token = sys.argv[3] + +handler = ecpci_url_reader(base_url, token) + +commit_info = handler.to_json("/repository/commits/" + commit) +last_pipeline_id = str(commit_info['last_pipeline']['id']) + +jobs = handler.to_json("/pipelines/" + last_pipeline_id + "/jobs") +build_job_id = str(jobs[1]['id']) +test_job_id = str(jobs[0]['id']) + +print("ECPCITEST CONFIGURE OUTPUT============================================") +print(handler.to_string("/jobs/" + build_job_id + "/trace")) +print("ECPCITEST CONFIGURE END===============================================") + +print("ECPCITEST TEST OUTPUT=================================================") +print(handler.to_string("/jobs/" + test_job_id + "/trace")) +print("ECPCITEST TEST OUTPUT END=============================================") diff --git a/.gitlab/ci/config/ecpci-push-branch.sh b/.gitlab/ci/config/ecpci-push-branch.sh new file mode 100755 index 000000000..1df586417 --- /dev/null +++ b/.gitlab/ci/config/ecpci-push-branch.sh @@ -0,0 +1,4 @@ +#!/bin/bash -ex + +git lfs uninstall +git -c http.sslVerify=false push -f "$1" "HEAD:refs/heads/${2}" diff --git a/.gitlab/ci/config/ecpci-remove-branch.sh b/.gitlab/ci/config/ecpci-remove-branch.sh new file mode 100755 index 000000000..fcb8f37d9 --- /dev/null +++ b/.gitlab/ci/config/ecpci-remove-branch.sh @@ -0,0 +1,3 @@ +#!/bin/bash -ex + +git -c http.sslVerify=false push --delete "$1" "$2" diff --git a/.gitlab/ci/config/ecpci-wait-commit-status.sh b/.gitlab/ci/config/ecpci-wait-commit-status.sh new file mode 100755 index 000000000..b1176ecd9 --- /dev/null +++ b/.gitlab/ci/config/ecpci-wait-commit-status.sh @@ -0,0 +1,68 @@ +#!/bin/bash -e +# shellcheck disable=SC2155 + +declare -r POLL_INTERVAL_SECONDS="10" + +function fetch_commit_status() +{ + local -r url="$1" + local -r commit="$2" + + local output=$(curl --insecure --silent "${url}/repository/commits/${commit}" \ + | tr ',{}[]' '\n' \ + | grep -Po -m1 '(?<=^"status":")\w+(?=")' \ + ) + + # No status means that the pipeline has not being created yet + [ -z "$output" ] && output="empty" + echo "$output" +} + +function print_pipeline_url() +{ + local -r url="$1" + local -r commit="$2" + + local web_url=$(curl --insecure --silent "${url}" \ + | tr ',{}[]' '\n' \ + | grep -Po -m1 '(?<=^"web_url":").+(?=")' \ + ) + + local pipeline_id=$(curl --insecure --silent "${url}/repository/commits/${commit}" \ + | tr ',{}[]' '\n' \ + | grep -Po '(?<=^"id":)\d+$' \ + ) + + echo "######################################################################" + echo "ECP Pipeline: ${web_url}/-/pipelines/$pipeline_id" + echo "######################################################################" +} + +function wait_commit_pipeline_status() +{ + local -r base_url="$1" + local -r commit="$2" + local is_url_printed="no" + + while true + do + local ret="$(fetch_commit_status "$base_url" "$commit")" + + if [ "$ret" != "empty" ] && [ "$is_url_printed" == "no" ] + then + print_pipeline_url "$base_url" "$commit" + is_url_printed="yes" + fi + + case "$ret" in + success) + return 0 ;; + failed|canceled|skipped) + echo "ERROR: The pipeline exited with \`${ret}\` status" > /dev/stderr + return 1 ;; + esac + sleep "$POLL_INTERVAL_SECONDS" + done +} + +wait_commit_pipeline_status "$1" "$2" diff --git a/.gitlab/ci/config/gitlab_ci_setup.cmake b/.gitlab/ci/config/gitlab_ci_setup.cmake index cafefc65d..c0a88803a 100644 --- a/.gitlab/ci/config/gitlab_ci_setup.cmake +++ b/.gitlab/ci/config/gitlab_ci_setup.cmake @@ -94,6 +94,12 @@ if(DEFINED ENV{CTEST_MEMORYCHECK_SANITIZER_OPTIONS}) list(APPEND optional_variables "set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS ${env_value})") endif() +# Override revision (Git Commit) if ORIGINAL_COMMIT_SHA is found in source code +if (EXISTS "ORIGINAL_COMMIT_SHA") + file(READ "ORIGINAL_COMMIT_SHA" commit_sha) + list(APPEND optional_variables "set(CTEST_UPDATE_VERSION_OVERRIDE ${commit_sha})") +endif() + #We need to do write this information out to a file in the build directory file(TO_CMAKE_PATH "${CTEST_SOURCE_DIRECTORY}" src_path) #converted so we can run on windows file(TO_CMAKE_PATH "${CTEST_BINARY_DIRECTORY}" bin_path) #converted so we can run on windows diff --git a/.gitlab/ci/config/google_benchmarks.sh b/.gitlab/ci/config/google_benchmarks.sh index 5e8aef597..e778c5170 100755 --- a/.gitlab/ci/config/google_benchmarks.sh +++ b/.gitlab/ci/config/google_benchmarks.sh @@ -22,6 +22,9 @@ tar xf "$tarball" mkdir build mkdir "$install_dir" -cmake -GNinja -S benchmark* -B build -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON +cmake -GNinja -S benchmark* -B build \ + -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON \ + -DCMAKE_BUILD_TYPE="Release" + cmake --build build cmake --install build --prefix "$install_dir" diff --git a/.gitlab/ci/config/initial_config.cmake b/.gitlab/ci/config/initial_config.cmake index ee7b7abcb..a0623dc12 100644 --- a/.gitlab/ci/config/initial_config.cmake +++ b/.gitlab/ci/config/initial_config.cmake @@ -53,9 +53,6 @@ foreach(option IN LISTS options) elseif(no_rendering STREQUAL option) set(VTKm_ENABLE_RENDERING "OFF" CACHE STRING "") - elseif(use_virtuals STREQUAL option) - set(VTKm_NO_DEPRECATED_VIRTUAL "OFF" CACHE STRING "") - elseif(no_testing STREQUAL option) set(VTKm_ENABLE_TESTING "OFF" CACHE STRING "") set(VTKm_ENABLE_TESTING_LIBRARY "OFF" CACHE STRING "") @@ -71,6 +68,10 @@ foreach(option IN LISTS options) set(VTKm_ENABLE_BENCHMARKS "ON" CACHE STRING "") set(ENV{CMAKE_PREFIX_PATH} "$ENV{CMAKE_PREFIX_PATH}:$ENV{HOME}/gbench") + elseif(min_build STREQUAL option) + set(VTKm_BUILD_ALL_LIBRARIES "OFF" CACHE STRING "") + set(VTKm_VERBOSE_MODULES "ON" CACHE STRING "") + elseif(mpi STREQUAL option) set(VTKm_ENABLE_MPI "ON" CACHE STRING "") @@ -107,15 +108,19 @@ foreach(option IN LISTS options) set(VTKm_CUDA_Architecture "turing" CACHE STRING "") endif() + elseif(ampere STREQUAL option) + set(CMAKE_CUDA_ARCHITECTURES "80" CACHE STRING "") + elseif(hip STREQUAL option) if(CMAKE_VERSION VERSION_LESS_EQUAL 3.20) message(FATAL_ERROR "VTK-m requires cmake > 3.20 to enable HIP support") endif() - set(CMAKE_C_COMPILER "/opt/rocm/llvm/bin/clang" CACHE FILEPATH "") - set(CMAKE_CXX_COMPILER "/opt/rocm/llvm/bin/clang++" CACHE FILEPATH "") set(VTKm_ENABLE_KOKKOS_HIP ON CACHE STRING "") - set(CMAKE_HIP_ARCHITECTURES "gfx900" CACHE STRING "") + + # -O1 and -O2 results in ridiculous build times in ROCm < 5.3 + set(CMAKE_HIP_FLAGS "-O0 " CACHE STRING "") + set(CMAKE_HIP_FLAGS_RELWITHDEBINFO "-g" CACHE STRING "") elseif(ascent STREQUAL option) set(CMAKE_C_FLAGS "-mcpu=power9" CACHE STRING "") @@ -150,6 +155,9 @@ foreach(option IN LISTS options) else() message(FATAL_ERROR "CCACHE version [${CCACHE_VERSION}] is <= 4") endif() + + elseif(perftest STREQUAL option) + set(VTKm_ENABLE_PERFORMANCE_TESTING "ON" CACHE STRING "") endif() endforeach() diff --git a/.gitlab/ci/ctest_submit_build.cmake b/.gitlab/ci/ctest_submit_build.cmake new file mode 100644 index 000000000..5b66d6a9d --- /dev/null +++ b/.gitlab/ci/ctest_submit_build.cmake @@ -0,0 +1,23 @@ +##============================================================================= +## +## 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. +## +##============================================================================= + +# We need this CMake versions for tests +cmake_minimum_required(VERSION 3.18) + +# Read the files from the build directory that contain +# host information ( name, parallel level, etc ) +include("$ENV{CI_PROJECT_DIR}/build/CIState.cmake") +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +ctest_start(APPEND) +ctest_submit(PARTS Build BUILD_ID build_id) +message(STATUS "Build submission build_id: ${build_id}") diff --git a/.gitlab/ci/ctest_test_submit.cmake b/.gitlab/ci/ctest_submit_test.cmake similarity index 100% rename from .gitlab/ci/ctest_test_submit.cmake rename to .gitlab/ci/ctest_submit_test.cmake diff --git a/.gitlab/ci/ctest_test.cmake b/.gitlab/ci/ctest_test.cmake index b49f99554..956856254 100644 --- a/.gitlab/ci/ctest_test.cmake +++ b/.gitlab/ci/ctest_test.cmake @@ -11,7 +11,7 @@ ##============================================================================= # We need this CMake versions for tests -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.12..3.15 FATAL_ERROR) # Read the files from the build directory that contain # host information ( name, parallel level, etc ) @@ -29,30 +29,49 @@ set(test_exclusions string(REPLACE " " ";" test_exclusions "${test_exclusions}") string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) - set(test_exclusions "(${test_exclusions})") + set(test_exclusions EXCLUDE "(${test_exclusions})") endif () if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(junit_args OUTPUT_JUNIT "${CTEST_BINARY_DIRECTORY}/junit.xml") endif() +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + set(repeat_args REPEAT "UNTIL_PASS:${CTEST_REPEAT_UNTIL_PASS}") +endif() + set(PARALLEL_LEVEL "10") if (DEFINED ENV{CTEST_MAX_PARALLELISM}) set(PARALLEL_LEVEL $ENV{CTEST_MAX_PARALLELISM}) endif() +if (DEFINED ENV{TEST_INCLUSIONS}) + set(test_inclusions INCLUDE $ENV{TEST_INCLUSIONS}) + unset(test_exclusions) +endif() + + ctest_test(APPEND PARALLEL_LEVEL ${PARALLEL_LEVEL} RETURN_VALUE test_result - EXCLUDE "${test_exclusions}" - REPEAT "UNTIL_PASS:3" + ${test_exclusions} + ${test_inclusions} + ${repeat_args} ${junit_args} ) message(STATUS "ctest_test RETURN_VALUE: ${test_result}") +if(VTKm_ENABLE_PERFORMANCE_TESTING) + file(GLOB note_files + "${CTEST_BINARY_DIRECTORY}/benchmark_*.stdout" + "${CTEST_BINARY_DIRECTORY}/compare_*.stdout" + "${CTEST_BINARY_DIRECTORY}/$ENV{CI_COMMIT_SHA}_*.json") + list(APPEND CTEST_NOTES_FILES ${note_files}) +endif() + if(NOT DEFINED ENV{GITLAB_CI_EMULATION}) - ctest_submit(PARTS Test BUILD_ID build_id) - message(STATUS "Test submission build_id: ${build_id}") + ctest_submit(PARTS Test Notes) + message(STATUS "Test submission done") endif() if (test_result) diff --git a/.gitlab/ci/docker/ubuntu1804/cuda/Dockerfile b/.gitlab/ci/docker/ubuntu1804/cuda/Dockerfile new file mode 100644 index 000000000..a1eb81f13 --- /dev/null +++ b/.gitlab/ci/docker/ubuntu1804/cuda/Dockerfile @@ -0,0 +1,24 @@ +FROM nvidia/cuda:11.7.1-devel-ubuntu18.04 +LABEL maintainer "Vicente Adolfo Bolea Sanchez " + +# Base dependencies for building VTK-m projects +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang-8 \ + curl \ + g++-8 \ + git \ + libmpich-dev \ + libomp-dev \ + libtbb-dev \ + mpich \ + ninja-build \ + python3 \ + python3-scipy \ + && \ + rm -rf /var/lib/apt/lists/* + +# Install Git LFS from official tarball, repo version is too old +RUN curl -OL https://github.com/git-lfs/git-lfs/releases/download/v3.2.0/git-lfs-linux-amd64-v3.2.0.tar.gz && \ + tar -xvzf git-lfs-linux-amd64-v3.2.0.tar.gz && \ + ./git-lfs-3.2.0/install.sh && \ + rm -rf ./git-lfs-3.2.0 diff --git a/.gitlab/ci/docker/ubuntu1804/cuda11.1/Dockerfile b/.gitlab/ci/docker/ubuntu1804/cuda11.1/Dockerfile deleted file mode 100644 index ef7b91123..000000000 --- a/.gitlab/ci/docker/ubuntu1804/cuda11.1/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -FROM nvidia/cuda:11.6.1-devel-ubuntu18.04 -LABEL maintainer "Robert Maynard" - -# Base dependencies for building VTK-m projects -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - g++-8 \ - clang-8 \ - git \ - git-lfs \ - libmpich-dev \ - libomp-dev \ - libtbb-dev \ - mpich \ - ninja-build \ - && \ - rm -rf /var/lib/apt/lists/* - -# Need to run git-lfs install manually on ubuntu based images when using the -# system packaged version -RUN git-lfs install - -# Provide a consistent CMake path across all images -# Allow tests that require CMake to work correctly -RUN mkdir /opt/cmake && \ - curl -L https://github.com/Kitware/CMake/releases/download/v3.16.7/cmake-3.16.7-Linux-x86_64.sh > cmake-3.16.7-Linux-x86_64.sh && \ - sh cmake-3.16.7-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license && \ - rm cmake-3.16.7-Linux-x86_64.sh - -# Provide CMake 3.17 so we can re-run tests easily -# This will be used when we run just the tests -RUN mkdir /opt/cmake-latest/ && \ - curl -L https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-x86_64.sh > cmake-3.17.3-Linux-x86_64.sh && \ - sh cmake-3.17.3-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \ - rm cmake-3.17.3-Linux-x86_64.sh && \ - ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest - -ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}" diff --git a/.gitlab/ci/docker/ubuntu2004/base/Dockerfile b/.gitlab/ci/docker/ubuntu2004/base/Dockerfile index 989c7a421..9f88be281 100644 --- a/.gitlab/ci/docker/ubuntu2004/base/Dockerfile +++ b/.gitlab/ci/docker/ubuntu2004/base/Dockerfile @@ -4,7 +4,7 @@ LABEL maintainer "Vicente Adolfo Bolea Sanchez" ENV TZ=America/New_York # Base dependencies for building VTK-m projects -RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ +RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y --no-install-recommends \ cmake \ curl \ g++ \ @@ -16,7 +16,10 @@ RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-i libhdf5-dev \ mpich \ ninja-build \ - software-properties-common + python \ + python3-scipy \ + software-properties-common && \ + apt clean # Need to run git-lfs install manually on ubuntu based images when using the # system packaged version diff --git a/.gitlab/ci/macos.yml b/.gitlab/ci/macos.yml index 6badbab88..5bd8c62ec 100644 --- a/.gitlab/ci/macos.yml +++ b/.gitlab/ci/macos.yml @@ -39,6 +39,7 @@ test:macos_xcode13: CCACHE_COMPILERCHECK: "content" CCACHE_NOHASHDIR: "true" CCACHE_RESHARE: "true" + CCACHE_INSTALL_DIR: "$CI_PROJECT_DIR/.gitlab" before_script: - .gitlab/ci/config/cmake.sh - export PATH=$PWD/.gitlab/cmake/bin:$PATH diff --git a/.gitlab/ci/rhel8.yml b/.gitlab/ci/rhel8.yml index 75c795acb..c17398b9c 100644 --- a/.gitlab/ci/rhel8.yml +++ b/.gitlab/ci/rhel8.yml @@ -13,7 +13,7 @@ build:rhel8: - .run_automatically variables: CMAKE_GENERATOR: "Unix Makefiles" - VTKM_SETTINGS: "serial+shared+64bit_floats+32bit_ids+use_virtuals" + VTKM_SETTINGS: "serial+shared+64bit_floats+32bit_ids" test:rhel8: tags: diff --git a/.gitlab/ci/spock.yml b/.gitlab/ci/spock.yml new file mode 100644 index 000000000..25fefe211 --- /dev/null +++ b/.gitlab/ci/spock.yml @@ -0,0 +1,111 @@ +# Ad-hoc build that runs in the ECP Hardware, concretely in OLCF Spock. +.spock_gcc_hip: + variables: + CCACHE_BASEDIR: "/gpfs/alpine/world-shared/csc331/" + CCACHE_DIR: "/gpfs/alpine/world-shared/csc331/vtk-m/ci/ccache" + CUSTOM_CI_BUILDS_DIR: "/gpfs/alpine/world-shared/csc331/vtk-m/ci/runtime" + + # -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it + CCACHE_IGNOREOPTIONS: "-isystem=*" + CCACHE_NOHASHDIR: "true" + CCACHE_INSTALL_DIR: "$CI_PROJECT_DIR/build" + + CMAKE_BUILD_TYPE: "RelWithDebInfo" + CMAKE_GENERATOR: "Ninja" + + # This is needed for the smoke_test, while we use rocm 5 to build VTK-m the + # smoke_test needs 4.5 since Kokkos is built agains rocm 4.5 + LD_LIBRARY_PATH: "/opt/rocm-4.5.0/lib:${LD_LIBRARY_PATH}" + LIBRARY_PATH: "/opt/rocm-4.5.0/lib:${LIBRARY_PATH}" + + # While Kokkos and VTK-m uses ROCm 4.5.0 runtime/sdk, we need to build + # VTK-m with HIPCC from ROCM 5 + CMAKE_HIP_COMPILER: "/opt/rocm-default/llvm/bin/clang++" + Kokkos_CXX_COMPILER: "/opt/rocm-default/llvm/bin/clang++" + CMAKE_HIP_ARCHITECTURES: "gfx908" + + CC: gcc + CXX: g++ + # DefApps/default;craype;rocm;gcc should be loaded first + JOB_MODULES: >- + DefApps/default + craype-accel-amd-gfx90a + rocm/5 + gcc/10 + cmake/3.22 + git + git-lfs + kokkos/3.5.00 + lsf-tools + ninja + spectrum-mpi + zstd + VTKM_SETTINGS: kokkos+hip+spock+ccache+no_rendering + interruptible: true + +.setup_env_ecpci: &setup_env_ecpci | + module purge + module load ${JOB_MODULES} + module list + export PATH="${CCACHE_INSTALL_DIR}/ccache:$PATH" + +build:spock_gcc_hip: + stage: build + tags: [spock, shell] + extends: + - .spock_gcc_hip + - .run_spock_ci + before_script: + - *setup_env_ecpci + - mkdir -p "$CCACHE_INSTALL_DIR" + - cmake --version + - cmake -VV -P .gitlab/ci/config/ccache.cmake + - ccache -z + - ccache -s + + - git remote add lfs https://gitlab.kitware.com/vtk/vtk-m.git + - git fetch lfs + - git-lfs install + - git-lfs pull lfs + script: + - cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake + - ctest -VV -S .gitlab/ci/ctest_configure.cmake + artifacts: + expire_in: 24 hours + when: always + paths: + - build/ + - .gitlab/ccache/ccache + +test:spock_gcc_hip: + stage: test + tags: [spock, slurm] + extends: + - .spock_gcc_hip + - .run_spock_ci + needs: + - build:spock_gcc_hip + dependencies: + - build:spock_gcc_hip + variables: + SCHEDULER_PARAMETERS: "-ACSC331 -pecp -t120 --nice=0 -c32 --gpus=4 -N 1" + # We need this to skip ctest_submit from being run inside a jsrun job + GITLAB_CI_EMULATION: 1 + # Tests errors to address due to different env in Spock + # Refer to issue: https://gitlab.kitware.com/vtk/vtk-m/-/issues/743 + CTEST_EXCLUSIONS: >- + UnitTestMIRFilter + UnitTestDistributedBranchDecompositionFilter + UnitTestWorkletParticleAdvection + UnitTestLagrangianFilter + before_script: + - *setup_env_ecpci + script: + - CTEST_MAX_PARALLELISM=32 ctest -VV -S .gitlab/ci/ctest_build.cmake + - CTEST_MAX_PARALLELISM=4 ctest -VV -S .gitlab/ci/ctest_test.cmake + after_script: + - *setup_env_ecpci + - ccache -s + - ctest -VV -S .gitlab/ci/ctest_submit_build.cmake + - ctest -VV -S .gitlab/ci/ctest_submit_test.cmake + timeout: 150 minutes diff --git a/.gitlab/ci/ubuntu1604.yml b/.gitlab/ci/ubuntu1604.yml index bacc2e628..2f5ff5a3a 100644 --- a/.gitlab/ci/ubuntu1604.yml +++ b/.gitlab/ci/ubuntu1604.yml @@ -7,7 +7,6 @@ build:ubuntu1604_gcc5: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .ubuntu1604_cuda @@ -32,6 +31,7 @@ test:ubuntu1604_gcc5: - .ubuntu1604_cuda - .cmake_test_linux - .run_automatically + - .use_minimum_supported_cmake dependencies: - build:ubuntu1604_gcc5 needs: @@ -45,7 +45,6 @@ build:ubuntu1604_gcc5_2: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .ubuntu1604_cuda @@ -70,6 +69,7 @@ test:ubuntu1804_test_ubuntu1604_gcc5_2: - .ubuntu1804_cuda - .cmake_test_linux - .run_upstream_branches + - .use_minimum_supported_cmake variables: CTEST_EXCLUSIONS: "built_against_test_install" dependencies: @@ -106,6 +106,7 @@ test:ubuntu1604_clang5: - .ubuntu1604 - .cmake_test_linux - .run_automatically + - .use_minimum_supported_cmake dependencies: - build:ubuntu1604_clang5 needs: diff --git a/.gitlab/ci/ubuntu1804.yml b/.gitlab/ci/ubuntu1804.yml index 3a1336639..ef9f14e01 100644 --- a/.gitlab/ci/ubuntu1804.yml +++ b/.gitlab/ci/ubuntu1804.yml @@ -46,7 +46,6 @@ build:ubuntu1804_gcc7: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .ubuntu1804_cuda @@ -85,7 +84,6 @@ build:ubuntu1804_clang_cuda: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .ubuntu1804_cuda @@ -193,7 +191,6 @@ build:ubuntu1804_kokkos: - vtkm - docker - linux - - cuda-rt - large-memory extends: - .ubuntu1804_cuda_kokkos @@ -220,3 +217,39 @@ test:ubuntu1804_kokkos: - build:ubuntu1804_kokkos needs: - build:ubuntu1804_kokkos + +build:ubuntu1804_cuda_perftest: + tags: + - build + - vtkm + - docker + - linux + extends: + - .ubuntu1804_cuda + - .cmake_build_linux + - .run_automatically + variables: + CMAKE_BUILD_TYPE: Release + VTKM_SETTINGS: "benchmarks+ampere+perftest+cuda+mpi+shared" + +test:ubuntu1804_cuda_perftest: + tags: + - benchmark + - vtkm + - docker + - cuda-rt + - linux + extends: + - .ubuntu1804_cuda + - .cmake_test_linux + - .run_automatically + dependencies: + - build:ubuntu1804_cuda_perftest + needs: + - build:ubuntu1804_cuda_perftest + variables: + TEST_INCLUSIONS: "PerformanceTest" + VTKm_PERF_REMOTE_URL: "https://vbolea:$VTKM_BENCH_RECORDS_TOKEN@gitlab.kitware.com/vbolea/vtk-m-benchmark-records.git" + VTKm_PERF_ALPHA: "0.05" + VTKm_PERF_REPETITIONS: "10" + VTKm_PERF_DIST: "t" diff --git a/.gitlab/ci/ubuntu2004.yml b/.gitlab/ci/ubuntu2004.yml index c54497629..ca104cab2 100644 --- a/.gitlab/ci/ubuntu2004.yml +++ b/.gitlab/ci/ubuntu2004.yml @@ -10,7 +10,7 @@ build:ubuntu2004_gcc9: - .run_automatically variables: CMAKE_BUILD_TYPE: Debug - VTKM_SETTINGS: "benchmarks+tbb+openmp+mpi+shared+hdf5" + VTKM_SETTINGS: "benchmarks+tbb+openmp+mpi+shared+hdf5+min_build" test:ubuntu2004_gcc9: tags: @@ -69,23 +69,26 @@ build:ubuntu2004_hip_kokkos: extends: - .ubuntu2004_hip_kokkos - .cmake_build_linux - - .run_upstream_branches + - .run_automatically variables: - CMAKE_BUILD_TYPE: RelWithDebInfo - VTKM_SETTINGS: "benchmarks+kokkos+hip+no_virtual+no_rendering+ccache" - CMAKE_PREFIX_PATH: "/opt/rocm/lib/cmake" + CMAKE_BUILD_TYPE: "RelWithDebInfo" + VTKM_SETTINGS: "benchmarks+kokkos+hip+no_rendering+ccache" - CCACHE_BASEDIR: "$CI_PROJECT_DIR" + CMAKE_PREFIX_PATH: "/opt/rocm/lib/cmake" + LD_LIBRARY_PATH: "/opt/rocm/lib" + CMAKE_HIP_COMPILER: "/opt/rocm/llvm/bin/clang++" + Kokkos_CXX_COMPILER: "/opt/rocm/llvm/bin/clang++" + CMAKE_HIP_ARCHITECTURES: "gfx900" # -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it - CCACHE_IGNOREOPTIONS: "-isystem=*" - CCACHE_COMPILERCHECK: "content" - CCACHE_NOHASHDIR: "true" - CCACHE_RESHARE: "true" + CCACHE_IGNOREOPTIONS: "-isystem=*" + CCACHE_BASEDIR: "$CI_PROJECT_DIR" + CCACHE_COMPILERCHECK: "content" + CCACHE_NOHASHDIR: "true" + CCACHE_RESHARE: "true" after_script: - ccache -v -s - ccache -z - timeout: 10 hours test:ubuntu2004_hip_kokkos: tags: @@ -98,9 +101,33 @@ test:ubuntu2004_hip_kokkos: - .cmake_test_linux - .run_upstream_branches variables: - CTEST_TIMEOUT: "30" + CTEST_MAX_PARALLELISM: 1 dependencies: - build:ubuntu2004_hip_kokkos needs: - build:ubuntu2004_hip_kokkos timeout: 3 hours + +# This is only for merge-requests +build:ascent: + stage: build + variables: + BRANCH_NAME: "mr${CI_MERGE_REQUEST_IID}-${CI_COMMIT_REF_NAME}" + ASCENT_REST_URL: "https://code.ornl.gov/api/v4/projects/7035" + ASCENT_GIT_URL: "https://vbolea:${ECPTEST_TOKEN}@code.ornl.gov/ecpcitest/vtk-m.git" + tags: + - vtkm + - docker + extends: + - .ubuntu2004 + - .run_only_merge_requests + script: + # A new commit is needed to symbolize a restart of a build from the same original commit + - .gitlab/ci/config/ecpci-amend-commit.sh "NEW_COMMIT_SHA" + - .gitlab/ci/config/ecpci-push-branch.sh "$ASCENT_GIT_URL" "$BRANCH_NAME" + - timeout 130m .gitlab/ci/config/ecpci-wait-commit-status.sh "$ASCENT_REST_URL" "$(cat NEW_COMMIT_SHA)" + after_script: + - .gitlab/ci/config/ecpci-remove-branch.sh "$ASCENT_GIT_URL" "$BRANCH_NAME" || true + - .gitlab/ci/config/ecpci-fetch-commit-trace.py "$ASCENT_REST_URL" "$(cat NEW_COMMIT_SHA)" "$ECPTEST_TOKEN" + timeout: 150 minutes + interruptible: true diff --git a/.gitlab/ci/windows10.yml b/.gitlab/ci/windows10.yml index 7d8b278a7..f33cbb509 100644 --- a/.gitlab/ci/windows10.yml +++ b/.gitlab/ci/windows10.yml @@ -5,7 +5,8 @@ # change between the build and test stages which CMake doesn't support. # Even if we could, it could change if other runners on the machine # could run at the same time, so we drop it. - GIT_CLONE_PATH: "$CI_BUILDS_DIR\\vtkm ci" + GIT_CLONE_PATH: "$CI_BUILDS_DIR\\vtkm ci" + CCACHE_INSTALL_DIR: "$CI_PROJECT_DIR\\.gitlab" artifacts: reports: junit: @@ -32,13 +33,17 @@ - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\cmake\bin;$env:PATH" - "cmake --version" - "cmake -V -P .gitlab/ci/config/ccache.cmake" - - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\ccache;$env:PATH" + - Set-Item -Force -Path "env:PATH" -Value "$env:CCACHE_INSTALL_DIR\ccache;$env:PATH" - "cmake -V -P .gitlab/ci/config/ninja.cmake" - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" - "cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake" - "ctest -VV -S .gitlab/ci/ctest_configure.cmake" script: - "ctest -VV -S .gitlab/ci/ctest_build.cmake" + after_script: + # This is needed since sometimes this process hangs holding files + # in the build directory. Blocking new builds + - "tskill cvtres" artifacts: expire_in: 24 hours when: always diff --git a/.gitlab/issue_templates/NewRelease.md b/.gitlab/issue_templates/NewRelease.md deleted file mode 100644 index d5552a62c..000000000 --- a/.gitlab/issue_templates/NewRelease.md +++ /dev/null @@ -1,248 +0,0 @@ - -## Update VTK-m - - - [ ] Update `release` branch for **vtk-m** and create update branch -``` -git fetch origin -git checkout release -git merge --ff-only origin/release -git submodule update --recursive --init -``` -## Create update branch - - - [ ] Create update branch `git checkout -b update-to-v@VERSION@` - - - [ ] Bring as a second parent the history of master (Solve conflicts always - taking master's version) -``` - git merge --no-ff origin/master -``` - - - - - [ ] Update the major and minor version in `version.txt`: -``` -echo "@MAJOR@.@MINOR@.9999" > version.txt -git add version.txt` -``` - - - - [ ] Update the version (not in patch releases) and date in the LICENSE.md - file `git add LICENSE.md`. - - [ ] Create commit that updates the License (and version.txt if modified): -``` -git commit -m 'release: update version and License' -``` - - - - [ ] Craft or update [changelog](#generate-change-log) - `docs/changelog/@VERSION@/release-notes.md` file. - - [ ] Create release notes commit. -``` -git add docs/changelog/@VERSION@/release-notes.md -git rm docs/changelog/*.md -git commit -m 'release: @VERSION@@RC@ release notes' -``` - - - [ ] Create update version commit: - -``` -echo @VERSION@@RC@ > version.txt -git add version.txt - -# Create commit with the following template -# Nth is counted by the number of final release tags -git commit -m '@VERSION@@RC@ is our Nth official release of VTK-m. - -The major changes to VTK-m from (previous release) can be found in: - docs/changelog/@VERSION@/release-notes.md' version.txt -``` - - - [ ] `git tag -a -m 'VTKm @VERSION@@RC@' v@VERSION@@RC@ HEAD` - - Integrate changes to `release` branch - - [ ] Create a MR using the [release-mr script][1] - (see [notes](#notes-about-update-mr)). - - - [ ] Add (or ensure) at the bottom of the description of the merge request: - `Backport: master:HEAD~1` - - - [ ] Remove (or ensure) that at the bottom of the description of the merge - request there is no `Backport` instruction. - - - [ ] Get +1 - - [ ] `Do: merge` - - Push tags - - [ ] `git push origin v@VERSION@@RC@` - -## Update Spack - - [ ] Update Spack package: https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/vtk-m/package.py - -## Post-release - - [ ] Copy the contents of docs/changelog/@VERSION@/release-notes.md to - the GitLab release. - - - [ ] Tag new version of the [VTK-m User Guide][2]. - - - [ ] Post an [Email Announcements](#email-announcements) VTK-m mailing list. - - - [ ] Ensure that the content of `version.txt` in master is - `[@MAJOR@ @MINOR@](@MAJOR@.@MINOR@.9999)`. - - ---- - -# Annex - -## Generate change log -Construct a `docs/changelog/@VERSION@/` folder. -Construct a `docs/changelog/@VERSION@/release-notes.md` file - -Use the following template for `release-notes.md`: - -```md -VTK-m N Release Notes -======================= - - - -| Merge request description | Merge request id | -| ------------------------------------------------------------------- | ---------------- | -| Update the link to register with the VTK-m dashboard | !2629 | -. -. -. -| CMAKE: CUDA ampere generate sm_80/86 | !2688 | - - - -# Table of Contents -1. [Core](#Core) - - Core change 1 -2. [ArrayHandle](#ArrayHandle) -3. [Control Environment](#Control-Environment) -4. [Execution Environment](#Execution-Environment) -5. [Worklets and Filters](#Worklets-and-Filters) -6. [Build](#Build) -7. [Other](#Other) - - -# Core - -## Core change 1 ## - -changes in core 1 - -# ArrayHandle - -# Control Enviornment - -# Execution Environment - -# Execution Environment - -# Worklets and Filters - -# Build - - -# Other -``` - -For each individual file in `docs/changelog` move them -to the relevant `release-notes` section. - - - Make sure each title and entry in the table of contents use full vtkm names - `vtkm::cont::Field` instead of Field. - - Make sure each title and entry DOESN'T have a period at the end. - - Make sure any sub-heading as part of the changelog is transformed from `##` - to `###`. - - Entries for `Core` are reserved for large changes that significantly improve - VTK-m users life, or are major breaking changes. - -## Notes about update-mr - -[`update-mr` script][1] has the following requirements to work: - -1. It needs a token to for authentication (reach @ben.boeckel for this) -2. It needs `kwrobot.release.vtkm` to have developer perms in your vtk-m repo. - -Lastly, `update-mr` can be used multiple times with different commit in the same -branch. - -## Notes about version.txt - -Master and release branch do not share the same version.txt scheme. In the -release branch the patch and release-candidate version is observed whereas in -master the patch field is fixed to _9999_ indicating that each of its commit is -a developing release. - -- Master: `@MAJOR@.@MINOR@.9999` -- Release: `@MAJOR@.@MINOR@.@PATCH@@RC@` - -## Email Announcements - -Announce the new VTK-m release on the mailing list. You will need to compute -the number of merge requests, changelog entries, and maybe # of authors. - -Example to compute the number of unique committers -``` -git log --format="%an" v1.4.0..v1.5.0 | sort -u | wc -l -``` - -Example to compute the number of merge requests -``` -git log v1.4.0..v1.5.0 | grep 'Merge | wc -l -``` - -A standard template to use is: - - -``` -Hi All, - -VTK-m 1.5.0 is now released, and a special thanks to everyone that has -contributed to VTK-m since our last release. The 1.5.0 release contains -over 100000 merge requests, and 100000 entries to the changelog . - -Below are all the entries in the changelog, with more details at ( -https://gitlab.kitware.com/vtk/vtk-m/-/tags/v@VERSION@) or in the vtkm -repository at `docs/@VERSION@/release-notes.md` - - - -- Update the link to register with the VTK-m dashboard -. -. -. -- CMAKE: CUDA ampere generate sm_80/86 - - -1. Core - - Core change 1 -2. ArrayHandle -3. Control Environment -4. Execution Environment -5. Worklets and Filters -6. Build -7. Other - -``` - -/cc @ben.boeckel - -/cc @vbolea - -/label ~"priority:required" - -[1]: https://gitlab.kitware.com/utils/release-utils/-/blob/master/release-mr.py -[2]: https://gitlab.kitware.com/vtk/vtk-m-user-guide diff --git a/CMake/VTKmCPUVectorization.cmake b/CMake/VTKmCPUVectorization.cmake index 87628f7f0..a80484451 100644 --- a/CMake/VTKmCPUVectorization.cmake +++ b/CMake/VTKmCPUVectorization.cmake @@ -62,6 +62,12 @@ if(TARGET vtkm_vectorization_flags) endif() add_library(vtkm_vectorization_flags INTERFACE) +set_target_properties( + vtkm_vectorization_flags + PROPERTIES + EXPORT_NAME vectorization_flags + ) + if(NOT VTKm_INSTALL_ONLY_LIBRARIES) install(TARGETS vtkm_vectorization_flags EXPORT ${VTKm_EXPORT_NAME}) endif() @@ -193,7 +199,7 @@ target_compile_options(vtkm_vectorization_flags INTERFACE $<$:${flags}> ) -if(TARGET vtkm::cuda AND flags AND NOT CMAKE_CUDA_HOST_COMPILER) +if(TARGET vtkm_cuda AND flags AND NOT CMAKE_CUDA_HOST_COMPILER) # Also propagate down these optimizations when building host side code # with cuda. To be safe we only do this when we know the C++ and CUDA # host compiler are from the same vendor diff --git a/CMake/VTKmCompilerFlags.cmake b/CMake/VTKmCompilerFlags.cmake index a145f4cb9..d37ba3a69 100644 --- a/CMake/VTKmCompilerFlags.cmake +++ b/CMake/VTKmCompilerFlags.cmake @@ -30,6 +30,11 @@ endif() # vtkm_compiler_flags is used by all the vtkm targets and consumers of VTK-m # The flags on vtkm_compiler_flags are needed when using/building vtk-m add_library(vtkm_compiler_flags INTERFACE) +set_target_properties( + vtkm_compiler_flags + PROPERTIES + EXPORT_NAME compiler_flags + ) # When building libraries/tests that are part of the VTK-m repository # inherit the properties from vtkm_vectorization_flags. @@ -50,12 +55,12 @@ target_compile_features(vtkm_compiler_flags INTERFACE cxx_std_14) # they don't use. if(VTKM_COMPILER_IS_MSVC) target_compile_options(vtkm_compiler_flags INTERFACE $<$:/Gy>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler="/Gy">) endif() elseif(NOT (VTKM_COMPILER_IS_PGI OR VTKM_COMPILER_IS_XL)) #can't find an equivalant PGI/XL flag target_compile_options(vtkm_compiler_flags INTERFACE $<$:-ffunction-sections>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler=-ffunction-sections>) endif() endif() @@ -63,7 +68,7 @@ endif() # Enable large object support so we can have 2^32 addressable sections if(VTKM_COMPILER_IS_MSVC) target_compile_options(vtkm_compiler_flags INTERFACE $<$:/bigobj>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler="/bigobj">) endif() endif() @@ -79,6 +84,11 @@ target_include_directories(vtkm_compiler_flags INTERFACE # vtkm_developer_flags is used ONLY BY libraries that are built as part of this # repository add_library(vtkm_developer_flags INTERFACE) +set_target_properties( + vtkm_developer_flags + PROPERTIES + EXPORT_NAME developer_flags + ) # Additional warnings just for Clang 3.5+, and AppleClang 7+ # about failures to vectorize. @@ -101,7 +111,7 @@ if(VTKM_COMPILER_IS_MSVC) #Setup MSVC warnings with CUDA and CXX target_compile_options(vtkm_developer_flags INTERFACE $<$:${cxx_flags}>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:${cuda_flags} -Xcudafe=--diag_suppress=1394,--diag_suppress=766>) endif() @@ -109,7 +119,7 @@ if(VTKM_COMPILER_IS_MSVC) # In VS2013 the C4127 warning has a bug in the implementation and # generates false positive warnings for lots of template code target_compile_options(vtkm_developer_flags INTERFACE $<$:-wd4127>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:-Xcompiler=-wd4127>) endif() endif() @@ -165,7 +175,7 @@ elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG) endif() target_compile_options(vtkm_developer_flags INTERFACE $<$:${cxx_flags}>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:${cuda_flags}>) endif() endif() @@ -176,10 +186,10 @@ function(setup_cuda_flags) endfunction() #common warnings for all platforms when building cuda -if ((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda)) +if ((TARGET vtkm_cuda) OR (TARGET vtkm::kokkos_cuda)) setup_cuda_flags() endif() if(NOT VTKm_INSTALL_ONLY_LIBRARIES) - install(TARGETS vtkm_compiler_flags vtkm_developer_flags EXPORT ${VTKm_EXPORT_NAME}) + vtkm_install_targets(TARGETS vtkm_compiler_flags vtkm_developer_flags) endif() diff --git a/CMake/VTKmConfig.cmake.in b/CMake/VTKmConfig.cmake.in index a5e07626d..8c29b3eb6 100644 --- a/CMake/VTKmConfig.cmake.in +++ b/CMake/VTKmConfig.cmake.in @@ -10,22 +10,22 @@ # When this file is run by CMake through the find_package command, the # following targets will exist: -# vtkm_cont Target that contains most of VTK-m +# vtkm::cont Target that contains most of VTK-m # -# vtkm_rendering Target that contains all the rendering code +# vtkm::rendering Target that contains all the rendering code # -# vtkm_filter Target that contains all of VTK-m pre-built filters +# vtkm::filter Target that contains all of VTK-m pre-built filters # -# vtkm_source Target that contains all of VTK-m pre-built sources +# vtkm::source Target that contains all of VTK-m pre-built sources # -# vtkm::tbb Target that contains tbb related link information -# implicitly linked to by `vtkm_cont` if tbb is enabled +# vtkm::tbb Target that contains tbb related link information +# implicitly linked to by `vtkm_cont` if tbb is enabled # -# vtkm::openmp Target that contains openmp related link information -# implicitly linked to by `vtkm_cont` if openmp is enabled +# vtkm::openmp Target that contains openmp related link information +# implicitly linked to by `vtkm_cont` if openmp is enabled # -# vtkm::cuda Target that contains cuda related link information -# implicitly linked to by `vtkm_cont` if cuda is enabled +# vtkm::cuda Target that contains cuda related link information +# implicitly linked to by `vtkm_cont` if cuda is enabled # # The following local variables will also be defined: # @@ -47,7 +47,6 @@ # VTKm_ENABLE_OSMESA_CONTEXT Will be enabled if VTK-m rendering was built with a osmesa context # VTKm_ENABLE_EGL_CONTEXT Will be enabled if VTK-m rendering was built with a EGL context # -# if (CMAKE_VERSION VERSION_LESS "3.12") message(FATAL_ERROR "VTK-m requires CMake 3.12+") @@ -109,18 +108,27 @@ set(VTKM_FROM_INSTALL_DIR FALSE) if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "@VTKm_BINARY_DIR@") set(VTKM_FROM_INSTALL_DIR TRUE) include(${VTKm_CONFIG_DIR}/VTKmTargets.cmake) + + if(DEFINED PACKAGE_FIND_VERSION AND PACKAGE_FIND_VERSION VERSION_LESS 2.0) + add_library(vtkm_cont ALIAS vtkm::cont) + add_library(vtkm_filter ALIAS vtkm::filter) + add_library(vtkm_io ALIAS vtkm::io) + add_library(vtkm_rendering ALIAS vtkm::rendering) + add_library(vtkm_source ALIAS vtkm::source) + add_library(vtkm_worklet ALIAS vtkm::worklet) + endif() endif() # Once we can require CMake 3.15 for all cuda builds we can # replace this with setting `cuda_architecture_flags` as part of the -# EXPORT_PROPERTIES of the vtkm_cuda target +# EXPORT_PROPERTIES of the vtkm::cuda target if(VTKm_ENABLE_CUDA AND VTKM_FROM_INSTALL_DIR) + # Canonical way of setting CUDA arch + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) + set_target_properties(vtkm::cuda PROPERTIES CUDA_ARCHITECTURES "@CMAKE_CUDA_ARCHITECTURES@") + endif() set_target_properties(vtkm::cuda PROPERTIES - - # Canonical way of setting CUDA arch - CUDA_ARCHITECTURES "@CMAKE_CUDA_ARCHITECTURES@" - # Legacy way of setting CUDA arch cuda_architecture_flags "@VTKm_CUDA_Architecture_Flags@" requires_static_builds TRUE) diff --git a/CMake/VTKmDIYUtils.cmake b/CMake/VTKmDIYUtils.cmake index 1594ba1fe..d88082397 100644 --- a/CMake/VTKmDIYUtils.cmake +++ b/CMake/VTKmDIYUtils.cmake @@ -8,6 +8,14 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ +macro(vtkm_diy_get_general_target target) + if(CMAKE_PROJECT_NAME STREQUAL "VTKm") + set(${target} "vtkm_diy") + else() + set(${target} "vtkm::diy") + endif() +endmacro() + macro(_vtkm_diy_target flag target) set(${target} "vtkmdiympi") if (NOT ${flag}) @@ -19,7 +27,8 @@ function(vtkm_diy_init_target) set(vtkm_diy_default_flag "${VTKm_ENABLE_MPI}") _vtkm_diy_target(vtkm_diy_default_flag vtkm_diy_default_target) - set_target_properties(vtkm_diy PROPERTIES + vtkm_diy_get_general_target(diy_target) + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack ${vtkm_diy_default_flag} vtkm_diy_target ${vtkm_diy_default_target}) endfunction() @@ -30,30 +39,33 @@ function(vtkm_diy_use_mpi_push) if (NOT ARGC EQUAL 0) set(topval ${ARGV0}) endif() - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (APPEND stack ${topval}) _vtkm_diy_target(topval target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() function(vtkm_diy_use_mpi value) - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (REMOVE_AT stack -1) list (APPEND stack ${value}) _vtkm_diy_target(value target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() function(vtkm_diy_use_mpi_pop) - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (GET stack -1 value) list (REMOVE_AT stack -1) _vtkm_diy_target(value target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() diff --git a/CMake/VTKmDeviceAdapters.cmake b/CMake/VTKmDeviceAdapters.cmake index e9ac03967..e87f05357 100644 --- a/CMake/VTKmDeviceAdapters.cmake +++ b/CMake/VTKmDeviceAdapters.cmake @@ -41,38 +41,39 @@ function(vtkm_extract_real_library library real_library) endif() endfunction() -if(VTKm_ENABLE_TBB AND NOT TARGET vtkm::tbb) +if(VTKm_ENABLE_TBB AND NOT TARGET vtkm_tbb) # Skip find_package(TBB) if we already have it if (NOT TARGET TBB::tbb) find_package(TBB REQUIRED) endif() - add_library(vtkmTBB INTERFACE) - add_library(vtkm::tbb ALIAS vtkmTBB) - target_link_libraries(vtkmTBB INTERFACE TBB::tbb) - target_compile_definitions(vtkmTBB INTERFACE "TBB_VERSION_MAJOR=${TBB_VERSION_MAJOR}") - set_target_properties(vtkmTBB PROPERTIES EXPORT_NAME vtkm::tbb) - install(TARGETS vtkmTBB EXPORT ${VTKm_EXPORT_NAME}) + add_library(vtkm_tbb INTERFACE) + target_link_libraries(vtkm_tbb INTERFACE TBB::tbb) + target_compile_definitions(vtkm_tbb INTERFACE "TBB_VERSION_MAJOR=${TBB_VERSION_MAJOR}") + set_target_properties(vtkm_tbb PROPERTIES EXPORT_NAME tbb) + install(TARGETS vtkm_tbb EXPORT ${VTKm_EXPORT_NAME}) endif() -if(VTKm_ENABLE_OPENMP AND NOT TARGET vtkm::openmp) +if(VTKm_ENABLE_OPENMP AND NOT TARGET vtkm_openmp) find_package(OpenMP 4.0 REQUIRED COMPONENTS CXX QUIET) - add_library(vtkm::openmp INTERFACE IMPORTED GLOBAL) + add_library(vtkm_openmp INTERFACE) + set_target_properties(vtkm_openmp PROPERTIES EXPORT_NAME openmp) if(OpenMP_CXX_FLAGS) - set_property(TARGET vtkm::openmp + set_property(TARGET vtkm_openmp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${OpenMP_CXX_FLAGS}>) if(VTKm_ENABLE_CUDA) string(REPLACE ";" "," openmp_cuda_flags "-Xcompiler=${OpenMP_CXX_FLAGS}") - set_property(TARGET vtkm::openmp + set_property(TARGET vtkm_openmp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${openmp_cuda_flags}>) endif() endif() if(OpenMP_CXX_LIBRARIES) - set_target_properties(vtkm::openmp PROPERTIES + set_target_properties(vtkm_openmp PROPERTIES INTERFACE_LINK_LIBRARIES "${OpenMP_CXX_LIBRARIES}") endif() + install(TARGETS vtkm_openmp EXPORT ${VTKm_EXPORT_NAME}) endif() if(VTKm_ENABLE_CUDA) @@ -84,10 +85,9 @@ if(VTKm_ENABLE_CUDA) message(FATAL_ERROR "VTK-m CUDA support requires version 9.2+") endif() - if(NOT TARGET vtkm::cuda) + if(NOT TARGET vtkm_cuda) add_library(vtkm_cuda INTERFACE) - add_library(vtkm::cuda ALIAS vtkm_cuda) - set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda) + set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME cuda) install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME}) # Reserve `requires_static_builds` to potential work around issues @@ -323,6 +323,11 @@ if(VTKm_ENABLE_KOKKOS AND NOT TARGET vtkm::kokkos) cmake_minimum_required(VERSION 3.13 FATAL_ERROR) find_package(Kokkos REQUIRED) + + # We must empty this property for every kokkos backend device since it + # contains a generator expresion which breaks some of our users builds. + set_property(TARGET Kokkos::kokkoscore PROPERTY INTERFACE_COMPILE_DEFINITIONS "") + if (CUDA IN_LIST Kokkos_DEVICES) cmake_minimum_required(VERSION 3.18 FATAL_ERROR) enable_language(CUDA) @@ -344,7 +349,6 @@ if(VTKm_ENABLE_KOKKOS AND NOT TARGET vtkm::kokkos) cmake_minimum_required(VERSION 3.18 FATAL_ERROR) enable_language(HIP) add_library(vtkm::kokkos_hip INTERFACE IMPORTED GLOBAL) - set_property(TARGET Kokkos::kokkoscore PROPERTY INTERFACE_COMPILE_DEFINITIONS "") set_property(TARGET Kokkos::kokkoscore PROPERTY INTERFACE_COMPILE_OPTIONS "") set_property(TARGET Kokkos::kokkoscore PROPERTY INTERFACE_LINK_OPTIONS "") endif() diff --git a/CMake/VTKmModules.cmake b/CMake/VTKmModules.cmake new file mode 100644 index 000000000..6bf7cc69a --- /dev/null +++ b/CMake/VTKmModules.cmake @@ -0,0 +1,660 @@ +##============================================================================ +## 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. +##============================================================================ + +option(VTKm_VERBOSE_MODULES + "When on, extra information about what modules are found and why they are \ +built or not is added as CMake status messages." + OFF + ) + +mark_as_advanced(VTKm_VERBOSE_MODULES) + +# ----------------------------------------------------------------------------- + +#[==[ +Sets a property for a module of a particular name. The module property is +available globally and can be retrieved with `vtkm_module_get_property`. +#]==] +function(vtkm_module_set_property module_name property_name property_value) + set_property(GLOBAL PROPERTY + "_vtkm_module_${module_name}_${property_name}" "${property_value}") +endfunction() + +#[==[ +Gets a property for a value of a particular name. +#]==] +function(vtkm_module_get_property out_var module_name property_name) + get_property(_vtkm_module_property GLOBAL PROPERTY + "_vtkm_module_${module_name}_${property_name}") + set("${out_var}" "${_vtkm_module_property}" PARENT_SCOPE) +endfunction() + +#[==[ +Sets out_var to true if a module of the given name exists, false otherwise. +A module does not need to be built for this to return true. Only the +associated vtkm.module file needs to exist. +#]==] +function(vtkm_module_exists out_var module_name) + vtkm_module_get_property(_vtkm_module_exists_name ${module_name} NAME) + if(_vtkm_module_exists_name) + set("${out_var}" TRUE PARENT_SCOPE) + else() + set("${out_var}" FALSE PARENT_SCOPE) + endif() +endfunction() + +#[==[ +Sets out_var to a list of all modules that are being built. This list includes +all modules that are enabled and have an associated target. Any modules not being +built will not be listed. + +The modules are listed in an order such that any module will be listed _after_ +any modules that it depends on. +#]==] +function(vtkm_module_get_list out_var) + get_property(_vtkm_module_list GLOBAL PROPERTY "_vtkm_module_list") + set("${out_var}" "${_vtkm_module_list}" PARENT_SCOPE) +endfunction() + +#[==[ +Forces the enable value of a module group to be a particular value. This is +useful for converting a CMake `option` to a group of modules to turn on or +off. When a group of modules is forced with this function, a CMake cache +variable is not made, thus not allowing the user to change the value. +(Presumably, the value is changed via other, easier means.) + +```cmake +vtkm_module_force_group(group_name + [VALUE ] | [ENABLE_OPTION ] | [DISABLE_OPTION ] + [ENABLE_VALUE ] + [DISABLE_VALUE ] + [REASON ] + ) + +The first argument is always the name of the group to force. Exactly +one of VALUE, ENABLE_OPTION, or DISABLE_OPTION must be provided. + + * `VALUE`: The specific value to set the group enable/disable flag. + Must be `YES`, `NO`, `WANT`, `DONT_WANT`, `NO`, or `DEFAULT`. + * `ENABLE_OPTION`: The name of a CMake variable (usually a cache + variable) that sets the flag to `ENABLE_VALUE` if true or + `DISABLE_VALUE` if false. + * `DISABLE_OPTION`: The name of a CMake variable (usually a cache + variable) that sets the flag to `DISABLE_VALUE` if true or + `ENABLE_VALUE` if false. + * `ENABLE_VALUE`: Value used to turn on the group. Defaults to `YES`. + * `DISABLE_VALUE`: Value used to turn off the group. Defaults to `NO`. + * `REASON`: String given to inform users how the group enable/disable + flag got its value. +``` +#]==] +function(vtkm_module_force_group group_name) + cmake_parse_arguments(PARSE_ARGV 1 force + "" + "VALUE;ENABLE_OPTION;DISABLE_OPTION;ENABLE_VALUE;DISABLE_VALUE;REASON" + "") + if(force_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Bad arguments to vtkm_module_force_group") + endif() + if(NOT DEFINED force_ENABLE_VALUE) + set(force_ENABLE_VALUE "YES") + endif() + if(NOT DEFINED force_DISABLE_VALUE) + set(force_DISABLE_VALUE "NO") + endif() + + if(DEFINED force_VALUE) + if(NOT force_REASON) + set(force_REASON "Forced value") + endif() + elseif(force_ENABLE_OPTION) + if(${${force_ENABLE_OPTION}}) + set(force_VALUE ${force_ENABLE_VALUE}) + else() + set(force_VALUE ${force_DISABLE_VALUE}) + endif() + if(NOT force_REASON) + set(force_REASON "${force_ENABLE_OPTION} set to ${${force_ENABLE_OPTION}}") + endif() + elseif(force_DISABLE_OPTION) + if(NOT ${${force_DISABLE_OPTION}}) + set(force_VALUE ${force_ENABLE_VALUE}) + else() + set(force_VALUE ${force_DISABLE_VALUE}) + endif() + if(NOT force_REASON) + set(force_REASON "${force_DISABLE_OPTION} set to ${${force_DISABLE_OPTION}}") + endif() + else() + message(FATAL_ERROR + "vtkm_module_force_group must be given VALUE, ENABLE_OPTION, or DISABLE_OPTION") + endif() + + set(force_REASON "${force_REASON} (forcing VTKm_GROUP_ENABLE_${group_name} to ${force_VALUE})") + + set_property(GLOBAL PROPERTY + "_vtkm_module_group_enable_${group_name}_override" TRUE) + set_property(GLOBAL PROPERTY + "_vtkm_module_group_enable_${group_name}_value" "${force_VALUE}") + set_property(GLOBAL PROPERTY + "_vtkm_module_group_enable_${group_name}_reason" "${force_REASON}") +endfunction() + +#[==[ +Creates a CMake variable to enable/disable the module with the given name. +This cached variable can be set by the user to turn the module on or off. +If the cache variable already exists, then this call has no effect. +#]==] +function(vtkm_module_enable_module_variable module_name default_value) + set(VTKm_MODULE_ENABLE_${module_name} ${default_value} + CACHE STRING + "Enable the ${module_name} module. + YES - Always create the module (it is an error otherwise). + WANT - Create the module if possible. + DONT_WANT - Create the module only if there is a dependency that requires it. + NO - Never create the module. + DEFAULT - Do the default behavior." + ) + mark_as_advanced(VTKm_MODULE_ENABLE_${module_name}) + set_property(CACHE VTKm_MODULE_ENABLE_${module_name} + PROPERTY STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT" + ) +endfunction() + +#[==[ +Creates a CMake variable to enable/disable the modules with the given group name. +This cached variable can be set by the user to turn the module on or off. +This cache variable only has an effect on modules that belong to this group and +have their own ENABLE flag set to DEFAULT. +If the cache variable already exists, then this call has no effect. +#]==] +function(vtkm_module_enable_group_variable group_name default_value) + get_property(override_exists GLOBAL PROPERTY _vtkm_module_group_enable_${group_name}_override) + if(override_exists) + # There is a force of this group overriding any setting, in which case + # don't even give the option. + return() + endif() + set(VTKm_GROUP_ENABLE_${group_name} ${default_value} + CACHE STRING + "Enable the ${group_name} module group. + YES - Always create the group of modules (it is an error otherwise). + WANT - Create the group of modules if possible. + DONT_WANT - Create the module only if there is a dependency that requires it. + NO - Never create the module. + DEFAULT - Do the default behavior." + ) + mark_as_advanced(VTKm_GROUP_ENABLE_${group_name}) + set_property(CACHE VTKm_GROUP_ENABLE_${group_name} + PROPERTY STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT" + ) +endfunction() + +# ----------------------------------------------------------------------------- + +#[==[ +Parses the given `module_file`. The name of the module (extracted from the file) +is returned in `name_var`. + +For each module option expected in the module file, a module property with the +same name is created to hold that option. Additionally, a `DIRECTORY` property +is created to point to the source directory containing the module. The module +properties can be retrieved with the vtkm_module_get_property function. +#]==] +function(_vtkm_module_parse_module_file module_file name_var) + # Read the file + if(NOT IS_ABSOLUTE "${module_file}") + string(PREPEND module_file "${CMAKE_CURRENT_SOURCE_DIR}/") + endif() + file(READ ${module_file} module_file_contents) + # Remove comments + string(REGEX REPLACE "#[^\n]*\n" "\n" module_file_contents "${module_file_contents}") + # Separate arguments with `;` to treat it like a list. + string(REGEX REPLACE "( |\n)+" ";" module_file_contents "${module_file_contents}") + + # Parse module file as arguments to a function + set(options NO_TESTING) + set(oneValueArgs NAME) + set(multiValueArgs + GROUPS DEPENDS PRIVATE_DEPENDS OPTIONAL_DEPENDS TEST_DEPENDS TEST_OPTIONAL_DEPENDS) + cmake_parse_arguments(_vtkm_module + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${module_file_contents}) + + # Check required arguments + if(_vtkm_module_UNPARSED_ARGUMENTS) + message(FATAL_ERROR + "Module file ${module_file} contains unknown options: ${_vtkm_module_UNPARSED_ARGUMENTS}") + endif() + if(NOT _vtkm_module_NAME) + message(FATAL_ERROR "Module file ${module_file} does not specify a NAME option.") + endif() + set(NAME ${_vtkm_module_NAME}) + + # Stash the information in variables + foreach(module_var_name IN LISTS options oneValueArgs multiValueArgs) + vtkm_module_set_property(${NAME} ${module_var_name} "${_vtkm_module_${module_var_name}}") + endforeach() + get_filename_component(directory "${module_file}" DIRECTORY) + vtkm_module_set_property(${NAME} DIRECTORY "${directory}") + + # Add a build dependency that reruns CMake whenever the vtkm.module file changes. + set_property(DIRECTORY "${PROJECT_SOURCE_DIR}" + APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${module_file}") + + set(${name_var} ${NAME} PARENT_SCOPE) +endfunction() + +# ----------------------------------------------------------------------------- + +#[==[ +Scans the given directories recursively for `vtkm.module` files and put the +paths into the output variable. Note that the module files are assumed to +live next to the `CMakeLists.txt` file, which will build the module. +#]==] +function(_vtkm_modules_find output) + set(all_modules) + foreach(search_directory IN LISTS ARGN) + file(GLOB_RECURSE found_modules "${search_directory}/vtkm.module") + list(APPEND all_modules ${found_modules}) + endforeach() + set(${output} ${all_modules} PARENT_SCOPE) +endfunction() + +# ----------------------------------------------------------------------------- + +#[==[ +Scans for modules and builds the appropriate cached variables to optionally +build them. Modules are found by looking for files named `vtkm.module`. +This module file is assumed to live next to the `CMakeLists.txt` file that +can build the module. + +```cmake +vtkm_modules_scan( + SCAN_DIRECTORIES ... + PROVIDED_MODULES + ) + +The arguments are as follows: + + * `SCAN_DIRECTORIES`: (Required) A list of directories to (recursively) scan + for modules (indicated by a `vtkm.module` file). + * `PROVIDED_MODULES`: (Required) The name of a variable that will be set with + a list of modules that exist. + +All the directories in `SCAN_DIRECTORIES` are recursively searched for files +named `vtkm.module`. See docs/Modules.md for information on the format of +`vtkm.module` files. +#]==] +function(vtkm_modules_scan) + cmake_parse_arguments(PARSE_ARGV 0 _scan + "" + "PROVIDED_MODULES" + "SCAN_DIRECTORIES" + ) + if(_scan_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Invalid arguments given to vtkm_module_scan.") + endif() + if(NOT _scan_PROVIDED_MODULES) + message(FATAL_ERROR "vtkm_scan_modules must have a `PROVIDED_MODULES` argument.") + endif() + + _vtkm_modules_find(_scan_module_files ${_scan_SCAN_DIRECTORIES}) + if (NOT _scan_module_files) + message(FATAL_ERROR "No vtkm.module files found in '${_scan_SCAN_DIRECTORIES}'") + endif() + + set(_scan_module_names) + # Read all of the module files passed in. + foreach(module_file IN LISTS _scan_module_files) + _vtkm_module_parse_module_file(${module_file} name) + if(VTKm_VERBOSE_MODULES) + message(STATUS "Found module ${name} in ${module_file}") + endif() + + vtkm_module_enable_module_variable(${name} "DEFAULT") + + vtkm_module_get_property(module_groups ${name} GROUPS) + foreach(group_name IN LISTS module_groups) + vtkm_module_enable_group_variable(${group_name} "DEFAULT") + endforeach() + + list(APPEND _scan_module_names "${name}") + endforeach() + + set(${_scan_PROVIDED_MODULES} ${_scan_module_names} PARENT_SCOPE) +endfunction() + +# ----------------------------------------------------------------------------- + +function(_vtkm_module_check_enable_flag variable_name) + set(valid_flags YES WANT DONT_WANT NO DEFAULT) + if(NOT "${${variable_name}}" IN_LIST valid_flags) + message(FATAL_ERROR + "${variable_name} must be set to one of ${valid_flags}, not `${${variable_name}}`.") + endif() +endfunction() + +function(_vtkm_module_get_enable_flag module output) + set(reasons_output "${ARGV2}") + _vtkm_module_check_enable_flag(VTKm_MODULE_ENABLE_${module}) + + set(enable_flag ${VTKm_MODULE_ENABLE_${module}}) + if(reasons_output) + set(reasons "VTKm_MODULE_ENABLE_${module} is set to `${VTKm_MODULE_ENABLE_${module}}`") + else() + set(reasons) + endif() + + if(enable_flag STREQUAL "DEFAULT") + vtkm_module_get_property(module_groups ${module} GROUPS) + foreach(group IN LISTS module_groups) + get_property(override_exists GLOBAL PROPERTY _vtkm_module_group_enable_${group}_override) + if(override_exists) + get_property(group_enable_flag GLOBAL PROPERTY _vtkm_module_group_enable_${group}_value) + if(reasons_output) + get_property(force_reason + GLOBAL PROPERTY _vtkm_module_group_enable_${group}_reason) + list(APPEND reasons "${force_reason}") + endif() + else() + _vtkm_module_check_enable_flag(VTKm_GROUP_ENABLE_${group}) + set(group_enable_flag "${VTKm_GROUP_ENABLE_${group}}") + if(reasons_output) + list(APPEND reasons "VTKm_GROUP_ENABLE_${group} is set to `${group_enable_flag}`") + endif() + endif() + if(NOT ${group_enable_flag} STREQUAL "DEFAULT") + set(enable_flag ${group_enable_flag}) + break() + endif() + endforeach() + endif() + + if(enable_flag STREQUAL "DEFAULT") + if(_vtkm_modules_want_by_default) + set(enable_flag "WANT") + else() + set(enable_flag "DONT_WANT") + endif() + if(reasons_output) + list(APPEND reasons "${_vtkm_modules_want_by_default_reason}") + endif() + endif() + + set(${output} ${enable_flag} PARENT_SCOPE) + if(reasons_output) + set(${reasons_output} ${reasons} PARENT_SCOPE) + endif() +endfunction() + +function(_vtkm_modules_print_enable_flag module) + _vtkm_module_get_enable_flag(${module} enable_flag reasons) + message(STATUS "Module ${module} is `${enable_flag}` because:") + foreach(reason IN LISTS reasons) + message(STATUS " ${reason}") + endforeach() +endfunction() + +function(_vtkm_modules_print_dependency_chain first_module) + set(last_module ${first_module}) + foreach(dep IN LISTS ARGN) + message(STATUS "Module `${last_module}` depends on module `${dep}`") + set(last_module ${dep}) + endforeach() +endfunction() + +# ----------------------------------------------------------------------------- + +function(_vtkm_modules_try_build target_module dependent_module dependency_chain) + vtkm_module_exists(exists ${target_module}) + if(NOT exists) + # The calling code should check to make sure something is a module before calling this. + message(FATAL_ERROR "\ +Internal error: _vtkm_modules_try_build called for a non-existant module `${target_module}`.") + endif() + + if(TARGET ${target_module}) + # This module is already created. Everything is good. + return() + endif() + + # Detect circular dependencies (to prevent infinite CMake loops) + list(FIND dependency_chain ${target_module} chain_index) + if(chain_index GREATER -1) + message("Circular dependency in modules detected!") + list(SUBLIST dependency_chain ${chain_index} -1 subchain) + _vtkm_modules_print_dependency_chain(${subchain} ${target_module}) + message(FATAL_ERROR "\ +Detected a circular dependency for module `${target_module}`. See the previous \ +messages for the dependency chain. Modify the dependencies in the vtkm.module \ +files to break the dependency cycle.") + endif() + + _vtkm_module_get_enable_flag(${target_module} enable_flag) + + if(enable_flag STREQUAL "NO") + # Cannot build this module. + if(dependent_module) + message("\ +Unable to enable module ${dependent_module} because module ${depends_on_module}, \ +on which it depends, cannot be enabled. See the following status messages \ +for more information.") + _vtkm_modules_print_enable_flag(${dependent_module}) + _vtkm_modules_print_enable_flag(${target_module}) + _vtkm_modules_print_dependency_chain(${dependent_module} ${dependency_chain} ${target_module}) + message(FATAL_ERROR "Inconsistent module enable states. See previous status for details.") + endif() + if(VTKm_VERBOSE_MODULES) + message(STATUS "Not building module ${target_module} because enable flag set to NO.") + _vtkm_modules_print_enable_flag(${target_module}) + endif() + return() + endif() + + if((enable_flag STREQUAL "DONT_WANT") AND (NOT dependent_module)) + # Have no reason to build this module. + if(VTKm_VERBOSE_MODULES) + message(STATUS "\ +Not building module ${target_module} because enable flag set to `DONT_WANT` \ +unless a dependency is found.") + _vtkm_modules_print_enable_flag(${target_module}) + endif() + return() + endif() + + # At this point, we either want or need the module. + + if((enable_flag STREQUAL "YES") AND (NOT dependent_module)) + # Found new target_module + set(dependent_module ${target_module}) + endif() + list(APPEND dependency_chain ${target_module}) + + # Attempt to build all dependent modules first. + vtkm_module_get_property(module_dependencies ${target_module} DEPENDS) + vtkm_module_get_property(module_private_dependencies ${target_module} PRIVATE_DEPENDS) + foreach(depends_on_module IN LISTS module_dependencies module_private_dependencies) + # A module can depend on either a module (which defines a target) or a target created + # somewhere else. If it depends on a module, allow that module to create the target. + vtkm_module_exists(depends_on_is_module ${depends_on_module}) + if(depends_on_is_module) + _vtkm_modules_try_build(${depends_on_module} "${dependent_module}" "${dependency_chain}") + endif() + if(NOT TARGET ${depends_on_module}) + # The module target_module depends on is not being built. Thus, we cannot compile + # this module. Customize the messages based on whether this module was needed to + # be on for correctness and whether the dependency is actually a module or just an + # expected library. + if(dependent_module) + if(depends_on_is_module) + # Internal error. If the dependent module could not be built, it should have already + # issued a FATAL_ERROR. + message(FATAL_ERROR "Internal error: Required module not built.") + else() + _vtkm_modules_print_enable_flag(${target_module}) + message(FATAL_ERROR "\ +Unable to enable module `${target_module}` because it depends on `${depends_on_module}`. \ +There is no module of that name. Either create a module of that name (using a `vtkm.module` \ +file) or create a CMake target of that name before the modules are built.") + endif() + elseif(VTKm_VERBOSE_MODULES) + if(depends_on_is_module) + message(STATUS "\ +Not building module `${target_module}` because it depends on module `${depends_on_module}`, \ +which is not built.") + else() + message(STATUS "\ +Not building module `${target_module}` because it depends on `${depends_on_module}`, which \ +is neither a module or an existing target. Either create a module of that name (using a \ +`vtkm.module` file) or create a CMake target of that name before the modules are built.") + endif() + _vtkm_modules_print_enable_flag(${target_module}) + endif() + return() + endif() + endforeach() + + # Also attempt to build optional dependent modules. These behave the same except we do + # not generate an error if the module cannot be loaded by removing the "dependent_module" + # and ignoring whether the dependent module actually gets built. + vtkm_module_get_property(module_optional_dependencies ${target_module} OPTIONAL_DEPENDS) + foreach(depends_on_module IN LISTS module_optional_dependencies) + vtkm_module_exists(depends_on_is_module ${depends_on_module}) + if(depends_on_is_module) + _vtkm_modules_try_build(${depends_on_module} "" "${dependency_chain}") + endif() + endforeach() + + # We have verified that we can enable this module. + + if(VTKm_VERBOSE_MODULES) + if(enable_flag STREQUAL "DONT_WANT") + list(GET dependency_chain -2 needed_by) + message(STATUS "Enabling module `${target_module}` because it is needed by `${needed_by}`") + else() + message(STATUS "Enabling module `${target_module}`") + endif() + _vtkm_modules_print_enable_flag(${target_module}) + endif() + vtkm_module_get_property(src_directory ${target_module} DIRECTORY) + file(RELATIVE_PATH rel_directory "${VTKm_SOURCE_DIR}" "${src_directory}") + set(vtkm_module_current ${target_module}) + add_subdirectory("${src_directory}" "${VTKm_BINARY_DIR}/${rel_directory}") + set(vtkm_module_current) + if(NOT TARGET ${target_module}) + if(VTKm_VERBOSE_MODULES) + message(STATUS "\ +Module `${target_module}` did not create the expected target. Creating a 'fake' target \ +so that other modules know this module is loaded.") + endif() + add_library(${target_module} INTERFACE) + endif() + get_property(_vtkm_module_list GLOBAL PROPERTY "_vtkm_module_list") + list(APPEND _vtkm_module_list ${target_module}) + set_property(GLOBAL PROPERTY "_vtkm_module_list" "${_vtkm_module_list}") +endfunction() + +# ----------------------------------------------------------------------------- + +function(_vtkm_modules_try_build_tests target_module) + if(NOT TARGET ${target_module}) + # This module was never created, so don't compile tests for it. + return() + endif() + + vtkm_module_get_property(no_testing ${target_module} NO_TESTING) + if(no_testing) + if(VTKm_VERBOSE_MODULES) + message(STATUS + "Not building tests for `${target_module}` because it has the NO_TESTING option.") + endif() + return() + endif() + + vtkm_module_get_property(target_dependencies ${target_module} TEST_DEPENDS) + foreach(dependency IN LISTS target_dependencies) + if(NOT TARGET ${dependency}) + if(VTKm_VERBOSE_MODULES) + message(STATUS + "Not building tests for `${target_module}` because missing dependency `${dependency}`") + endif() + return() + endif() + endforeach() + + vtkm_module_get_property(src_directory ${target_module} DIRECTORY) + file(RELATIVE_PATH rel_directory "${VTKm_SOURCE_DIR}" "${src_directory}") + set(vtkm_module_current_test ${target_module}) + add_subdirectory("${src_directory}/testing" "${VTKm_BINARY_DIR}/${rel_directory}/testing") + set(vtkm_module_current_test) +endfunction() + +# ----------------------------------------------------------------------------- + +#[==[ +Determines which modules should be built and then calls `add_subdirectory` on those +modules to build them. + +```cmake +vtkm_modules_build( + PROVIDED_MODULES ... + [WANT_BY_DEFAULT ] + [WANT_BY_DEFAULT_REASON ] + ) + +The arguments are as follows: + + * `PROVIDED_MODULES`: (Required) A list of module names that are available. + This list typically provided by `vtkm_modules_scan`. + * `WANT_BY_DEFAULT`: (Defaults to `OFF`) Whether modules should by default be + built if possible. + * `WANT_BY_DEFAULT_REASON`: When `VTKm_VERBOSE_MODULES` and a module's enable + is set to the default value (dictated by `WANT_BY_DEFAULT`), then this string + is given as the reason. +``` +#]==] +function(vtkm_modules_build) + cmake_parse_arguments(PARSE_ARGV 0 _build + "" + "WANT_BY_DEFAULT;WANT_BY_DEFAULT_REASON" + "PROVIDED_MODULES" + ) + + if(_build_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Invalid arguments given to vtkm_modules_build.") + endif() + if(NOT _build_PROVIDED_MODULES) + message(FATAL_ERROR "vtkm_modules_build requires PROVIDED_MODULES variable.") + endif() + + if(_build_WANT_BY_DEFAULT) + set(_vtkm_modules_want_by_default ${_build_WANT_BY_DEFAULT}) + else() + set(_vtkm_modules_want_by_default OFF) + endif() + if(_build_WANT_BY_DEFAULT_REASON) + set(_vtkm_modules_want_by_default_reason "${_build_WANT_BY_DEFAULT_REASON}") + else() + set(_vtkm_modules_want_by_default_reason "WANT_BY_DEFAULT is ${_vtkm_modules_want_by_default}") + endif() + + foreach(module IN LISTS _build_PROVIDED_MODULES) + _vtkm_modules_try_build(${module} "" "") + endforeach() + + if(VTKm_ENABLE_TESTING) + foreach(module IN LISTS _build_PROVIDED_MODULES) + _vtkm_modules_try_build_tests(${module}) + endforeach() + endif() +endfunction() diff --git a/CMake/VTKmRenderingContexts.cmake b/CMake/VTKmRenderingContexts.cmake index 6d0309485..bb5dfbaa2 100644 --- a/CMake/VTKmRenderingContexts.cmake +++ b/CMake/VTKmRenderingContexts.cmake @@ -92,6 +92,10 @@ endif() #----------------------------------------------------------------------------- if(VTKm_ENABLE_RENDERING AND NOT TARGET vtkm_rendering_gl_context) add_library(vtkm_rendering_gl_context INTERFACE) + + if(NOT VTKm_INSTALL_ONLY_LIBRARIES) + vtkm_install_targets(TARGETS vtkm_rendering_gl_context) + endif() endif() #----------------------------------------------------------------------------- diff --git a/CMake/VTKmWrappers.cmake b/CMake/VTKmWrappers.cmake index 52bdede9b..3284a6279 100644 --- a/CMake/VTKmWrappers.cmake +++ b/CMake/VTKmWrappers.cmake @@ -197,7 +197,7 @@ endfunction() # # If VTK-m was built with CMake 3.18+ and you are using CMake 3.18+ and have # a cmake_minimum_required of 3.18 or have set policy CMP0105 to new, this will -# return an empty string as the `vtkm::cuda` target will correctly propagate +# return an empty string as the `vtkm_cuda` target will correctly propagate # all the necessary flags. # # This is required for CMake < 3.18 as they don't support the `$` @@ -211,11 +211,11 @@ endfunction() # function(vtkm_get_cuda_flags settings_var) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) if(POLICY CMP0105) cmake_policy(GET CMP0105 does_device_link) get_property(arch_flags - TARGET vtkm::cuda + TARGET vtkm_cuda PROPERTY INTERFACE_LINK_OPTIONS) if(arch_flags AND CMP0105 STREQUAL "NEW") return() @@ -223,7 +223,7 @@ function(vtkm_get_cuda_flags settings_var) endif() get_property(arch_flags - TARGET vtkm::cuda + TARGET vtkm_cuda PROPERTY cuda_architecture_flags) set(${settings_var} "${${settings_var}} ${arch_flags}" PARENT_SCOPE) endif() @@ -259,6 +259,66 @@ function(vtkm_add_drop_unused_function_flags uses_vtkm_target) endif() endfunction() +#----------------------------------------------------------------------------- +# This function takes a target name and returns the mangled version of its name +# in a form that complies with the VTK-m export target naming scheme. +macro(vtkm_target_mangle output target) + string(REPLACE "vtkm_" "" ${output} ${target}) +endmacro() + +#----------------------------------------------------------------------------- +# Enable VTK-m targets to be installed. +# +# This function decorates the `install` CMake function mangling the exported +# target names to comply with the VTK-m exported target names scheme. Use this +# function instead of the canonical CMake `install` function for VTK-m targets. +# +# Signature: +# vtkm_install_targets( +# TARGETS +# [EXPORT ] +# [ARGS ] +# ) +# +# Usage: +# add_library(vtkm_library) +# vtkm_install_targets(TARGETS vtkm_library ARGS COMPONENT core) +# +# TARGETS: List of targets to be installed. +# +# EXPORT: [OPTIONAL] The name of the export set to which this target will be +# added. If omitted vtkm_install_targets will use the value of +# VTKm_EXPORT_NAME by default. +# +# ARGS: [OPTIONAL] Any argument other than `TARGETS` and `EXPORT` accepted +# by the `install` CMake function: +# +# +function(vtkm_install_targets) + set(oneValueArgs EXPORT) + set(multiValueArgs TARGETS ARGS) + cmake_parse_arguments(VTKm_INSTALL "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(export_name ${VTKm_EXPORT_NAME}) + if(VTKm_INSTALL_EXPORT) + set(export_name ${VTKm_INSTALL_EXPORT}) + endif() + + if(NOT DEFINED VTKm_INSTALL_TARGETS) + message(FATAL_ERROR "vtkm_install_targets invoked without TARGETS arguments.") + endif() + + if(DEFINED VTKm_INSTALL_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vtkm_install_targets missing ARGS keyword prepending install arguments") + endif() + + foreach(tgt IN LISTS VTKm_INSTALL_TARGETS) + vtkm_target_mangle(tgt_mangled ${tgt}) + set_target_properties(${tgt} PROPERTIES EXPORT_NAME ${tgt_mangled}) + endforeach() + + install(TARGETS ${VTKm_INSTALL_TARGETS} EXPORT ${export_name} ${VTKm_INSTALL_ARGS}) +endfunction(vtkm_install_targets) #----------------------------------------------------------------------------- # Add a relevant information to target that wants to use VTK-m. @@ -301,7 +361,7 @@ endfunction() # # If VTK-m was built with CMake 3.18+ and you are using CMake 3.18+ and have # a cmake_minimum_required of 3.18 or have set policy CMP0105 to new, this will -# return an empty string as the `vtkm::cuda` target will correctly propagate +# return an empty string as the `vtkm_cuda` target will correctly propagate # all the necessary flags. # # Note: calling `vtkm_add_target_information` multiple times with @@ -368,62 +428,18 @@ function(vtkm_add_target_information uses_vtkm_target) endif() endforeach() - # set the required target properties - if(NOT VTKm_NO_DEPRECATED_VIRTUAL) - set_target_properties(${targets} PROPERTIES POSITION_INDEPENDENT_CODE ON) - set_target_properties(${targets} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - endif() - if(VTKm_TI_DROP_UNUSED_SYMBOLS) foreach(target IN LISTS targets) vtkm_add_drop_unused_function_flags(${target}) endforeach() endif() - if((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda)) + if((TARGET vtkm_cuda) OR (TARGET vtkm::kokkos_cuda)) set_source_files_properties(${VTKm_TI_DEVICE_SOURCES} PROPERTIES LANGUAGE "CUDA") elseif(TARGET vtkm::kokkos_hip) set_source_files_properties(${VTKm_TI_DEVICE_SOURCES} PROPERTIES LANGUAGE "HIP") kokkos_compilation(SOURCE ${VTKm_TI_DEVICE_SOURCES}) endif() - - # Validate that following: - # - We are building with CUDA enabled. - # - We are building a VTK-m library or a library that wants cross library - # device calls. - # - # This is required as CUDA currently doesn't support device side calls across - # dynamic library boundaries. - if((NOT VTKm_NO_DEPRECATED_VIRTUAL) AND ((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda))) - foreach(target IN LISTS targets) - get_target_property(lib_type ${target} TYPE) - if (TARGET vtkm::cuda) - get_target_property(requires_static vtkm::cuda requires_static_builds) - endif() - if (TARGET vtkm::kokkos) - get_target_property(requires_static vtkm::kokkos requires_static_builds) - endif() - - if(requires_static AND ${lib_type} STREQUAL "SHARED_LIBRARY" AND VTKm_TI_EXTENDS_VTKM) - #We provide different error messages based on if we are building VTK-m - #or being called by a consumer of VTK-m. We use PROJECT_NAME so that we - #produce the correct error message when VTK-m is a subdirectory include - #of another project - if(PROJECT_NAME STREQUAL "VTKm") - message(SEND_ERROR "${target} needs to be built STATIC as CUDA doesn't" - " support virtual methods across dynamic library boundaries. You" - " need to set the CMake option BUILD_SHARED_LIBS to `OFF` or" - " (better) turn VTKm_NO_DEPRECATED_VIRTUAL to `ON`.") - else() - message(SEND_ERROR "${target} needs to be built STATIC as CUDA doesn't" - " support virtual methods across dynamic library boundaries. You" - " should either explicitly call add_library with the `STATIC` keyword" - " or set the CMake option BUILD_SHARED_LIBS to `OFF` or" - " (better) turn VTKm_NO_DEPRECATED_VIRTUAL to `ON`.") - endif() - endif() - endforeach() - endif() endfunction() @@ -499,8 +515,8 @@ function(vtkm_library) if (NOT VTKm_SKIP_LIBRARY_VERSIONS) # Setup the SOVERSION and VERSION information for this vtkm library - set_property(TARGET ${lib_name} PROPERTY VERSION 1) - set_property(TARGET ${lib_name} PROPERTY SOVERSION 1) + set_property(TARGET ${lib_name} PROPERTY VERSION ${VTKm_VERSION}.${VTKm_VERSION_PATCH}) + set_property(TARGET ${lib_name} PROPERTY SOVERSION ${VTKm_VERSION}) endif () # Support custom library suffix names, for other projects wanting to inject @@ -512,6 +528,32 @@ function(vtkm_library) endif() set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME ${lib_name}${_lib_suffix}) + # Include any module information + if(vtkm_module_current) + if(NOT lib_name STREQUAL vtkm_module_current) + # We do want each library to be in its own module. (VTK's module allows you to declare + # multiple libraries per module. We may want that in the future, but right now we should + # not need it.) + message(FATAL_ERROR + "Library name `${lib_name}` does not match module name `${vtkm_module_current}`") + endif() + vtkm_module_get_property(depends ${vtkm_module_current} DEPENDS) + vtkm_module_get_property(private_depends ${vtkm_module_current} PRIVATE_DEPENDS) + vtkm_module_get_property(optional_depends ${vtkm_module_current} OPTIONAL_DEPENDS) + target_link_libraries(${lib_name} + PUBLIC ${depends} + PRIVATE ${private_depends} + ) + foreach(opt_dep IN LISTS optional_depends) + if(TARGET ${opt_dep}) + target_link_libraries(${lib_name} PRIVATE ${opt_dep}) + endif() + endforeach() + else() + # Might need to add an argument to vtkm_library to create an exception to this rule + message(FATAL_ERROR "Library `${lib_name}` is not created inside of a VTK-m module.") + endif() + #generate the export header and install it vtkm_generate_export_header(${lib_name}) @@ -531,8 +573,7 @@ function(vtkm_library) endif() #install the library itself - install(TARGETS ${lib_name} - EXPORT ${VTKm_EXPORT_NAME} + vtkm_install_targets(TARGETS ${lib_name} ARGS ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR} LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR} RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR} diff --git a/CMake/testing/VTKmCheckSourceInInstall.cmake b/CMake/testing/VTKmCheckSourceInInstall.cmake index 70fbb615f..587021d83 100644 --- a/CMake/testing/VTKmCheckSourceInInstall.cmake +++ b/CMake/testing/VTKmCheckSourceInInstall.cmake @@ -16,8 +16,7 @@ # -DVTKm_SOURCE_DIR= # -DVTKm_BINARY_DIR= # -DVTKm_INSTALL_INCLUDE_DIR= -# -DVTKm_ENABLE_RENDERING= -# -DVTKm_ENABLE_LOGGING= +# -DDIR_EXCEPTIONS=::... # -DVTKm_ENABLE_HDF5_IO= # -P /CMake/testing/VTKMCheckSourceInInstall.cmake ## @@ -34,12 +33,9 @@ endif () if (NOT VTKm_INSTALL_INCLUDE_DIR) message(FATAL_ERROR "VTKm_INSTALL_INCLUDE_DIR not defined.") endif () -if (NOT DEFINED VTKm_ENABLE_RENDERING) - message(FATAL_ERROR "VTKm_ENABLE_RENDERING not defined.") -endif () -if (NOT DEFINED VTKm_ENABLE_LOGGING) - message(FATAL_ERROR "VTKm_ENABLE_LOGGING not defined.") -endif () +if (NOT DEFINED DIR_EXCEPTIONS) + message(FATAL_ERROR "DIR_EXCEPTIONS not defined.") +endif() if (NOT DEFINED VTKm_ENABLE_HDF5_IO) message(FATAL_ERROR "VTKm_ENABLE_HDF5_IO not defined.") endif() @@ -116,41 +112,13 @@ function(do_verify root_dir prefix) thirdparty/diy/vtkmdiy/cmake/mpi_types.h thirdparty/lodepng/vtkmlodepng/lodepng.h thirdparty/loguru/vtkmloguru/loguru.hpp - - # Ignore deprecated virtual classes (which are not installed if VTKm_NO_DEPRECATED_VIRTUAL - # is on). These exceptions can be removed when these files are completely removed. - cont/ArrayHandleVirtual.h - cont/ArrayHandleVirtual.hxx - cont/ArrayHandleVirtualCoordinates.h - cont/CellLocator.h - cont/PointLocator.h - cont/StorageVirtual.h - cont/StorageVirtual.hxx - cont/VirtualObjectHandle.h - cont/cuda/internal/VirtualObjectTransferCuda.h - cont/internal/TransferInfo.h - cont/internal/VirtualObjectTransfer.h - cont/internal/VirtualObjectTransferInstantiate.h - cont/internal/VirtualObjectTransferShareWithControl.h - cont/kokkos/internal/VirtualObjectTransferKokkos.h - cont/openmp/internal/VirtualObjectTransferOpenMP.h - cont/serial/internal/VirtualObjectTransferSerial.h - cont/tbb/internal/VirtualObjectTransferTBB.h - exec/CellLocator.h - exec/PointLocator.h - internal/ArrayPortalVirtual.h ) + string(REPLACE ":" ";" directory_exceptions "${DIR_EXCEPTIONS}") #by default every header in a testing directory doesn't need to be installed - set(directory_exceptions ".*/testing" ) + list(APPEND directory_exceptions ".*/testing") # These exceptions should be based on the status of the associated # cmake option - if(NOT VTKm_ENABLE_RENDERING) - list(APPEND directory_exceptions rendering) - endif() - if(NOT VTKm_ENABLE_LOGGING) - list(APPEND directory_exceptions thirdparty/loguru) - endif() if (NOT VTKm_ENABLE_HDF5_IO) list(APPEND file_exceptions io/ImageWriterHDF5.h diff --git a/CMake/testing/VTKmPerformanceTest.cmake b/CMake/testing/VTKmPerformanceTest.cmake new file mode 100644 index 000000000..47dfcf4eb --- /dev/null +++ b/CMake/testing/VTKmPerformanceTest.cmake @@ -0,0 +1,149 @@ +##============================================================================ +## 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. +##============================================================================ + +#----------------------------------------------------------------------------- +# Adds a performance benchmark test +# +# Usage: +# add_benchmark_test(benchmark +# [ NAME ] +# [ ARGS ] +# [ REGEX ] +# ) +# +# benchmark: Target of an executable that uses Google Benchmark. +# +# NAME: The name given to the CMake tests. The benchmark target name is used +# if NAME is not specified. +# +# ARGS: Extra arguments passed to the benchmark executable when run. +# +# REGEX: Regular expressions that select the specific benchmarks within the binary +# to be used. It populates the Google Benchmark +# --benchmark_filter parameter. When multiple regexes are passed +# as independent positional arguments, they are joined using the "|" +# regex operator before populating the `--benchmark_filter` parameter. +# +function(add_benchmark_test benchmark) + + # We need JSON support among other things for this to work + if (CMAKE_VERSION VERSION_LESS 3.19) + message(FATAL_ERROR "Performance regression testing needs CMAKE >= 3.19") + return() + endif() + + ###TEST VARIABLES############################################################ + + set(options) + set(one_value_keywords NAME) + set(multi_value_keywords ARGS REGEX) + cmake_parse_arguments(PARSE_ARGV 1 VTKm_PERF "${options}" "${one_value_keywords}" "${multi_value_keywords}") + if (VTKm_PERF_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Bad arguments to add_benchmark_test (${VTKm_PERF_UNPARSED_ARGUMENTS}).") + endif() + + if (NOT VTKm_PERF_NAME) + set(VTKm_PERF_NAME ${benchmark}) + endif() + + if (VTKm_PERF_REGEX) + string(REPLACE ";" "|" VTKm_PERF_REGEX "${VTKm_PERF_REGEX}") + else() + set(VTKm_PERF_REGEX ".*") + endif() + + set(VTKm_PERF_REMOTE_URL "https://gitlab.kitware.com/vbolea/vtk-m-benchmark-records.git") + + # Parameters for the null hypothesis test + set(VTKm_PERF_ALPHA 0.05) + set(VTKm_PERF_REPETITIONS 10) + set(VTKm_PERF_MIN_TIME 1) + set(VTKm_PERF_DIST "normal") + + set(VTKm_PERF_REPO "${CMAKE_BINARY_DIR}/vtk-m-benchmark-records") + set(VTKm_PERF_COMPARE_JSON "${CMAKE_BINARY_DIR}/nocommit_${VTKm_PERF_NAME}.json") + set(VTKm_PERF_STDOUT "${CMAKE_BINARY_DIR}/benchmark_${VTKm_PERF_NAME}.stdout") + set(VTKm_PERF_COMPARE_STDOUT "${CMAKE_BINARY_DIR}/compare_${VTKm_PERF_NAME}.stdout") + + if (DEFINED ENV{CI_COMMIT_SHA}) + set(VTKm_PERF_COMPARE_JSON "${CMAKE_BINARY_DIR}/$ENV{CI_COMMIT_SHA}_${VTKm_PERF_NAME}.json") + endif() + + set(test_name "PerformanceTest${VTKm_PERF_NAME}") + + ###TEST INVOKATIONS########################################################## + add_test(NAME "${test_name}Run" + COMMAND ${CMAKE_COMMAND} + "-DVTKm_PERF_BENCH_DEVICE=Any" + "-DVTKm_PERF_BENCH_PATH=${CMAKE_BINARY_DIR}/bin/${benchmark}" + "-DVTKm_PERF_ARGS=${VTKm_PERF_ARGS}" + "-DVTKm_PERF_REGEX=${VTKm_PERF_REGEX}" + "-DVTKm_PERF_REPETITIONS=${VTKm_PERF_REPETITIONS}" + "-DVTKm_PERF_MIN_TIME=${VTKm_PERF_MIN_TIME}" + "-DVTKm_PERF_COMPARE_JSON=${VTKm_PERF_COMPARE_JSON}" + "-DVTKm_PERF_STDOUT=${VTKm_PERF_STDOUT}" + "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" + -P "${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestRun.cmake" + ) + + add_test(NAME "${test_name}Fetch" + COMMAND ${CMAKE_COMMAND} + "-DVTKm_PERF_REPO=${VTKm_PERF_REPO}" + "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" + "-DVTKm_PERF_REMOTE_URL=${VTKm_PERF_REMOTE_URL}" + -P "${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestFetch.cmake" + ) + + add_test(NAME "${test_name}Upload" + COMMAND ${CMAKE_COMMAND} + "-DVTKm_PERF_REPO=${VTKm_PERF_REPO}" + "-DVTKm_PERF_COMPARE_JSON=${VTKm_PERF_COMPARE_JSON}" + "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" + -P "${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestUpload.cmake" + ) + + add_test(NAME "${test_name}Report" + COMMAND ${CMAKE_COMMAND} + "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" + "-DVTKm_PERF_ALPHA=${VTKm_PERF_ALPHA}" + "-DVTKm_PERF_COMPARE_JSON=${VTKm_PERF_COMPARE_JSON}" + "-DVTKm_PERF_COMPARE_STDOUT=${VTKm_PERF_COMPARE_STDOUT}" + "-DVTKm_PERF_DIST=${VTKm_PERF_DIST}" + "-DVTKm_PERF_NAME=${VTKm_PERF_NAME}" + "-DVTKm_PERF_REPO=${VTKm_PERF_REPO}" + "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" + -P "${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestReport.cmake" + ) + + add_test(NAME "${test_name}CleanUp" + COMMAND ${CMAKE_COMMAND} -E rm -rf "${VTKm_PERF_REPO}" + ) + + ###TEST PROPERTIES########################################################### + set_tests_properties("${test_name}Report" "${test_name}Upload" + PROPERTIES + FIXTURE_REQUIRED "${test_name}Run;${test_name}Fetch" + FIXTURE_CLEANUP "${test_name}CleanUp" + REQUIRED_FILES "${VTKm_PERF_COMPARE_JSON}") + + set_tests_properties("${test_name}Run" + "${test_name}Report" + "${test_name}Upload" + "${test_name}Fetch" + "${test_name}CleanUp" + PROPERTIES RUN_SERIAL ON) + + set_tests_properties(${test_name}Run PROPERTIES TIMEOUT 1800) + + # Only upload when we are inside a CI build + if (NOT DEFINED ENV{CI_COMMIT_SHA} OR NOT DEFINED ENV{VTKM_BENCH_RECORDS_TOKEN}) + set_tests_properties(${test_name}Upload PROPERTIES DISABLED TRUE) + endif() +endfunction() diff --git a/vtkm/filter/internal/CMakeLists.txt b/CMake/testing/VTKmPerformanceTestFetch.cmake similarity index 61% rename from vtkm/filter/internal/CMakeLists.txt rename to CMake/testing/VTKmPerformanceTestFetch.cmake index 05e3f8da9..9342c898b 100644 --- a/vtkm/filter/internal/CMakeLists.txt +++ b/CMake/testing/VTKmPerformanceTestFetch.cmake @@ -1,4 +1,3 @@ - ##============================================================================ ## Copyright (c) Kitware, Inc. ## All rights reserved. @@ -9,9 +8,10 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -set(deprecated_headers - ResolveFieldTypeAndExecute.h - ResolveFieldTypeAndMap.h -) +include(${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestLib.cmake) -vtkm_declare_headers(${deprecated_headers}) +REQUIRE_FLAG_MUTABLE("VTKm_PERF_REPO") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_REMOTE_URL") + +file(REMOVE_RECURSE vtk-m-benchmark-records) +execute(COMMAND /usr/bin/git clone -b records ${VTKm_PERF_REMOTE_URL} ${VTKm_PERF_REPO}) diff --git a/CMake/testing/VTKmPerformanceTestLib.cmake b/CMake/testing/VTKmPerformanceTestLib.cmake new file mode 100644 index 000000000..ba5de8336 --- /dev/null +++ b/CMake/testing/VTKmPerformanceTestLib.cmake @@ -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. +##============================================================================ + +macro(REQUIRE_FLAG flag) + if (NOT DEFINED ${flag}) + message(FATAL_ERROR "Need to pass the ${flag}") + endif() +endmacro(REQUIRE_FLAG) + +macro(REQUIRE_FLAG_MUTABLE flag) + REQUIRE_FLAG(${flag}) + + # Env var overrides default value + if (DEFINED ENV{${flag}}) + set(${flag} "$ENV{${flag}}") + endif() +endmacro(REQUIRE_FLAG_MUTABLE) + +macro(execute) + execute_process( + ${ARGV} + COMMAND_ECHO STDOUT + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + COMMAND_ERROR_IS_FATAL ANY + ) +endmacro() + +message("CTEST_FULL_OUTPUT") diff --git a/CMake/testing/VTKmPerformanceTestReport.cmake b/CMake/testing/VTKmPerformanceTestReport.cmake new file mode 100644 index 000000000..0cf8a26c6 --- /dev/null +++ b/CMake/testing/VTKmPerformanceTestReport.cmake @@ -0,0 +1,77 @@ +##============================================================================ +## 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. +##============================================================================ + +include("${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestLib.cmake") + +REQUIRE_FLAG("VTKm_PERF_NAME") +REQUIRE_FLAG("VTKm_PERF_COMPARE_JSON") +REQUIRE_FLAG("VTKm_PERF_COMPARE_STDOUT") + +REQUIRE_FLAG_MUTABLE("VTKm_PERF_REPO") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_ALPHA") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_DIST") + +###FIND MOST RECENT BASELINE#################################################### +execute(COMMAND /usr/bin/git -C "${VTKm_SOURCE_DIR}" merge-base origin/master @ + OUTPUT_VARIABLE GIT_BASE_COMMIT) + +string(STRIP "${GIT_BASE_COMMIT}" GIT_BASE_COMMIT) + +execute_process(COMMAND /usr/bin/git -C "${VTKm_SOURCE_DIR}" log --format=%H --first-parent "${GIT_BASE_COMMIT}" + OUTPUT_VARIABLE GIT_ANCESTOR_COMMITS + COMMAND_ECHO STDOUT + ECHO_ERROR_VARIABLE + COMMAND_ERROR_IS_FATAL ANY + ) + +string(REPLACE "\n" ";" GIT_ANCESTOR_COMMITS ${GIT_ANCESTOR_COMMITS}) + +foreach(commit IN LISTS GIT_ANCESTOR_COMMITS) + if (EXISTS "${VTKm_PERF_REPO}/${commit}_${VTKm_PERF_NAME}.json") + set(BASELINE_REPORT "${VTKm_PERF_REPO}/${commit}_${VTKm_PERF_NAME}.json") + break() + endif() +endforeach() + +if (NOT DEFINED BASELINE_REPORT) + message(FATAL_ERROR "PerformanceTestReport: no ancestor benchmarks record found") +endif() + +###RUN COMPARE_PY SCRIPT######################################################## +execute(COMMAND /usr/bin/python3 + "${VTKm_SOURCE_DIR}/Utilities/Scripts/compare.py" + --alpha "${VTKm_PERF_ALPHA}" + --dist "${VTKm_PERF_DIST}" + benchmarks "${BASELINE_REPORT}" "${VTKm_PERF_COMPARE_JSON}" + OUTPUT_VARIABLE compare_py_output + ) + +# Write compare.py output to disk +file(WRITE "${VTKm_PERF_COMPARE_STDOUT}" "${compare_py_output}") + +###PERFORM NULL HYPHOTESIS###################################################### +string(REGEX MATCHALL "[^\n]*time_pvalue[^\n]*" pvalues_list ${compare_py_output}) + +foreach(pvalue_line IN LISTS pvalues_list) + # We only take into consideration the wall time of the test + string(REGEX MATCH "(.*)/manual_time_pvalue[ \t]+([0-9.]+)[ ]+" ignoreme ${pvalue_line}) + if (CMAKE_MATCH_0) + set(benchmark_name "${CMAKE_MATCH_1}") + set(benchmark_pvalue "${CMAKE_MATCH_2}") + if("${benchmark_pvalue}" LESS "${VTKm_PERF_ALPHA}") + list(APPEND time_failed_benchs ${benchmark_name}) + endif() + endif() +endforeach() + +if(time_failed_benchs) + string(REPLACE ";" "\n" time_failed_benchs "${time_failed_benchs}") + message(FATAL_ERROR "Time-failed Benchmarks:\n${time_failed_benchs}") +endif() diff --git a/CMake/testing/VTKmPerformanceTestRun.cmake b/CMake/testing/VTKmPerformanceTestRun.cmake new file mode 100644 index 000000000..ec5c5533b --- /dev/null +++ b/CMake/testing/VTKmPerformanceTestRun.cmake @@ -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. +##============================================================================ + +include("${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestLib.cmake") + +REQUIRE_FLAG("VTKm_PERF_BENCH_PATH") +REQUIRE_FLAG("VTKm_PERF_REGEX") +REQUIRE_FLAG("VTKm_PERF_COMPARE_JSON") +REQUIRE_FLAG("VTKm_PERF_STDOUT") + +REQUIRE_FLAG_MUTABLE("VTKm_PERF_BENCH_DEVICE") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_REPETITIONS") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_MIN_TIME") + +execute( + COMMAND "${VTKm_PERF_BENCH_PATH}" + --vtkm-device "${VTKm_PERF_BENCH_DEVICE}" + ${VTKm_PERF_ARGS} + "--benchmark_filter=${VTKm_PERF_REGEX}" + "--benchmark_out=${VTKm_PERF_COMPARE_JSON}" + "--benchmark_repetitions=${VTKm_PERF_REPETITIONS}" + "--benchmark_min_time=${VTKm_PERF_MIN_TIME}" + --benchmark_out_format=json + --benchmark_counters_tabular=true + OUTPUT_VARIABLE report_output + ) + +# Write compare.py output to disk +file(WRITE "${VTKm_PERF_STDOUT}" "${report_output}") diff --git a/CMake/testing/VTKmPerformanceTestUpload.cmake b/CMake/testing/VTKmPerformanceTestUpload.cmake new file mode 100644 index 000000000..4c5567164 --- /dev/null +++ b/CMake/testing/VTKmPerformanceTestUpload.cmake @@ -0,0 +1,23 @@ +##============================================================================ +## 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. +##============================================================================ + +include("${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTestLib.cmake") + +REQUIRE_FLAG("VTKm_PERF_COMPARE_JSON") +REQUIRE_FLAG_MUTABLE("VTKm_PERF_REPO") + +file(COPY "${VTKm_PERF_COMPARE_JSON}" DESTINATION "${VTKm_PERF_REPO}/") +get_filename_component(perf_report_name "${VTKm_PERF_COMPARE_JSON}" NAME) + +execute(COMMAND /usr/bin/git -C "${VTKm_PERF_REPO}" config --local user.name vtk-m\ benchmark\ job) +execute(COMMAND /usr/bin/git -C "${VTKm_PERF_REPO}" config --local user.email do_not_email_the_robot@kitware.com) +execute(COMMAND /usr/bin/git -C "${VTKm_PERF_REPO}" add "${perf_report_name}") +execute(COMMAND /usr/bin/git -C "${VTKm_PERF_REPO}" commit -m "Added ${perf_report_name} record") +execute(COMMAND /usr/bin/git -C "${VTKm_PERF_REPO}" push origin records) diff --git a/CMake/testing/VTKmTestInstall.cmake b/CMake/testing/VTKmTestInstall.cmake index 3b27250b7..839c80b82 100644 --- a/CMake/testing/VTKmTestInstall.cmake +++ b/CMake/testing/VTKmTestInstall.cmake @@ -11,12 +11,23 @@ # ----------------------------------------------------------------------------- function(vtkm_test_install ) if(NOT VTKm_INSTALL_ONLY_LIBRARIES) + # Find all modules that are not-compiled. Skip these directories. + set(dir_exceptions) + foreach(module IN LISTS all_modules) + if(NOT TARGET ${module}) + vtkm_module_get_property(directory ${module} DIRECTORY) + file(RELATIVE_PATH directory "${VTKm_SOURCE_DIR}/vtkm" "${directory}") + list(APPEND dir_exceptions ${directory}) + endif() + endforeach() + # Replace ';' list separator with ':' to preserve them as a single argument + string(REPLACE ";" ":" dir_exceptions "${dir_exceptions}") + set(command_args "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" "-DVTKm_INSTALL_INCLUDE_DIR=${VTKm_INSTALL_INCLUDE_DIR}" - "-DVTKm_ENABLE_RENDERING=${VTKm_ENABLE_RENDERING}" - "-DVTKm_ENABLE_LOGGING=${VTKm_ENABLE_LOGGING}" + "-DDIR_EXCEPTIONS=${dir_exceptions}" "-DVTKm_ENABLE_HDF5_IO=${VTKm_ENABLE_HDF5_IO}" ) @@ -71,7 +82,7 @@ set(CMAKE_CXX_STANDARD \"${CMAKE_CXX_STANDARD}\" CACHE STRING \"\") set(CMAKE_CXX_STANDARD_REQUIRED ${CMAKE_CXX_STANDARD_REQUIRED} CACHE BOOL \"\") set(CMAKE_CUDA_COMPILER \"${CMAKE_CUDA_COMPILER}\" CACHE FILEPATH \"\") set(CMAKE_CUDA_FLAGS \"$CACHE{CMAKE_CUDA_FLAGS}\" CACHE STRING \"\") -set(CMAKE_CUDA_HOST_COMPILER \"${CMAKE_CUDA_HOST_COMPILER}\" CACHE FILEPATH \"\") +set(CMAKE_HIP_COMPILER \"${CMAKE_HIP_COMPILER}\" CACHE FILEPATH \"\") " ) diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index c36ba67ad..508bbd300 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -10,7 +10,7 @@ include(VTKmWrappers) -function(vtkm_create_test_executable +function(_vtkm_create_test_executable prog_name sources device_sources @@ -206,35 +206,67 @@ function(vtkm_unit_tests) # Add the path to the location where generated regression test images should be written list(APPEND VTKm_UT_TEST_ARGS "--vtkm-write-dir=${VTKm_BINARY_DIR}") + set(test_libraries) + if(vtkm_module_current_test) + vtkm_module_get_property(module_dir ${vtkm_module_current_test} DIRECTORY) + vtkm_module_get_property(depends ${vtkm_module_current_test} TEST_DEPENDS) + vtkm_module_get_property(optional_depends ${vtkm_module_current_test} TEST_OPTIONAL_DEPENDS) + list(APPEND depends ${vtkm_module_current_test}) + set(test_libraries ${depends}) + foreach(lib IN LISTS VTKm_UT_LIBRARIES) + vtkm_module_exists(lib_is_module ${lib}) + if((lib_is_module) AND (NOT ${lib} IN_LIST depends) AND (NOT ${lib} IN_LIST optional_depends)) + message(WARNING "\ +Test program for module `${vtkm_module_current_test}` lists `${lib} as a library in \ +vtkm_unit_tests but not in its test dependencies. Add test dependencies to \ +`${module_dir}/vtkm.module`.") + endif() + list(APPEND test_libraries ${lib}) + endforeach() + foreach(module IN LISTS optional_depends) + if(TARGET ${module}) + list(APPEND test_libraries ${module}) + endif() + endforeach() + else() + if(NOT vtkm_module_current) + message(WARNING "TEST ${test_prog} is not associated with any module.") + endif() + endif() + + if(vtkm_module_current) + message(WARNING "Test ${test_prog} is being created inside a module definition rather than tests.") + endif() + if(VTKm_UT_MPI) if (VTKm_ENABLE_MPI) - vtkm_create_test_executable( + _vtkm_create_test_executable( ${test_prog} "${VTKm_UT_SOURCES}" "${VTKm_UT_DEVICE_SOURCES}" - "${VTKm_UT_LIBRARIES}" + "${test_libraries}" "${VTKm_UT_DEFINES}" ON # is_mpi_test ON # use_mpi ${VTKm_UT_USE_VTKM_JOB_POOL}) endif() if ((NOT VTKm_ENABLE_MPI) OR VTKm_ENABLE_DIY_NOMPI) - vtkm_create_test_executable( + _vtkm_create_test_executable( ${test_prog} "${VTKm_UT_SOURCES}" "${VTKm_UT_DEVICE_SOURCES}" - "${VTKm_UT_LIBRARIES}" + "${test_libraries}" "${VTKm_UT_DEFINES}" ON # is_mpi_test OFF # use_mpi ${VTKm_UT_USE_VTKM_JOB_POOL}) endif() else() - vtkm_create_test_executable( + _vtkm_create_test_executable( ${test_prog} "${VTKm_UT_SOURCES}" "${VTKm_UT_DEVICE_SOURCES}" - "${VTKm_UT_LIBRARIES}" + "${test_libraries}" "${VTKm_UT_DEFINES}" OFF # is_mpi_test OFF # use_mpi diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c7a9e6b2..31572a24b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,14 @@ cmake_dependent_option(VTKm_ENABLE_TESTING_LIBRARY "Enable VTKm Testing Library" OFF "NOT VTKm_ENABLE_TESTING;NOT VTKm_ENABLE_BENCHMARKS" ON) mark_as_advanced(VTKm_ENABLE_TESTING_LIBRARY) +# We may want to make finer controls on whether libraries/modules get built. +# VTK uses the concept of groups for its modules +vtkm_option(VTKm_BUILD_ALL_LIBRARIES + "Build all libraries by default. (Can be overridden for each library.)" + ON + ) +mark_as_advanced(VTKm_BUILD_ALL_LIBRARIES) + vtkm_option(VTKm_USE_DOUBLE_PRECISION "Use double precision for floating point calculations" OFF) vtkm_option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON) @@ -169,12 +177,6 @@ vtkm_option(VTKm_ENABLE_DEVELOPER_FLAGS "Enable compiler flags that are useful w # Some application might need not to install those, hence this option. vtkm_option(VTKm_NO_INSTALL_README_LICENSE "disable the installation of README and LICENSE files" OFF) -# We are in the process of deprecating the use of virtual methods because they -# are not well supported on many accelerators. Turn this option on to remove -# the code entirely. In VTK-m 2.0 virtual methods should be removed entirely -# and this option will be removed. -vtkm_option(VTKm_NO_DEPRECATED_VIRTUAL "Do not compile support of deprecated virtual methods" ON) - # In Python wheels, having SONAME suffixes just ends up duplicating files. # Allow VTK to turn off these symlinks for its wheel distribution. vtkm_option(VTKm_SKIP_LIBRARY_VERSIONS "Skip versioning VTK-m libraries" OFF) @@ -188,10 +190,29 @@ mark_as_advanced( VTKm_HIDE_PRIVATE_SYMBOLS VTKm_ENABLE_DEVELOPER_FLAGS VTKm_NO_INSTALL_README_LICENSE - VTKm_NO_DEPRECATED_VIRTUAL VTKm_SKIP_LIBRARY_VERSIONS ) +#----------------------------------------------------------------------------- +# Force building of modules where specified by user-facing options. +include(VTKmModules) +vtkm_module_force_group(Core VALUE "YES" REASON "Core modules always built") +vtkm_module_force_group(Rendering ENABLE_OPTION VTKm_ENABLE_RENDERING) +vtkm_module_force_group(Logging ENABLE_OPTION VTKm_ENABLE_LOGGING) +vtkm_module_force_group(Testing + ENABLE_OPTION VTKm_ENABLE_TESTING_LIBRARY + ENABLE_VALUE "WANT" + DISABLE_VALUE "DONT_WANT" + ) +vtkm_module_force_group(Benchmarking ENABLE_OPTION VTKm_ENABLE_BENCHMARKS) + +# The tutorial requires several common filters. This logic might need to +# become more complicated (or less compliated if we decide to always +# compile these). +if(VTKm_ENABLE_TUTORIALS) + vtkm_module_force_group(FiltersCommon VALUE "YES" REASON "Tutorial needs common filters.") +endif() + #----------------------------------------------------------------------------- # Setup default build types @@ -262,7 +283,18 @@ check_type_size("long long" VTKm_SIZE_LONG_LONG BUILTIN_TYPES_ONLY) #----------------------------------------------------------------------------- # Add subdirectories add_subdirectory(vtkmstd) -add_subdirectory(vtkm) + +#----------------------------------------------------------------------------- +# Process modules +vtkm_modules_scan( + SCAN_DIRECTORIES vtkm benchmarking + PROVIDED_MODULES all_modules + ) +vtkm_modules_build( + PROVIDED_MODULES ${all_modules} + WANT_BY_DEFAULT ${VTKm_BUILD_ALL_LIBRARIES} + WANT_BY_DEFAULT_REASON "VTKm_BUILD_ALL_LIBRARIES is `${VTKm_BUILD_ALL_LIBRARIES}`" + ) #----------------------------------------------------------------------------- # Build documentation @@ -291,6 +323,33 @@ write_basic_package_version_file( VERSION ${VTKm_VERSION} COMPATIBILITY ExactVersion ) +#----------------------------------------------------------------------------- +# Create makefile/package files for projects not using CMake + +set(lib_args) +vtkm_module_get_list(module_list) +list(REVERSE module_list) +foreach(module IN LISTS module_list) + get_target_property(type ${module} TYPE) + if (NOT type MATCHES "LIBRARY" OR type STREQUAL "INTERFACE_LIBRARY") + continue() + endif() + get_target_property(library ${module} OUTPUT_NAME) + if (NOT library) + continue() + endif() + set(lib_args "${lib_args} \\ + -l${library}") +endforeach() +if (TARGET vtkmdiympi) + set(lib_args "${lib_args} \\ + -lvtkmdiympi") +endif() +if (TARGET vtkmdiympi_nompi) + set(lib_args "${lib_args} \\ + -lvtkmdiympi_nompi") +endif() + configure_file(${VTKm_SOURCE_DIR}/config/vtkm_config.mk.in ${VTKm_BINARY_DIR}/config/vtkm_config.mk @ONLY) install(FILES ${VTKm_BINARY_DIR}/config/vtkm_config.mk @@ -353,9 +412,11 @@ if(NOT VTKm_INSTALL_ONLY_LIBRARIES) # Create and install exports for external projects export(EXPORT ${VTKm_EXPORT_NAME} + NAMESPACE vtkm:: FILE ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmTargets.cmake ) install(EXPORT ${VTKm_EXPORT_NAME} + NAMESPACE vtkm:: DESTINATION ${VTKm_INSTALL_CONFIG_DIR} FILE VTKmTargets.cmake ) @@ -376,12 +437,6 @@ if (VTKm_ENABLE_CPACK) include(CPack) endif () -#----------------------------------------------------------------------------- -#add the benchmarking folder -if(VTKm_ENABLE_BENCHMARKS) - add_subdirectory(benchmarking) -endif() - #----------------------------------------------------------------------------- if (VTKm_ENABLE_TESTING) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 1c4a65a76..995f94349 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -53,3 +53,11 @@ list(APPEND CTEST_CUSTOM_WARNING_MATCH # Let CUDA compiler warn us about recursive functions we should avoid. ".*nvlink warning.*" ) + +## Sometimes a few test hangs in HIP disable repeat until_pass for HIP builds +set(CTEST_REPEAT_UNTIL_PASS 3) +if (NOT x"@CMAKE_HIP_COMPILER@"x STREQUAL xx) + set(CTEST_REPEAT_UNTIL_PASS 0) +endif() + +set(VTKm_ENABLE_PERFORMANCE_TESTING "@VTKm_ENABLE_PERFORMANCE_TESTING@") diff --git a/README.md b/README.md index 7f0bc8d07..bd2f3d25d 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,10 @@ and then build. Here are some example *nix commands for the process (individual commands may vary). ```sh -$ tar xvzf ~/Downloads/vtk-m-v1.9.0.tar.gz +$ tar xvzf ~/Downloads/vtk-m-v2.0.0.tar.gz $ mkdir vtkm-build $ cd vtkm-build -$ cmake-gui ../vtk-m-v1.9.0 +$ cmake-gui ../vtk-m-v2.0.0 $ cmake --build -j . # Runs make (or other build program) ``` @@ -246,9 +246,9 @@ project(VTKmDemo CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_rendering) +if(TARGET vtkm::rendering) add_executable(Demo Demo.cxx) - target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering vtkm_source) + target_link_libraries(Demo PRIVATE vtkm::filter vtkm::rendering vtkm::source) endif() ``` diff --git a/Utilities/Scripts/compare.py b/Utilities/Scripts/compare.py index 539ace6fb..e7d12503a 100755 --- a/Utilities/Scripts/compare.py +++ b/Utilities/Scripts/compare.py @@ -55,6 +55,15 @@ def create_parser(): default=True, action="store_false", help="The tool can do a two-tailed Mann-Whitney U test with the null hypothesis that it is equally likely that a randomly selected value from one sample will be less than or greater than a randomly selected value from a second sample.\nWARNING: requires **LARGE** (no less than {}) number of repetitions to be meaningful!\nThe test is being done by default, if at least {} repetitions were done.\nThis option can disable the U Test.".format(report.UTEST_OPTIMAL_REPETITIONS, report.UTEST_MIN_REPETITIONS)) + + utest.add_argument( + '--dist', + dest='utest_dist', + choices=['mannwhitney', 'normal', 't'], + default='mannwhitney', + type=str, + help="Utest probabilistic distribution to use") + alpha_default = 0.05 utest.add_argument( "--alpha", @@ -239,7 +248,7 @@ def main(): # Diff and output output_lines = gbench.report.generate_difference_report( json1, json2, args.display_aggregates_only, - args.utest, args.utest_alpha) + args.utest, args.utest_dist, args.utest_alpha, sys.stdout.isatty()) print(description) for ln in output_lines: print(ln) diff --git a/Utilities/Scripts/gbench/report.py b/Utilities/Scripts/gbench/report.py index 5bd3a8d85..ecf0f76ad 100644 --- a/Utilities/Scripts/gbench/report.py +++ b/Utilities/Scripts/gbench/report.py @@ -6,7 +6,11 @@ import re import copy from scipy.stats import mannwhitneyu +from scipy.stats import norm +from scipy.stats import t +from statistics import mean +from statistics import stdev class BenchmarkColor(object): def __init__(self, name, code): @@ -38,6 +42,7 @@ BC_UNDERLINE = BenchmarkColor('UNDERLINE', '\033[4m') UTEST_MIN_REPETITIONS = 2 UTEST_OPTIMAL_REPETITIONS = 9 # Lowest reasonable number, More is better. UTEST_COL_NAME = "_pvalue" +UTEST_NORM_MIN_STDEV = 0.05 def color_format(use_color, fmt_str, *args, **kwargs): @@ -154,7 +159,7 @@ def extract_field(partition, field_name): rhs = [x[field_name] for x in partition[1]] return [lhs, rhs] -def calc_utest(timings_cpu, timings_time): +def calc_utest(utest_dist, timings_cpu, timings_time): min_rep_cnt = min(len(timings_time[0]), len(timings_time[1]), len(timings_cpu[0]), @@ -164,20 +169,30 @@ def calc_utest(timings_cpu, timings_time): if min_rep_cnt < UTEST_MIN_REPETITIONS: return False, None, None - time_pvalue = mannwhitneyu( - timings_time[0], timings_time[1], alternative='two-sided').pvalue - cpu_pvalue = mannwhitneyu( - timings_cpu[0], timings_cpu[1], alternative='two-sided').pvalue + pvalue_fn = str + if utest_dist == "normal": + pvalue_fn = lambda x : norm.sf(mean(x[1]), mean(x[0]), + max(stdev(x[0]), mean(x[0])*UTEST_NORM_MIN_STDEV)) + elif utest_dist == "t": + pvalue_fn = lambda x : t.sf(mean(x[1]), len(x[0]) - 1, mean(x[0]), + max(stdev(x[0]), mean(x[0])*UTEST_NORM_MIN_STDEV)) + elif utest_dist == "mannwhitney": + pvalue_fn = lambda x : mannwhitneyu(x[0], x[1], alternative='two-sided').pvalue + else: + return False, None, None + + time_pvalue = pvalue_fn(timings_time) + cpu_pvalue = pvalue_fn(timings_cpu) return (min_rep_cnt >= UTEST_OPTIMAL_REPETITIONS), cpu_pvalue, time_pvalue -def print_utest(partition, utest_alpha, first_col_width, use_color=True): +def print_utest(partition, utest_dist, utest_alpha, first_col_width, use_color=True): def get_utest_color(pval): return BC_FAIL if pval >= utest_alpha else BC_OKGREEN timings_time = extract_field(partition, 'real_time') timings_cpu = extract_field(partition, 'cpu_time') - have_optimal_repetitions, cpu_pvalue, time_pvalue = calc_utest(timings_cpu, timings_time) + have_optimal_repetitions, cpu_pvalue, time_pvalue = calc_utest(utest_dist, timings_cpu, timings_time) # Check if we failed miserably with minimum required repetitions for utest if not have_optimal_repetitions and cpu_pvalue is None and time_pvalue is None: @@ -212,6 +227,7 @@ def generate_difference_report( json2, display_aggregates_only=False, utest=False, + utest_dist="mannwhitney", utest_alpha=0.05, use_color=True): """ @@ -279,6 +295,7 @@ def generate_difference_report( # After processing the whole partition, if requested, do the U test. if utest: output_strs += print_utest(partition, + utest_dist=utest_dist, utest_alpha=utest_alpha, first_col_width=first_col_width, use_color=use_color) diff --git a/benchmarking/BenchmarkFieldAlgorithms.cxx b/benchmarking/BenchmarkFieldAlgorithms.cxx index 13899d63c..f288a5f4c 100644 --- a/benchmarking/BenchmarkFieldAlgorithms.cxx +++ b/benchmarking/BenchmarkFieldAlgorithms.cxx @@ -19,10 +19,6 @@ #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif - #include #include @@ -225,21 +221,30 @@ public: using ExecutionSignature = void(_1, _2, _3, _4); using InputDomain = _1; - template + template VTKM_EXEC void operator()(const vtkm::Id2& low_high, const WeightType& weight, - const vtkm::exec::ExecutionWholeArrayConst& inPortal, - T& result) const + const PortalType& inPortal, + U& result) const + { + using T = typename PortalType::ValueType; + this->DoIt(low_high, weight, inPortal, result, typename std::is_same::type{}); + } + + template + VTKM_EXEC void DoIt(const vtkm::Id2& low_high, + const WeightType& weight, + const PortalType& inPortal, + typename PortalType::ValueType& result, + std::true_type) const { //fetch the low / high values from inPortal result = vtkm::Lerp(inPortal.Get(low_high[0]), inPortal.Get(low_high[1]), weight); } - template - VTKM_EXEC void operator()(const vtkm::Id2&, - const WeightType&, - const vtkm::exec::ExecutionWholeArrayConst&, - U&) const + template + VTKM_EXEC void DoIt(const vtkm::Id2&, const WeightType&, const PortalType&, U&, std::false_type) + const { //the inPortal and result need to be the same type so this version only //exists to generate code when using dynamic arrays @@ -420,20 +425,6 @@ void BenchBlackScholesStatic(::benchmark::State& state) }; VTKM_BENCHMARK_TEMPLATES(BenchBlackScholesStatic, ValueTypes); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template -void BenchBlackScholesDynamic(::benchmark::State& state) -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - BenchBlackScholesImpl impl{ state }; - impl.Run(vtkm::cont::make_ArrayHandleVirtual(impl.StockPrice), - vtkm::cont::make_ArrayHandleVirtual(impl.OptionStrike), - vtkm::cont::make_ArrayHandleVirtual(impl.OptionYears)); - VTKM_DEPRECATED_SUPPRESS_END -}; -VTKM_BENCHMARK_TEMPLATES(BenchBlackScholesDynamic, ValueTypes); -#endif //VTKM_NO_DEPRECATED_VIRTUAL - template void BenchBlackScholesMultiplexer0(::benchmark::State& state) { @@ -528,20 +519,6 @@ void BenchMathStatic(::benchmark::State& state) }; VTKM_BENCHMARK_TEMPLATES(BenchMathStatic, ValueTypes); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template -void BenchMathDynamic(::benchmark::State& state) -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - BenchMathImpl impl{ state }; - impl.Run(vtkm::cont::make_ArrayHandleVirtual(impl.InputHandle), - vtkm::cont::make_ArrayHandleVirtual(impl.TempHandle1), - vtkm::cont::make_ArrayHandleVirtual(impl.TempHandle2)); - VTKM_DEPRECATED_SUPPRESS_END -}; -VTKM_BENCHMARK_TEMPLATES(BenchMathDynamic, ValueTypes); -#endif //VTKM_NO_DEPRECATED_VIRTUAL - template void BenchMathMultiplexer0(::benchmark::State& state) { @@ -631,18 +608,6 @@ void BenchFusedMathStatic(::benchmark::State& state) }; VTKM_BENCHMARK_TEMPLATES(BenchFusedMathStatic, ValueTypes); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template -void BenchFusedMathDynamic(::benchmark::State& state) -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - BenchFusedMathImpl impl{ state }; - impl.Run(vtkm::cont::make_ArrayHandleVirtual(impl.InputHandle)); - VTKM_DEPRECATED_SUPPRESS_END -}; -VTKM_BENCHMARK_TEMPLATES(BenchFusedMathDynamic, ValueTypes); -#endif //VTKM_NO_DEPRECATED_VIRTUAL - template void BenchFusedMathMultiplexer0(::benchmark::State& state) { @@ -755,20 +720,6 @@ void BenchEdgeInterpStatic(::benchmark::State& state) }; VTKM_BENCHMARK_TEMPLATES(BenchEdgeInterpStatic, InterpValueTypes); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template -void BenchEdgeInterpDynamic(::benchmark::State& state) -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - BenchEdgeInterpImpl impl{ state }; - impl.Run(vtkm::cont::make_ArrayHandleVirtual(impl.EdgePairHandle), - vtkm::cont::make_ArrayHandleVirtual(impl.WeightHandle), - vtkm::cont::make_ArrayHandleVirtual(impl.FieldHandle)); - VTKM_DEPRECATED_SUPPRESS_END -}; -VTKM_BENCHMARK_TEMPLATES(BenchEdgeInterpDynamic, InterpValueTypes); -#endif //VTKM_NO_DEPRECATED_VIRTUAL - struct ImplicitFunctionBenchData { vtkm::cont::ArrayHandle Points; @@ -834,37 +785,6 @@ void BenchImplicitFunction(::benchmark::State& state) } VTKM_BENCHMARK(BenchImplicitFunction); -void BenchVirtualImplicitFunction(::benchmark::State& state) -{ - using EvalWorklet = EvaluateImplicitFunction; - - const vtkm::cont::DeviceAdapterId device = Config.Device; - - auto data = MakeImplicitFunctionBenchData(); - - { - std::ostringstream desc; - desc << data.Points.GetNumberOfValues() << " points"; - state.SetLabel(desc.str()); - } - - EvalWorklet eval; - - vtkm::cont::Timer timer{ device }; - vtkm::cont::Invoker invoker{ device }; - - for (auto _ : state) - { - (void)_; - timer.Start(); - invoker(eval, data.Points, data.Result, data.Sphere1); - timer.Stop(); - - state.SetIterationTime(timer.GetElapsedTime()); - } -} -VTKM_BENCHMARK(BenchVirtualImplicitFunction); - void Bench2ImplicitFunctions(::benchmark::State& state) { using EvalWorklet = Evaluate2ImplicitFunctions; diff --git a/benchmarking/BenchmarkFilters.cxx b/benchmarking/BenchmarkFilters.cxx index 56959078e..093e5c7a4 100644 --- a/benchmarking/BenchmarkFilters.cxx +++ b/benchmarking/BenchmarkFilters.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -96,6 +97,17 @@ vtkm::cont::DataSet& GetUnstructuredInputDataSet() return *UnstructuredInputDataSet; } +vtkm::cont::PartitionedDataSet* InputPartitionedData; +vtkm::cont::PartitionedDataSet* UnstructuredInputPartitionedData; +vtkm::cont::PartitionedDataSet& GetInputPartitionedData() +{ + return *InputPartitionedData; +} +vtkm::cont::PartitionedDataSet& GetUnstructuredInputPartitionedData() +{ + return *UnstructuredInputPartitionedData; +} + // The point scalars to use: static std::string PointScalarsName; // The cell scalars to use: @@ -120,7 +132,8 @@ enum GradOpts : int Vorticity = 1 << 3, QCriterion = 1 << 4, RowOrdering = 1 << 5, - ScalarInput = 1 << 6 + ScalarInput = 1 << 6, + PartitionedInput = 1 << 7 }; void BenchGradient(::benchmark::State& state, int options) @@ -162,11 +175,21 @@ void BenchGradient(::benchmark::State& state, int options) vtkm::cont::Timer timer{ device }; //vtkm::cont::DataSet input = static_cast(options & Structured) ? GetInputDataSet() : GetUnstructuredInputDataSet(); + vtkm::cont::PartitionedDataSet input; + if (options & PartitionedInput) + { + input = GetInputPartitionedData(); + } + else + { + input = GetInputDataSet(); + } + for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); @@ -179,7 +202,9 @@ void BenchGradient(::benchmark::State& state, int options) VTKM_BENCHMARK(BenchGradient##Name) VTKM_PRIVATE_GRADIENT_BENCHMARK(Scalar, Gradient | ScalarInput); +VTKM_PRIVATE_GRADIENT_BENCHMARK(ScalarPartitionedData, Gradient | ScalarInput | PartitionedInput); VTKM_PRIVATE_GRADIENT_BENCHMARK(Vector, Gradient); +VTKM_PRIVATE_GRADIENT_BENCHMARK(VectorPartitionedData, Gradient | PartitionedInput); VTKM_PRIVATE_GRADIENT_BENCHMARK(VectorRow, Gradient | RowOrdering); VTKM_PRIVATE_GRADIENT_BENCHMARK(Point, PointGradient); VTKM_PRIVATE_GRADIENT_BENCHMARK(Divergence, Divergence); @@ -190,7 +215,7 @@ VTKM_PRIVATE_GRADIENT_BENCHMARK(All, #undef VTKM_PRIVATE_GRADIENT_BENCHMARK -void BenchThreshold(::benchmark::State& state) +void BenchThreshold(::benchmark::State& state, bool partitionedInput) { const vtkm::cont::DeviceAdapterId device = Config.Device; @@ -210,24 +235,33 @@ void BenchThreshold(::benchmark::State& state) filter.SetLowerThreshold(mid - quarter); filter.SetUpperThreshold(mid + quarter); + auto input = partitionedInput ? GetInputPartitionedData() : GetInputDataSet(); + vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK(BenchThreshold); + +#define VTKM_PRIVATE_THRESHOLD_BENCHMARK(Name, Opts) \ + void BenchThreshold##Name(::benchmark::State& state) { BenchThreshold(state, Opts); } \ + VTKM_BENCHMARK(BenchThreshold##Name) + +VTKM_PRIVATE_THRESHOLD_BENCHMARK(BenchThreshold, false); +VTKM_PRIVATE_THRESHOLD_BENCHMARK(BenchThresholdPartitioned, true); void BenchThresholdPoints(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; const bool compactPoints = static_cast(state.range(0)); + const bool partitionedInput = static_cast(state.range(1)); // Lookup the point scalar range const auto range = []() -> vtkm::Range { @@ -246,19 +280,33 @@ void BenchThresholdPoints(::benchmark::State& state) filter.SetUpperThreshold(mid + quarter); filter.SetCompactPoints(compactPoints); + vtkm::cont::PartitionedDataSet input; + input = partitionedInput ? GetInputPartitionedData() : GetInputDataSet(); + vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK_OPTS(BenchThresholdPoints, ->ArgName("CompactPts")->DenseRange(0, 1)); + +void BenchThresholdPointsGenerator(::benchmark::internal::Benchmark* bm) +{ + bm->ArgNames({ "CompactPts", "PartitionedInput" }); + + bm->Args({ 0, 0 }); + bm->Args({ 1, 0 }); + bm->Args({ 0, 1 }); + bm->Args({ 1, 1 }); +} + +VTKM_BENCHMARK_APPLY(BenchThresholdPoints, BenchThresholdPointsGenerator); void BenchCellAverage(::benchmark::State& state) { @@ -284,68 +332,79 @@ VTKM_BENCHMARK(BenchCellAverage); void BenchPointAverage(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; + const bool isPartitioned = static_cast(state.range(0)); vtkm::filter::field_conversion::PointAverage filter; filter.SetActiveField(CellScalarsName, vtkm::cont::Field::Association::Cells); + vtkm::cont::PartitionedDataSet input; + input = isPartitioned ? GetInputPartitionedData() : GetInputDataSet(); vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK(BenchPointAverage); +VTKM_BENCHMARK_OPTS(BenchPointAverage, ->ArgName("PartitionedInput")->DenseRange(0, 1)); void BenchWarpScalar(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; + const bool isPartitioned = static_cast(state.range(0)); vtkm::filter::field_transform::WarpScalar filter{ 2. }; filter.SetUseCoordinateSystemAsField(true); filter.SetNormalField(PointVectorsName, vtkm::cont::Field::Association::Points); filter.SetScalarFactorField(PointScalarsName, vtkm::cont::Field::Association::Points); + vtkm::cont::PartitionedDataSet input; + input = isPartitioned ? GetInputPartitionedData() : GetInputDataSet(); + vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK(BenchWarpScalar); +VTKM_BENCHMARK_OPTS(BenchWarpScalar, ->ArgName("PartitionedInput")->DenseRange(0, 1)); void BenchWarpVector(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; + const bool isPartitioned = static_cast(state.range(0)); vtkm::filter::field_transform::WarpVector filter{ 2. }; filter.SetUseCoordinateSystemAsField(true); filter.SetVectorField(PointVectorsName, vtkm::cont::Field::Association::Points); + vtkm::cont::PartitionedDataSet input; + input = isPartitioned ? GetInputPartitionedData() : GetInputDataSet(); + vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK(BenchWarpVector); +VTKM_BENCHMARK_OPTS(BenchWarpVector, ->ArgName("PartitionedInput")->DenseRange(0, 1)); void BenchContour(::benchmark::State& state) { @@ -356,6 +415,7 @@ void BenchContour(::benchmark::State& state) const bool mergePoints = static_cast(state.range(2)); const bool normals = static_cast(state.range(3)); const bool fastNormals = static_cast(state.range(4)); + const bool isPartitioned = static_cast(state.range(5)); vtkm::filter::contour::Contour filter; filter.SetActiveField(PointScalarsName, vtkm::cont::Field::Association::Points); @@ -383,7 +443,15 @@ void BenchContour(::benchmark::State& state) vtkm::cont::Timer timer{ device }; - vtkm::cont::DataSet input = isStructured ? GetInputDataSet() : GetUnstructuredInputDataSet(); + vtkm::cont::PartitionedDataSet input; + if (isPartitioned) + { + input = isStructured ? GetInputPartitionedData() : GetUnstructuredInputPartitionedData(); + } + else + { + input = isStructured ? GetInputDataSet() : GetUnstructuredInputDataSet(); + } for (auto _ : state) { @@ -399,17 +467,31 @@ void BenchContour(::benchmark::State& state) void BenchContourGenerator(::benchmark::internal::Benchmark* bm) { - bm->ArgNames({ "IsStructuredDataSet", "NIsoVals", "MergePts", "GenNormals", "FastNormals" }); + bm->ArgNames({ "IsStructuredDataSet", + "NIsoVals", + "MergePts", + "GenNormals", + "FastNormals", + "MultiPartitioned" }); auto helper = [&](const vtkm::Id numIsoVals) { - bm->Args({ 0, numIsoVals, 0, 0, 0 }); - bm->Args({ 0, numIsoVals, 1, 0, 0 }); - bm->Args({ 0, numIsoVals, 0, 1, 0 }); - bm->Args({ 0, numIsoVals, 0, 1, 1 }); - bm->Args({ 1, numIsoVals, 0, 0, 0 }); - bm->Args({ 1, numIsoVals, 1, 0, 0 }); - bm->Args({ 1, numIsoVals, 0, 1, 0 }); - bm->Args({ 1, numIsoVals, 0, 1, 1 }); + bm->Args({ 0, numIsoVals, 0, 0, 0, 0 }); + bm->Args({ 0, numIsoVals, 1, 0, 0, 0 }); + bm->Args({ 0, numIsoVals, 0, 1, 0, 0 }); + bm->Args({ 0, numIsoVals, 0, 1, 1, 0 }); + bm->Args({ 1, numIsoVals, 0, 0, 0, 0 }); + bm->Args({ 1, numIsoVals, 1, 0, 0, 0 }); + bm->Args({ 1, numIsoVals, 0, 1, 0, 0 }); + bm->Args({ 1, numIsoVals, 0, 1, 1, 0 }); + + bm->Args({ 0, numIsoVals, 0, 0, 0, 1 }); + bm->Args({ 0, numIsoVals, 1, 0, 0, 1 }); + bm->Args({ 0, numIsoVals, 0, 1, 0, 1 }); + bm->Args({ 0, numIsoVals, 0, 1, 1, 1 }); + bm->Args({ 1, numIsoVals, 0, 0, 0, 1 }); + bm->Args({ 1, numIsoVals, 1, 0, 0, 1 }); + bm->Args({ 1, numIsoVals, 0, 1, 0, 1 }); + bm->Args({ 1, numIsoVals, 0, 1, 1, 1 }); }; helper(1); @@ -417,34 +499,48 @@ void BenchContourGenerator(::benchmark::internal::Benchmark* bm) helper(12); } -// :TODO: Disabled until SIGSEGV in Countour when passings field is resolved VTKM_BENCHMARK_APPLY(BenchContour, BenchContourGenerator); void BenchExternalFaces(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; const bool compactPoints = static_cast(state.range(0)); + const bool isPartitioned = false; //static_cast(state.range(1)); vtkm::filter::entity_extraction::ExternalFaces filter; filter.SetCompactPoints(compactPoints); + vtkm::cont::PartitionedDataSet input; + input = isPartitioned ? GetInputPartitionedData() : GetInputDataSet(); + vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK_OPTS(BenchExternalFaces, ->ArgName("Compact")->DenseRange(0, 1)); + +void BenchExternalFacesGenerator(::benchmark::internal::Benchmark* bm) +{ + bm->ArgNames({ "Compact", "PartitionedInput" }); + + bm->Args({ 0, 0 }); + bm->Args({ 1, 0 }); + bm->Args({ 0, 1 }); + bm->Args({ 1, 1 }); +} +VTKM_BENCHMARK_APPLY(BenchExternalFaces, BenchExternalFacesGenerator); void BenchTetrahedralize(::benchmark::State& state) { const vtkm::cont::DeviceAdapterId device = Config.Device; + const bool isPartitioned = static_cast(state.range(0)); // This filter only supports structured datasets: if (FileAsInput && !InputIsStructured()) @@ -453,20 +549,23 @@ void BenchTetrahedralize(::benchmark::State& state) } vtkm::filter::geometry_refinement::Tetrahedralize filter; + vtkm::cont::PartitionedDataSet input; + input = isPartitioned ? GetInputPartitionedData() : GetInputDataSet(); vtkm::cont::Timer timer{ device }; for (auto _ : state) { (void)_; timer.Start(); - auto result = filter.Execute(GetInputDataSet()); + auto result = filter.Execute(input); ::benchmark::DoNotOptimize(result); timer.Stop(); state.SetIterationTime(timer.GetElapsedTime()); } } -VTKM_BENCHMARK(BenchTetrahedralize); + +VTKM_BENCHMARK_OPTS(BenchTetrahedralize, ->ArgName("PartitionedInput")->DenseRange(0, 1)); void BenchVertexClustering(::benchmark::State& state) { @@ -803,6 +902,7 @@ enum optionIndex CELL_SCALARS, POINT_VECTORS, WAVELET_DIM, + NUM_PARTITIONS, TETRA }; @@ -810,6 +910,7 @@ void InitDataSet(int& argc, char** argv) { std::string filename; vtkm::Id waveletDim = 256; + vtkm::Id numPartitions = 1; bool tetra = false; namespace option = vtkm::cont::internal::option; @@ -854,6 +955,12 @@ void InitDataSet(int& argc, char** argv) Arg::Number, " --wavelet-dim \tThe size in each dimension of the wavelet grid " "(if generated)." }); + usage.push_back({ NUM_PARTITIONS, + 0, + "", + "num-partitions", + Arg::Number, + " --num-partitions \tThe number of partitions to create" }); usage.push_back({ TETRA, 0, "", @@ -903,6 +1010,12 @@ void InitDataSet(int& argc, char** argv) parse >> waveletDim; } + if (options[NUM_PARTITIONS]) + { + std::istringstream parse(options[NUM_PARTITIONS].arg); + parse >> numPartitions; + } + tetra = (options[TETRA] != nullptr); // Now go back through the arg list and remove anything that is not in the list of @@ -992,6 +1105,19 @@ void InitDataSet(int& argc, char** argv) GetInputDataSet() = GetUnstructuredInputDataSet(); } + //Create partitioned data. + if (numPartitions > 0) + { + std::cerr << "[InitDataSet] Creating " << numPartitions << " partitions." << std::endl; + InputPartitionedData = new vtkm::cont::PartitionedDataSet; + UnstructuredInputPartitionedData = new vtkm::cont::PartitionedDataSet; + for (vtkm::Id i = 0; i < numPartitions; i++) + { + GetInputPartitionedData().AppendPartition(GetInputDataSet()); + GetUnstructuredInputPartitionedData().AppendPartition(GetUnstructuredInputDataSet()); + } + } + inputGenTimer.Stop(); std::cerr << "[InitDataSet] DataSet initialization took " << inputGenTimer.GetElapsedTime() @@ -1027,4 +1153,6 @@ int main(int argc, char* argv[]) VTKM_EXECUTE_BENCHMARKS_PREAMBLE(argc, args.data(), dataSetSummary); delete InputDataSet; delete UnstructuredInputDataSet; + delete InputPartitionedData; + delete UnstructuredInputPartitionedData; } diff --git a/benchmarking/BenchmarkInSitu.cxx b/benchmarking/BenchmarkInSitu.cxx index 5c59b7d9c..c60db51cf 100644 --- a/benchmarking/BenchmarkInSitu.cxx +++ b/benchmarking/BenchmarkInSitu.cxx @@ -118,7 +118,9 @@ void BuildInputDataSet(uint32_t cycle, bool isStructured, bool isMultiBlock, vtk PointVectorsName = "perlinnoisegrad"; // Generate uniform dataset(s) - const vtkm::Id3 dims{ dim, dim, dim }; + vtkm::source::PerlinNoise noise; + noise.SetPointDimensions({ dim, dim, dim }); + noise.SetSeed(static_cast(cycle)); if (isMultiBlock) { for (auto i = 0; i < 2; ++i) @@ -127,12 +129,9 @@ void BuildInputDataSet(uint32_t cycle, bool isStructured, bool isMultiBlock, vtk { for (auto k = 0; k < 2; ++k) { - const vtkm::Vec3f origin{ static_cast(i), - static_cast(j), - static_cast(k) }; - const vtkm::source::PerlinNoise noise{ dims, - origin, - static_cast(cycle) }; + noise.SetOrigin({ static_cast(i), + static_cast(j), + static_cast(k) }); const auto dataset = noise.Execute(); partitionedInputDataSet.AppendPartition(dataset); } @@ -141,7 +140,6 @@ void BuildInputDataSet(uint32_t cycle, bool isStructured, bool isMultiBlock, vtk } else { - const vtkm::source::PerlinNoise noise{ dims, static_cast(cycle) }; inputDataSet = noise.Execute(); } @@ -986,6 +984,34 @@ void ParseBenchmarkOptions(int& argc, char** argv) std::cerr << "Using image size = " << ImageSize << "x" << ImageSize << std::endl; } +// Adding a const char* or std::string to a vector of char* is harder than it sounds. +void AddArg(int& argc, std::vector& args, const std::string newArg) +{ + // This object will be deleted when the program exits + static std::vector> stringPool; + + // Add a new vector of chars to the back of stringPool + stringPool.emplace_back(); + std::vector& newArgData = stringPool.back(); + + // Copy the string to the std::vector. + // Yes, something like malloc or strdup would be easier. But that would technically create + // a memory leak that could be reported by a memory analyzer. By copying this way, the + // memory will be deleted on program exit and no leak will be reported. + newArgData.resize(newArg.length() + 1); + std::copy(newArg.begin(), newArg.end(), newArgData.begin()); + newArgData.back() = '\0'; // Don't forget the terminating null character. + + // Add the argument to the list. + if (args.size() <= static_cast(argc)) + { + args.resize(static_cast(argc + 1)); + } + args[static_cast(argc)] = newArgData.data(); + + ++argc; +} + } // end anon namespace int main(int argc, char* argv[]) @@ -1023,10 +1049,14 @@ int main(int argc, char* argv[]) if (benchmark_repetitions) { if (!benchmark_min_time) - args[argc++] = strdup("--benchmark_min_time=0.00000001"); + { + AddArg(argc, args, "--benchmark_min_time=0.00000001"); + } if (!benchmark_report_aggregates_only) - args[argc++] = strdup("--benchmark_report_aggregates_only=true"); + { + AddArg(argc, args, "--benchmark_report_aggregates_only=true"); + } } VTKM_EXECUTE_BENCHMARKS(argc, args.data()); diff --git a/benchmarking/BenchmarkRayTracing.cxx b/benchmarking/BenchmarkRayTracing.cxx index 487d06610..f6c7ae261 100644 --- a/benchmarking/BenchmarkRayTracing.cxx +++ b/benchmarking/BenchmarkRayTracing.cxx @@ -39,9 +39,8 @@ vtkm::cont::InitializeResult Config; void BenchRayTracing(::benchmark::State& state) { - const vtkm::Id3 dims(128, 128, 128); - - vtkm::source::Tangle maker(dims); + vtkm::source::Tangle maker; + maker.SetPointDimensions({ 128, 128, 128 }); vtkm::cont::DataSet dataset = maker.Execute(); vtkm::cont::CoordinateSystem coords = dataset.GetCoordinateSystem(); diff --git a/benchmarking/CMakeLists.txt b/benchmarking/CMakeLists.txt index aa2946cce..33b782649 100644 --- a/benchmarking/CMakeLists.txt +++ b/benchmarking/CMakeLists.txt @@ -8,23 +8,25 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ +if(NOT vtkm_module_current STREQUAL "benchmarking") + message(FATAL_ERROR "Benchmarking CMakeLists.txt not loaded by benchmarking module.") +endif() + #Find Google Benchmark.Note that benchmark_DIR must be pointed at an #installation, not a build directory. find_package(benchmark REQUIRED) -function(add_benchmark) - set(options) - set(oneValueArgs NAME FILE) - set(multiValueArgs LIBS) - cmake_parse_arguments(VTKm_AB - "${options}" "${oneValueArgs}" "${multiValueArgs}" - ${ARGN} - ) - set(exe_name ${VTKm_AB_NAME}) - - add_executable(${exe_name} ${VTKm_AB_FILE}) - target_link_libraries(${exe_name} PRIVATE ${VTKm_AB_LIBS}) +function(add_benchmark exe_name) + add_executable(${exe_name} ${exe_name}.cxx) target_link_libraries(${exe_name} PRIVATE benchmark::benchmark) + vtkm_module_get_property(depends benchmarking DEPENDS) + target_link_libraries(${exe_name} PRIVATE ${depends}) + vtkm_module_get_property(optional_depends benchmarking OPTIONAL_DEPENDS) + foreach(dep IN LISTS optional_depends) + if(TARGET ${dep}) + target_link_libraries(${exe_name} PRIVATE ${dep}) + endif() + endforeach() vtkm_add_drop_unused_function_flags(${exe_name}) vtkm_add_target_information(${exe_name}) @@ -34,7 +36,8 @@ function(add_benchmark) CUDA_VISIBILITY_PRESET "hidden" ) - vtkm_add_target_information(${exe_name} DEVICE_SOURCES ${VTKm_AB_FILE}) + # At some point, we might not want to compile benchmarks with device compilers. + vtkm_add_target_information(${exe_name} DEVICE_SOURCES ${exe_name}.cxx) endfunction() set(benchmarks @@ -48,18 +51,56 @@ set(benchmarks BenchmarkTopologyAlgorithms ) +if(TARGET vtkm_rendering) + list(APPEND benchmarks + BenchmarkRayTracing + BenchmarkInSitu + ) +endif() + set(VTKm_BENCHS_RANGE_LOWER_BOUNDARY 4096 CACHE STRING "Smallest sample for input size bench for BenchmarkDeviceAdapter") set(VTKm_BENCHS_RANGE_UPPER_BOUNDARY 134217728 CACHE STRING "Biggest sample for input size bench for BenchmarkDeviceAdapter") mark_as_advanced(VTKm_BENCHS_RANGE_LOWER_BOUNDARY VTKm_BENCHS_RANGE_UPPER_BOUNDARY) foreach (benchmark ${benchmarks}) - add_benchmark(NAME ${benchmark} FILE ${benchmark}.cxx LIBS vtkm_source vtkm_filter vtkm_io) + add_benchmark(${benchmark}) endforeach () target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY}) target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY}) -if(TARGET vtkm_rendering) - add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering vtkm_source) - add_benchmark(NAME BenchmarkInSitu FILE BenchmarkInSitu.cxx LIBS vtkm_rendering vtkm_source vtkm_filter vtkm_io) +if(VTKm_ENABLE_PERFORMANCE_TESTING) + include("${VTKm_SOURCE_DIR}/CMake/testing/VTKmPerformanceTest.cmake") + add_benchmark_test(BenchmarkFilters + NAME BenchThreshold + REGEX BenchThreshold + ) + add_benchmark_test(BenchmarkFilters + NAME BenchTetrahedralize + REGEX BenchTetrahedralize + ) + add_benchmark_test(BenchmarkFilters + NAME BenchContour + REGEX + BenchContour/IsStructuredDataSet:1/NIsoVals:12/MergePts:1/GenNormals:0.*/MultiPartitioned:0 + BenchContour/IsStructuredDataSet:1/NIsoVals:12/MergePts:0/GenNormals:1/FastNormals:1.*/MultiPartitioned:0 + BenchContour/IsStructuredDataSet:0/NIsoVals:12/MergePts:1/GenNormals:0.*/MultiPartitioned:0 + BenchContour/IsStructuredDataSet:0/NIsoVals:12/MergePts:0/GenNormals:1/FastNormals:1.*/MultiPartitioned:0 + ) + add_benchmark_test(BenchmarkFilters + NAME BenchContourPartitioned + ARGS --wavelet-dim=32 --num-partitions=128 + REGEX + BenchContour/IsStructuredDataSet:1/NIsoVals:12/MergePts:1/GenNormals:0.*/MultiPartitioned:1 + BenchContour/IsStructuredDataSet:1/NIsoVals:12/MergePts:0/GenNormals:1/FastNormals:1.*/MultiPartitioned:1 + BenchContour/IsStructuredDataSet:0/NIsoVals:12/MergePts:1/GenNormals:0.*/MultiPartitioned:1 + BenchContour/IsStructuredDataSet:0/NIsoVals:12/MergePts:0/GenNormals:1/FastNormals:1.*/MultiPartitioned:1 + ) + add_benchmark_test(BenchmarkFilters + NAME BenchVertexClustering + REGEX BenchVertexClustering/NumDivs:256 + ) + if(TARGET vtkm_rendering) + add_benchmark_test(BenchmarkInSitu REGEX "BenchContour") + endif() endif() diff --git a/benchmarking/vtkm.module b/benchmarking/vtkm.module new file mode 100644 index 000000000..96ad0840e --- /dev/null +++ b/benchmarking/vtkm.module @@ -0,0 +1,19 @@ +NAME + benchmarking +GROUPS + Benchmarking +DEPENDS + vtkm_cont + vtkm_filter_contour + vtkm_filter_entity_extraction + vtkm_filter_field_conversion + vtkm_filter_field_transform + vtkm_filter_flow + vtkm_filter_geometry_refinement + vtkm_filter_mesh_info + vtkm_filter_vector_analysis + vtkm_io + vtkm_source +OPTIONAL_DEPENDS + vtkm_rendering +NO_TESTING diff --git a/config/vtkm.pc.in b/config/vtkm.pc.in index 71f7c71ac..162e7fdaa 100644 --- a/config/vtkm.pc.in +++ b/config/vtkm.pc.in @@ -18,14 +18,4 @@ Name: VTKm Description: The VTKm library Version: @VTKm_VERSION@ Cflags: -I${includedir}/vtkm-@CMAKE_INSTALL_PREFIX@ -Libs: -L${libdir} \ - -lvtkm_rendering-@VTKm_VERSION@ \ - -lvtkm_filter_contour-@VTKm_VERSION@ \ - -lvtkm_filter_gradient-@VTKm_VERSION@ \ - -lvtkm_filter_extra-@VTKm_VERSION@ \ - -lvtkm_filter_common-@VTKm_VERSION@ \ - -lvtkm_worklet-@VTKm_VERSION@ \ - -lvtkm_source-@VTKm_VERSION@ \ - -lvtkm_io-@VTKm_VERSION@ \ - -lvtkm_cont-@VTKm_VERSION@ \ - -lvtkmdiympi_nompi +Libs: -L${libdir}@lib_args@ diff --git a/config/vtkm_config.mk.in b/config/vtkm_config.mk.in index 0325e2dee..35d1bb968 100644 --- a/config/vtkm_config.mk.in +++ b/config/vtkm_config.mk.in @@ -25,14 +25,4 @@ VTKm_ENABLE_EGL_CONTEXT = @VTKm_ENABLE_EGL_CONTEXT@ VTKm_ENABLE_MPI = @VTKm_ENABLE_MPI@ VTKm_INCLUDE_FLAGS = -I $(VTKm_DIR)/include -VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib \ - -lvtkm_rendering-$(VTKM_VERSION) \ - -lvtkm_filter_contour-$(VTKM_VERSION) \ - -lvtkm_filter_gradient-$(VTKM_VERSION) \ - -lvtkm_filter_extra-$(VTKM_VERSION) \ - -lvtkm_filter_common-$(VTKM_VERSION) \ - -lvtkm_worklet-$(VTKM_VERSION) \ - -lvtkm_source-$(VTKM_VERSION) \ - -lvtkm_io-$(VTKM_VERSION) \ - -lvtkm_cont-$(VTKM_VERSION) \ - -lvtkmdiympi_nompi +VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib@lib_args@ diff --git a/docs/CI-README.md b/docs/CI-README.md index 1028ed82e..f63745125 100644 --- a/docs/CI-README.md +++ b/docs/CI-README.md @@ -19,6 +19,10 @@ Gitlab CI 4. ECP Continuous Integration - OLCF Ascent testing machine +5. Automated Performance Regression tests + - Overview + - Details + # Kitware Gitlab CI GitLab CI/CD allows for software development through continous integration, delivery, and deployment. @@ -308,4 +312,103 @@ GCC8. For a view of only ascent jobs refer to the following [link][cdash-ascent]. +# Automated Performance Regression tests + +## Overview + +The design of the performance regression test is composed of the following +components: + +1. The Kitware Gitlab instance which trigger the benchmark jobs when a git + commit is pushed. +2. Gitlab CI jobs for performing the benchmarks and for generating the + comparison with the historical results. +3. A Git repository that is used for storing the historical results. +4. The Kitware CDASH instance which files, displays the performance report and + inform the developer if a performance regression has occurred. + +The performance regression test is performed whenever a git commit is pushed. +The job _performancetest_ which invoke the benchmark suite in a Gitlab runner +job and later compare its results against the historical results, stored in +CDASH, of its most immediate master ancestor. The results of this comparison are +then displayed in a brief report in the form of a comment in its corresponding +Gitlab merge-request. + +![perftest_arch](perftest_arch.png) + +## Details + +### Selection of Benchmarks + +While we can possibly run all of the provided benchmarks in the continuous +build track to avoid potential performance and latency issues in the CI, I +have initially limited the benchmark suites to: + +- BenchmarkFilters +- BenchmarkInsitu + +### Benchmark ctest + +We provide a CMake function named `add_benchmark_test` which sets the +performance regression test for the given Google Benchmark suite. It admits one +argument to filter the number of benchmarks to be executed. If ran locally, it +will not upload the results to the online record repository. + +### Requirements + +- Python3 with the SciPy package +- Benchmark tests will be enabled in a CMAKE build that sets both + `VTKm_ENABLE_BENCHMARKS` and `VTKm_ENABLE_PERFORMANCE_TESTING` + +### New Gitlab Runner requirements + +- It must have disabled every type of CPU scaling option both at the BIOS and + Kernel level (`cpugovern`). +- It must provide a gitlab runner with a concurrency level 1 to avoid other + jobs being scheduled while the benchmark is being executed. + +### How to make sense of the results + +Results of both of the benchmark and the comparison against its most recent +commit ancestor can be accessed in the CDASH Notes for the performance +regression build. The CDASH Notes can be accessed by clicking the note-like +miniature image in the build name column. + +Performance Regressions test that report a performance failure are reported in +the form of a test failure of the test `PerformanceTest($TestName)Report`. The +results of the comparison can be seen by clicking this failed test. + +Performance regression test success is determined by the performance of a null +hypothesis test with the hypothesis that the given tests performs similarly +or better than the baseline test with a confidence level 1-alpha. If a pvalue is +small enough (less than alpha), we reject the null hypothesis and we report that +the current commit introduces a performance regression. By default we use a +t-distribution with an alpha value of 5%. The pvalues can be seen in the +uploaded reports. + +The following parameters can be modified by editing the corresponding +environmental variables: + +- Alpha value: `VTKm_PERF_ALPHA` +- Minimum number of repetitions for each benchmark: `VTKm_PERF_REPETITIONS` +- Minimum time to spend for each benchmark: `VTKm_PERF_MIN_TIME` +- Statistical distribution to use: `VTKm_PERF_DIST` + +Below is an example of this raw output of the comparison of the current commit +against the baseline results: + +``` +Benchmark Time CPU Time Old Time New CPU Old CPU New +------------------------------------------------------------------------------------------------------------ +BenchThreshold/manual_time +0.0043 +0.0036 73 73 92 92 +BenchThreshold/manual_time +0.0074 +0.0060 73 73 91 92 +BenchThreshold/manual_time -0.0003 -0.0007 73 73 92 92 +BenchThreshold/manual_time -0.0019 -0.0018 73 73 92 92 +BenchThreshold/manual_time -0.0021 -0.0017 73 73 92 92 +BenchThreshold/manual_time +0.0001 +0.0006 73 73 92 92 +BenchThreshold/manual_time +0.0033 +0.0031 73 73 92 92 +BenchThreshold/manual_time -0.0071 -0.0057 73 73 92 92 +BenchThreshold/manual_time -0.0050 -0.0041 73 73 92 92 +``` + [cdash-ascent]: https://open.cdash.org/index.php?project=VTKM&filtercount=1&showfilters=1&field1=site&compare1=63&value1=ascent diff --git a/docs/HPCBuilds.md b/docs/HPCBuilds.md index c6d678a19..2edec8a4d 100644 --- a/docs/HPCBuilds.md +++ b/docs/HPCBuilds.md @@ -89,7 +89,6 @@ ${cmake_build_dir}/bin/cmake -S ${vtkm_src_dir} -B ${vtkm_build_dir} \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF\ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=ON\ - -DVTKm_NO_DEPRECATED_VIRTUAL=ON \ -DVTKm_ENABLE_KOKKOS=ON \ -DVTKm_ENABLE_MPI=OFF\ -DVTKm_ENABLE_RENDERING=ON \ diff --git a/docs/Modules.md b/docs/Modules.md new file mode 100644 index 000000000..ae1dcf593 --- /dev/null +++ b/docs/Modules.md @@ -0,0 +1,245 @@ +# Specifying modules in the VTK-m build system + +The VTK-m build system comes with a module mechanism that allows a library +or other target be optionally compiled based on CMake configuration +variables. Additionally, modules can be optionally compiled based on their +dependencies. That is, a module can be turned on if a module that depends +on it wants to be compiled. Likewise, a module can be turned off if a +module that it depends on cannot be compiled. + +## Module configuration + +All modules have a "name" that is the same as the target created by the +module (for example, the name of a library). Every module has an associated +(advanced) CMake variable named `VTKm_MODULE_ENABLE_`. For example, +the module that builds the `vtkm_filter_entity_extraction` filter has an +associated CMake variable named +`VTKm_MODULE_ENABLE_vtkm_filter_entity_extraction`. This CMake variable can +be used to control whether the module should be included in the build. It +can be set to one of the following values. + + * `YES`: Always create the module. If it is not possible to create the + module, the CMake configuration fails. + * `WANT`: Create the module if possible. If it is possible to create all + modules it depends on, then this module will be created. If this is not + possible, this module will not be created, but this will not cause an + error in the configuration. + * `DONT_WANT`: Create the module only if there is a dependency that + requires it. This is useful for stripping out modules not directly + needed but required for a select list of modules desired. + * `NO`: Never create the module. Any module that depends on this module + will also not be built. + * `DEFAULT`: Does the default behavior. This is typically either `WANT` + or `DONT_WANT` depending on other configuration. + +The advantage of having these multiple options is that it becomes possible +to turn off all modules except a select desired few and have the CMake +configuration automatically determine dependencies. + +### Module groups + +Modules can also declare themselves as part of a group. Module groups +provide a way to turn on/off the build of several related modules. For +example, there is a module group named `FiltersCommon` that contains +modules with the most commonly used filters in VTK-m. + +Every module group has an associated (advanced) CMake variable named +`VTKm_GROUP_ENABLE_`. For example, the `FiltersCommon` group has an +associated CMake variable named `VTKm_GROUP_ENABLE_FiltersCommon`. This +variable can be set to the same `YES`/`WANT`/`DONT_WANT`/`NO`/`DEFAULT` +values as those for the `VTKm_MODULE_ENABLE` variables described earlier. + +### Default behavior + +If a `VTKm_MODULE_ENABLE_*` variable is set to `DEFAULT`, then the +configuration first checks all the `VTKm_GROUP_ENABLE_*` variables +associated with the groups the module belongs to. It will use the first +value not set to `DEFAULT` that it encounters. + +If all the module's group are also set to `DEFAULT` (or the module does not +belong to any groups) then the behavior is based on the +`VTKm_BUILD_ALL_LIBRARIES` CMake variable. If `VTKm_BUILD_ALL_LIBRARIES` is +`ON`, then the default behavior becomes `WANT`. Otherwise, it becomes +`DONT_WANT`. + +## Specifying a module + +A module is created in much the same way as a normal target is made in +CMake: Create a directory with the appropriate source material and add a +`CMakeLists.txt` file to specify how they are built. However, the main +difference is that you do _not_ link to the directory with a CMake +`add_subdirectory` command (or any other command like `include` or +`subdirs`). + +Instead, you simply create a file named `vtkm.module` and place it in the +same directory with the `CMakeLists.txt` file. The VTK-m configuration will +automatically find this `vtkm.module` file, recognize the directory as +containing a module, and automatically include the associated +`CMakeLists.txt` in the build (given that the CMake configuration turns on +the module to be compiled). + +Each `vtkm.module` is a simple text file that contains a list of options. +Each option is provided by giving the name of the option followed by the +arguments for that option. The following options can be defined in a +`vtkm.module` file. `NAME` is required, but the rest are optional. + + * `NAME`: The name of the target created by the module. + * `GROUPS`: A list of all groups the module belongs to. If a module's + enable flag is set to `DEFAULT`, then the enable option is taken from + the groups it belongs to. + * `DEPENDS`: A list of all modules (or other libraries) on which this + module depends. Everything in this list is added as a link library to + the library created with `vtkm_library`. + * `PRIVATE_DEPENDS`: Same as `DEPENDS` except that these libraries are + added as private link libraries. + * `OPTIONAL_DEPENDS`: A list of all modules that that are not strictly + needed but will be used if available. + * `TEST_DEPENDS`: A list of all modules (or other libraries) on which the + tests for this module depends. + * `TEST_OPTIONAL_DEPENDS`: A list of all modules that the test executable + will like to if they exist, but are not necessary. + * `NO_TESTING`: Normally, a module is expected to have a subdirectory + named `testing`, which will build any necessary testing executables and + add ctest tests. If this option is given, no tests are added. (Note, + modules generally should have tests.) + +A `vtkm.module` file may also have comments. Everything between a `#` and +the end of the line will be ignored. + +As an example, the `vtkm_filter_entity_extraction` module (located in +`vtkm/filter/entity_extraction` has a `vtkm.module` file that looks like +the following. + +``` cmake +NAME + vtkm_filter_entity_extraction +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_worklet + vtkm_filter_core + vtkm_filter_clean_grid +TEST_DEPENDS + vtkm_filter_clean_grid + vtkm_filter_entity_extraction + vtkm_source +``` + +## Building the module + +As mentioned earlier, a VTK-m module directory has its own +`CMakeLists.txt`. There does not have to be anything particularly special +about the `CMakeLists.txt`. If the module is building a library target +(which is typical), it should use the `vtkm_library` CMake command to do so +to make sure the proper compiler flags are added. + +Here is an example portion of the `CMakeLists.txt` for the +`vtkm_filter_entity_extraction` module. (Mainly, the definition of +variables containing source and header files is left out.) + +``` cmake +vtkm_library( + NAME vtkm_filter_entity_extraction + HEADERS ${entity_extraction_headers} + DEVICE_SOURCES ${entity_extraction_sources_device} + USE_VTKM_JOB_POOL +) + +target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_entity_extraction) +``` + +Note that if a library created by a module depends on the library created +by another module, it should be in the `DEPENDS` list of `vtkm.module`. For +example, the `vtkm.module` contains `vtkm_filter_clean_grid` in its +`DEPENDS` list, and that library will automatically be added as a target +link library to `vtkm_filter_entity_extraction`. You should avoid using +`target_link_libraries` to link one module to another as the modules will +not be able to guarantee that all the targets will be created correctly. + +Also note that the `CMakeLists.txt` file should _not_ include its testing +directory with `add_subdirectory`. As described in the next section, the +testing directory will automatically be added, if possible. (Using +`add_subdirectory` for other subdirectories on which the module depends is +OK.) + +## Module testing directory + +All modules are expected to have a `testing` subdirectory. This +subdirectory should contain its own `CMakeLists.txt` that, typically, +builds a testing executable and adds the appropriate tests. (This is +usually done with the `vtkm_unit_tests` CMake function.) + +However, a module should _not_ include its own `testing` directory with +`add_subdirectory`. This is because the tests for a module might have +dependencies that the module itself does not. For example, it is common for +filter tests to use a source to generate some test data. But what if the +CMake configuration has the source module turned off? Should the filter +module be turned off because the tests need the source module? No. Should +the source module be turned on just because some tests want it? No. + +To resolve this issue, VTK-m modules allow for an extended set of +dependencies for the tests. This is specified with the `TEST_DEPENDS` +variable in `vtkm.module`. It will then add the test only if all the test +dependencies are met. + +If the dependencies for both the module itself and the module's tests are +met, then the `testing` subdirectory of the module will be added to the +build. Like for the module itself, the `CMakeLists.txt` in the `testing` +directory should build tests just like any other CMake directory. Here is +an example `CMakeLists.txt` for the `vtkm_filter_entity_extraction` module. + +``` cmake +set(unit_tests + UnitTestExternalFacesFilter.cxx + UnitTestExtractGeometryFilter.cxx + UnitTestExtractPointsFilter.cxx + UnitTestExtractStructuredFilter.cxx + UnitTestGhostCellRemove.cxx + UnitTestMaskFilter.cxx + UnitTestMaskPointsFilter.cxx + UnitTestThresholdFilter.cxx + UnitTestThresholdPointsFilter.cxx + ) + +set(libraries + vtkm_filter_clean_grid + vtkm_filter_entity_extraction + vtkm_source + ) + +vtkm_unit_tests( + SOURCES ${unit_tests} + LIBRARIES ${libraries} + USE_VTKM_JOB_POOL +) +``` + +## Testing if a module is being built + +The easiest way to test if a module is being built (in CMake) is to check +whether the associated target exists. + +``` cmake +if(TARGET vtkm_filter_entity_extraction) + # Do stuff dependent on vtkm_filter_entity_extraction library/module +endif() +``` + +Note that this only works in a module if the module properly depends on the +named target. It only works outside of modules if modules have already been +processed. + +## Debugging modules + +Because modules depend on each other, and these dependencies affect whether +a particular module will be built, it can sometimes be difficult to +understand why a particular module is or is not built. To help diagnose +problems with modules, you can turn on extra reporting with the +`VTKm_VERBOSE_MODULES` CMake variable. + +When `VTKm_VERBOSE_MODULES` is set to `OFF` (the default), then the parsing +and dependency resolution of the modules is silent unless there is an +error. When `VTKm_VERBOSE_MODULES` is set to `ON`, then information about +what modules are found, which modules are built, and why they are or are +not built are added as status messages during CMake configuration. diff --git a/docs/NewRelease.md.tmpl b/docs/NewRelease.md.tmpl new file mode 100644 index 000000000..4ce3d2423 --- /dev/null +++ b/docs/NewRelease.md.tmpl @@ -0,0 +1,287 @@ + +$py(VERSION=str(version.partition("-")[0]))\ +$py(MAJOR=int(VERSION.split(".")[0]))\ +$py(MINOR=int(VERSION.split(".")[1]))\ +$py(PATCH=int(VERSION.split(".")[2]))\ +$py(RC="".join(version.partition("-")[1:3]))\ +$if(PATCH == 0 and RC == "")\ +## Prerequisites + +- [ ] Make sure that the current VTK-m release branch builds in VTK. +- [ ] Make sure that the current VTK-m release branch builds in ECP Ascent. + +$endif\ +## Update VTK-m + +- [ ] Update `release` branch for **vtk-m** and create update branch +``` +git fetch origin +git checkout release +git merge --ff-only origin/release +git submodule update --recursive --init +``` +$if(PATCH == 0 and RC == "-rc1")\ +- [ ] Update `master` branch for **vtk-m** and create update branch +``` +git fetch origin +git checkout master +git merge --ff-only origin/master +git submodule update --recursive --init +``` +$endif\ + +## Create update branch + +- [ ] Create update branch `git checkout -b update-to-$(VERSION)` +$if(PATCH == 0 and RC == "-rc1")\ +- [ ] Bring as a second parent the history of master (Solve conflicts always + taking master's version) +``` +git merge --no-ff origin/master +``` +$else\ +- [ ] Backport merge-requests belonging to the milestone $(VERSION) +$endif\ +$if(PATCH == 0)\ +- [ ] Set version to master +``` +echo "$(MAJOR).$(MINOR).9999" > version.txt +git add version.txt +``` +$endif\ + +- [ ] Update the version (not in patch releases) and date in the LICENSE.md + file `git add LICENSE.md`. +- [ ] Create commit that updates the License (and version.txt if modified): +``` +git commit -m 'release: update version and License' +``` + + +- [ ] Craft or update [changelog](#generate-change-log) + `docs/changelog/$(VERSION)/release-notes.md` file. +- [ ] Create release notes commit. +``` +git add docs/changelog/$(MAJOR).$(MINOR)/release-notes.md +git rm docs/changelog/*.md +git commit -m 'release: $(VERSION)$(RC) release notes' +``` + +- [ ] Create update version commit: + +``` +echo $(VERSION)$(RC) > version.txt +git add version.txt + +# Create commit with the following template +# Nth is counted by the number of final release tags +git commit -m '$(VERSION)$(RC) is our Nth official release of VTK-m. + +The major changes to VTK-m from (previous release) can be found in: + docs/changelog/$(VERSION)/release-notes.md' version.txt +``` + +- [ ] `git tag -a -m 'VTKm $(VERSION)$(RC)' v$(VERSION)$(RC) HEAD` +- Integrate changes to `release` branch + - [ ] Create a MR using the [release-mr script][1] + (see [notes](#notes-about-update-mr)). +$if(PATCH == 0)\ + - [ ] Add (or ensure) at the bottom of the description of the merge request: + `Backport: master:HEAD~1` +$else\ + - [ ] Remove (or ensure) that at the bottom of the description of the merge + request there is no `Backport` instruction. +$endif\ + - [ ] Get +1 + - [ ] `Do: merge` +- Push tags + - [ ] `git push origin v$(VERSION)$(RC)` + +## Update Spack +- [ ] Update Spack package: https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/vtk-m/package.py + +## Post-release +$if(PATCH == 0 and RC == "-rc1")\ +- [ ] Create a release-specific branch of the previous major/minor release (Ask + @ben.boeckel). For more information on release-specific branch maintanance + schedule refer to `docs/ReleaseRoadmap.md`. +$endif\ +- [ ] Copy the contents of docs/changelog/$(VERSION)/release-notes.md to + the GitLab release. +$if(PATCH == 0 and RC == "")\ +- [ ] Tag new version of the [VTK-m User Guide][2]. +$endif\ +- [ ] Post an [Email Announcements](#email-announcements) VTK-m mailing list. +$if(RC == "")\ +- [ ] Update this release Date, Delay and End-of-Support fields in `docs/ReleaseRoadmap.md`. +$endif\ +$if(PATCH == 0)\ +- [ ] Ensure that the content of `version.txt` in master is `$(MAJOR).$(MINOR).9999`. +$endif\ + +## Update VTK-m in VTK + +VTK ships a particular VTK-m release in each of its releases, we need to open a +merge-request update the VTK-m commit in VTK as soon as possible even if the +newly VTK-m version does not correspond with the scheduled for the following VTK +release, the reason for opening the merge-request is that: + +- We can test how compatible it is with VTK giving us the change to address + those issues in the following releases. +- We do not forget to update VTK-m commit in VTK when the time comes + + - [ ] Update VTK-m submodule in VTK using: `git submodule update --remote` + +--- + +# Annex + +## Generate change log +Construct a `docs/changelog/$(VERSION)/` folder. +Construct a `docs/changelog/$(VERSION)/release-notes.md` file + +Use the following template for `release-notes.md`: + +```md +VTK-m N Release Notes +======================= + + + +| Merge request description | Merge request id | +| ------------------------------------------------------------------- | ---------------- | +| Update the link to register with the VTK-m dashboard | !2629 | +. +. +. +| CMAKE: CUDA ampere generate sm_80/86 | !2688 | + + + +# Table of Contents +1. [Core](#Core) + - Core change 1 +2. [ArrayHandle](#ArrayHandle) +3. [Control Environment](#Control-Environment) +4. [Execution Environment](#Execution-Environment) +5. [Worklets and Filters](#Worklets-and-Filters) +6. [Build](#Build) +7. [Other](#Other) + + +# Core + +## Core change 1 ## + +changes in core 1 + +# ArrayHandle + +# Control Enviornment + +# Execution Environment + +# Execution Environment + +# Worklets and Filters + +# Build + + +# Other +``` + +For each individual file in `docs/changelog` move them +to the relevant `release-notes` section. + + - Make sure each title and entry in the table of contents use full vtkm names + `vtkm::cont::Field` instead of Field. + - Make sure each title and entry DOESN'T have a period at the end. + - Make sure any sub-heading as part of the changelog is transformed from `##` + to `###`. + - Entries for `Core` are reserved for large changes that significantly improve + VTK-m users life, or are major breaking changes. + +## Notes about update-mr + +[`update-mr` script][1] has the following requirements to work: + +1. It needs a token to for authentication (reach @ben.boeckel for this) +2. It needs `kwrobot.release.vtkm` to have developer perms in your vtk-m repo. + +Lastly, `update-mr` can be used multiple times with different commit in the same +branch. + +## Notes about version.txt + +Master and release branch do not share the same version.txt scheme. In the +release branch the patch and release-candidate version is observed whereas in +master the patch field is fixed to _9999_ indicating that each of its commit is +a developing release. + +- Master: `$(MAJOR).$(MINOR).9999` +- Release: `$(MAJOR).$(MINOR).$(PATCH)$(RC)` + +## Email Announcements + +Announce the new VTK-m release on the mailing list. You will need to compute +the number of merge requests, changelog entries, and maybe # of authors. + +Example to compute the number of unique committers +``` +git log --format="%an" v1.4.0..v1.5.0 | sort -u | wc -l +``` + +Example to compute the number of merge requests +``` +git log v1.4.0..v1.5.0 | grep 'Merge | wc -l +``` + +A standard template to use is: + + +``` +Hi All, + +VTK-m 1.5.0 is now released, and a special thanks to everyone that has +contributed to VTK-m since our last release. The 1.5.0 release contains +over 100000 merge requests, and 100000 entries to the changelog . + +Below are all the entries in the changelog, with more details at ( +https://gitlab.kitware.com/vtk/vtk-m/-/tags/v$(VERSION)) or in the vtkm +repository at `docs/$(VERSION)/release-notes.md` + +$if(int(PATCH) > 0)\ +- Update the link to register with the VTK-m dashboard +. +. +. +- CMAKE: CUDA ampere generate sm_80/86 +$else\ +1. Core + - Core change 1 +2. ArrayHandle +3. Control Environment +4. Execution Environment +5. Worklets and Filters +6. Build +7. Other +$endif\ +``` + +[1]: https://gitlab.kitware.com/utils/release-utils/-/blob/master/release-mr.py +[2]: https://gitlab.kitware.com/vtk/vtk-m-user-guide + +@ben.boeckel +@vbolea +/label ~"area:release" +/milestone %"v$(VERSION)" +/assign @vbolea diff --git a/docs/ReleaseProcess.md b/docs/ReleaseProcess.md index 326cc855a..69136f47f 100644 --- a/docs/ReleaseProcess.md +++ b/docs/ReleaseProcess.md @@ -87,6 +87,9 @@ shown in here: # Get started with a new Release 1. Go to `https://gitlab.kitware.com/vtkm/vtk-m/` and open a new issue. -2. At the _issue template_ dropdown menu select: `NewRelease.md` -3. Now remove the comments and substitute the variables surrounded by `@`. -4. Post the issue and follow the steps. +2. Generate and copy to clipboard the release script (-rcN is optional): +``` +# Download pyexpander (Available in pip) +expander.py --eval 'version="X.Y.Z-rcN"' docs/NewRelease.md.tmpl | xclip -selection c +``` +3. Paste the output in the issue and follow the steps. diff --git a/docs/ReleaseRoadmap.md b/docs/ReleaseRoadmap.md index 0351d8b35..3dabc2978 100644 --- a/docs/ReleaseRoadmap.md +++ b/docs/ReleaseRoadmap.md @@ -4,7 +4,7 @@ | --------- | ------------ | ------- | ----------- | ---------------- | | 1.7.0 | 2021-12-01 | +8 | Long Term | 2022-12-01 | | 1.8.0 | 2022-06-01 | +14 | Long Term | 2023-06-01 | -| 1.9.0 | 2022-09-01 | | Short Term* | TBD | +| 1.9.0 | 2022-09-01 | +41 | Short Term | next release | | 2.0.0 | 2022-12-01 | | Long Term* | TBD | | 2.1.0 | 2023-03-01 | | Short Term* | TBD | | 2.2.0 | 2023-06-01 | | Long Term* | TBD | diff --git a/docs/changelog/benchmark-options.md b/docs/changelog/benchmark-options.md new file mode 100644 index 000000000..457226cb4 --- /dev/null +++ b/docs/changelog/benchmark-options.md @@ -0,0 +1,9 @@ +# More performance test options + +More options are available for adding performance regression tests. These +options allow you to pass custom options to the benchmark test so that you +are not limited to the default values. They also allow multiple tests to be +created from the same benchmark executable. Separating out the benchmarks +allows the null hypothesis testing to better catch performance problems +when only one of the tested filters regresses. It also allows passing +different arguments to different benchmarks. diff --git a/docs/changelog/build-modules.md b/docs/changelog/build-modules.md new file mode 100644 index 000000000..ea3a0db2e --- /dev/null +++ b/docs/changelog/build-modules.md @@ -0,0 +1,16 @@ +# Added modules to the build system + +VTK-m libraries and other targets can now be built as modules. The +advantage of modules is that you can selectively choose which +modules/libraries will be built. This makes it easy to create a more +stripped down compile of VTK-m. For example, you might want a reduced set +of libraries to save memory or you might want to turn off certain libraries +to save compile time. + +The module system will automatically determine dependencies among the +modules. It is capable of weakly turning off a module where it will still +be compiled if needed. Likewise, it is capabile of weakly turning on a +module where the build will still work if it cannot be created. + +The use of modules is described in the `Modules.md` file in the `docs` +directory of the VTK-m source. diff --git a/docs/changelog/cont-portal-token.md b/docs/changelog/cont-portal-token.md new file mode 100644 index 000000000..b666508f5 --- /dev/null +++ b/docs/changelog/cont-portal-token.md @@ -0,0 +1,21 @@ +# Support providing a Token to ReadPortal and WritePortal + +When managing portals in the execution environment, `ArrayHandle` uses the +`Token` object to ensure that the memory associated with a portal exists +for the length of time that it is needed. This is done by creating the +portal with a `Token` object, and the associated portal objects are +guaranteed to be valid while that `Token` object exists. This is supported +by essentially locking the array from further changes. + +`Token` objects are typically used when creating a control-side portal with +the `ReadPortal` or `WritePortal`. This is not to say that a `Token` would +not be useful; a control-side portal going out of scope is definitely a +problem. But the creation and distruction of portals in the control +environment is generally too much work for the possible benefits. + +However, under certain circumstances it could be useful to use a `Token` to +get a control-side portal. For example, if the `PrepareForExecution` method +of an `ExecutionObjectBase` needs to fill a small `ArrayHandle` on the +control side to pass to the execution side, it would be better to use the +provided `Token` object when doing so. This change allows you to optionally +provide that `Token` when creating these control-side portals. diff --git a/docs/changelog/coords-are-fields.md b/docs/changelog/coords-are-fields.md new file mode 100644 index 000000000..06d2261d1 --- /dev/null +++ b/docs/changelog/coords-are-fields.md @@ -0,0 +1,29 @@ +# Coordiante systems are stored as Fields + +Previously, `DataSet` managed `CoordinateSystem`s separately from `Field`s. +However, a `CoordinateSystem` is really just a `Field` with some special +attributes. Thus, coordiante systems are now just listed along with the +rest of the fields, and the coordinate systems are simply strings that +point back to the appropriate field. (This was actually the original +concept for `DataSet`, but the coordinate systems were separated from +fields for some now obsolete reasons.) + +This change should not be very noticible, but there are a few consequences +that should be noted. + +1. The `GetCoordinateSystem` methods no longer return a reference to a + `CoordinateSystem` object. This is because the `CoordinateSystem` object + is made on the fly from the field. +2. When mapping fields in filters, the coordinate systems get mapped as + part of this process. This has allowed us to remove some of the special + cases needed to set the coordinate system in the output. +3. If a filter is generating a coordinate system in a special way + (different than mapping other point fields), then it can use the special + `CreateResultCoordianteSystem` method to attach this custom coordinate + system to the output. +4. The `DataSet::GetCoordianteSystems()` method to get a `vector<>` of all + coordiante systems is removed. `DataSet` no longer internally has this + structure. Although it could be built, the only reason for its existance + was to support passing coordinate systems in filters. Now that this is + done autmoatically, the method is no longer needed. + diff --git a/docs/changelog/delete-deprecated.md b/docs/changelog/delete-deprecated.md new file mode 100644 index 000000000..bfcaf864c --- /dev/null +++ b/docs/changelog/delete-deprecated.md @@ -0,0 +1,7 @@ +# Delete deprecated features + +With the major release of VTK-m 2.0, we are cleaning up the code by +removing deprecated features. For software using VTK-m 1.9, you should have +gotten deprecation warnings about any feature that is removed. Thus, to +ease porting to VTK-m 2.0, software should consider updating to VTK-m 1.9 +first. diff --git a/docs/changelog/expose-variant.md b/docs/changelog/expose-variant.md new file mode 100644 index 000000000..8e7358a79 --- /dev/null +++ b/docs/changelog/expose-variant.md @@ -0,0 +1,12 @@ +# Expose the Variant helper class + +For several versions, VTK-m has had a `Variant` templated class. This acts +like a templated union where the object will store one of a list of types +specified as the template arguments. (There are actually 2 versions for the +control and execution environments, respectively.) + +Because this is a complex class that required several iterations to work +through performance and compiler issues, `Variant` was placed in the +`internal` namespace to avoid complications with backward compatibility. +However, the class has been stable for a while, so let us expose this +helpful tool for wider use. diff --git a/docs/changelog/external-lib-lists.md b/docs/changelog/external-lib-lists.md new file mode 100644 index 000000000..df29ab543 --- /dev/null +++ b/docs/changelog/external-lib-lists.md @@ -0,0 +1,11 @@ +# Output complete list of libraries for external Makefiles + +There is a Makefile include, `vtkm_config.mk`, and a package include, +`vtkm.pc`, that are configured so that external programs that do not use +CMake have a way of importing VTK-m's configuration. However, the set of +libraries was hardcoded. In particular, many of the new filter libraries +were missing. + +Rather than try to maintain this list manually, the new module mechanism +in the CMake configuration is used to get a list of libraries built and +automatically build these lists. diff --git a/docs/changelog/field-length-checking.md b/docs/changelog/field-length-checking.md new file mode 100644 index 000000000..e8624ed26 --- /dev/null +++ b/docs/changelog/field-length-checking.md @@ -0,0 +1,12 @@ +# Check to make sure that the fields in a DataSet are the proper length + +It is possible in a `DataSet` to add a point field (or coordinate system) +that has a different number of points than reported in the cell set. +Likewise for the number of cells in cell fields. This is very bad practice +because it is likely to lead to crashes in worklets that are expecting +arrays of an appropriate length. + +Although `DataSet` will still allow this, a warning will be added to the +VTK-m logging to alert users of the inconsistency introduced into the +`DataSet`. Since warnings are by default printed to standard error, users +are likely to see it. diff --git a/docs/changelog/ghost-cell-api.md b/docs/changelog/ghost-cell-api.md new file mode 100644 index 000000000..dbc937d10 --- /dev/null +++ b/docs/changelog/ghost-cell-api.md @@ -0,0 +1,5 @@ +# Change name of method to set the cell ghost levels in a DataSet + +Previously, the method was named `AddGhostCellField`. However, only one +ghost cell field can be marked at a time, so `SetGhostCellField` is more +appropriate. diff --git a/docs/changelog/ghost-cell-global-name.md b/docs/changelog/ghost-cell-global-name.md new file mode 100644 index 000000000..0dfbfc528 --- /dev/null +++ b/docs/changelog/ghost-cell-global-name.md @@ -0,0 +1,7 @@ +# Automatically make the fields with the global cell ghosts the cell ghosts + +Previously, if you added a cell field to a `DataSet` with a name that was +the same as that returned from `GetGlobalCellFieldName`, it was still only +recognized as a normal field. Now, that field is automatically recognized +as a the cell ghost levels (unless the global cell field name is changed or +a different field is explicitly set as the cell ghost levels). diff --git a/docs/changelog/hide-particle-members.md b/docs/changelog/hide-particle-members.md new file mode 100644 index 000000000..eeeaf4d9b --- /dev/null +++ b/docs/changelog/hide-particle-members.md @@ -0,0 +1,11 @@ +# Particle class members are hidden + +The member variables of the `vtkm::Particle` classes are now hidden. This +means that external code will not be directly able to access member +variables like `Pos`, `Time`, and `ID`. Instead, these need to be retrieved +and changed through accessor methods. + +This follows standard C++ principles. It also helps us future-proof the +classes. It means that we can provide subclasses or alternate forms of +`Particle` that operate differently. It also makes it possible to change +interfaces while maintaining a deprecated interface. diff --git a/docs/changelog/include-and-exclude-field-selection.md b/docs/changelog/include-and-exclude-field-selection.md new file mode 100644 index 000000000..a36fceaa3 --- /dev/null +++ b/docs/changelog/include-and-exclude-field-selection.md @@ -0,0 +1,21 @@ +# Allow FieldSelection to simultaneously include and exclude fields + +The basic use of `FieldSelection` is to construct the class with a mode +(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields +based off of this mode. This works fine for basic uses where the same code +that constructs a `FieldSelection` sets all the fields. + +But what happens, for example, if you have code that takes an existing +`FieldSelection` and wants to exclude the field named `foo`? If the +`FieldSelection` mode happens to be anything other than `Exclude`, the code +would have to go through several hoops to construct a new `FieldSelection` +object with this modified selection. + +To make this case easier, `FieldSelection` now has the ability to specify +the mode independently for each field. The `AddField` method now has an +optional mode argument the specifies whether the mode for that field should +be `Select` or `Exclude`. + +In the example above, the code can simply add the `foo` field with the +`Exclude` mode. Regardless of whatever state the `FieldSelection` was in +before, it will now report the `foo` field as not selected. diff --git a/docs/changelog/no-execution-whole-array.md b/docs/changelog/no-execution-whole-array.md new file mode 100644 index 000000000..d7eb97ba7 --- /dev/null +++ b/docs/changelog/no-execution-whole-array.md @@ -0,0 +1,18 @@ +# Removed ExecutionWholeArray class + +`ExecutionWholeArray` is an archaic class in VTK-m that is a thin wrapper +around an array portal. In the early days of VTK-m, this class was used to +transfer whole arrays to the execution environment. However, now the +supported method is to use `WholeArray*` tags in the `ControlSignature` of +a worklet. + +Nevertheless, the `WholeArray*` tags caused the array portal transferred to +the worklet to be wrapped inside of an `ExecutionWholeArray` class. This +is unnecessary and can cause confusion about the types of data being used. + +Most code is unaffected by this change. Some code that had to work around +the issue of the portal wrapped in another class used the `GetPortal` +method which is no longer needed (for obvious reasons). One extra feature +that `ExecutionWholeArray` had was that it provided an subscript operator +(somewhat incorrectly). Thus, any use of '[..]' to index the array portal +have to be changed to use the `Get` method. diff --git a/docs/changelog/particle-density-output-field.md b/docs/changelog/particle-density-output-field.md new file mode 100644 index 000000000..2ffb96ede --- /dev/null +++ b/docs/changelog/particle-density-output-field.md @@ -0,0 +1,7 @@ +# Correct particle density filter output field + +The field being created by `ParticleDensityNearestGridPoint` was supposed +to be associated with cells, but it was sized to the number of points. +Although the number of points will always be more than the number of cells +(so the array will be big enough), having inappropriately sized arrays can +cause further problems downstream. diff --git a/docs/changelog/partitioned-cell-locator.md b/docs/changelog/partitioned-cell-locator.md new file mode 100644 index 000000000..365fe9cf5 --- /dev/null +++ b/docs/changelog/partitioned-cell-locator.md @@ -0,0 +1,14 @@ +# New partitioned cell locator class + +A new version of a locator, `CellLocatorParitioned`, is now available. This version of a +locator takes a `PartitionedDataSet` and builds a structure that will find the partition Ids and +cell Ids for the input array of locations. It runs CellLocatorGeneral for each partition. We +expect multiple hits and only return the first one (lowest partition Id) where the detected cell +is of type REGULAR (no ghost, not blanked) in the vtkGhostType array. If this array does not +exist in a partition, we assume that all cells are regular. + +vtkm::cont::CellLocatorPartitioned produces an Arrayhandle of the size of the number of +partitions filled with the execution objects of CellLocatorGeneral. It further produces an +Arrayhandle filled with the ReadPortals of the vtkGhost arrays to then select the non-blanked +cells from the potentially multiple detected cells on the different partitions. Its counterpart +on the exec side, vtkm::exec::CellLocatorPartitioned, contains the actual FindCell function. diff --git a/docs/changelog/read-permuted-global-cell-ids.md b/docs/changelog/read-permuted-global-cell-ids.md new file mode 100644 index 000000000..ba07b5165 --- /dev/null +++ b/docs/changelog/read-permuted-global-cell-ids.md @@ -0,0 +1,8 @@ +# Fix reading global ids of permuted cells + +The legacy VTK reader sometimes has to permute cell data because some VTK +cells are not directly supported in VTK-m. (For example, triangle strips +are not supported. They have to be converted to triangles.) + +The global and petigree identifiers were not properly getting permuted. +This is now fixed. diff --git a/docs/changelog/remove-deprecated.md b/docs/changelog/remove-deprecated.md new file mode 100644 index 000000000..33b786dd1 --- /dev/null +++ b/docs/changelog/remove-deprecated.md @@ -0,0 +1,8 @@ +# Remove deprecated features from VTK-m + +With the major revision 2.0 of VTK-m, many items previously marked as +deprecated were removed. If updating to a new version of VTK-m, it is +recommended to first update to VTK-m 1.9, which will include the deprecated +features but provide warnings (with the right compiler) that will point to +the replacement code. Once the deprecations have been fixed, updating to +2.0 should be smoother. diff --git a/docs/changelog/rename-filter-base.md b/docs/changelog/rename-filter-base.md new file mode 100644 index 000000000..8185e5a88 --- /dev/null +++ b/docs/changelog/rename-filter-base.md @@ -0,0 +1,11 @@ +# Rename NewFilter base classes to Filter + +During the VTK-m 1.8 and 1.9 development, the filter infrastructure was +overhauled. Part of this created a completely new set of base classes. To +avoid confusion with the original filter base classes and ease transition, +the new filter base classes were named `NewFilter*`. Eventually after all +filters were transitioned, the old filter base classes were deprecated. + +With the release of VTK-m 2.0, the old filter base classes are removed. The +"new" filter base classes are no longer new. Thus, they have been renamed +simply `Filter` (and `FilterField`). diff --git a/docs/changelog/source-parameters.md b/docs/changelog/source-parameters.md new file mode 100644 index 000000000..f7c0aadec --- /dev/null +++ b/docs/changelog/source-parameters.md @@ -0,0 +1,8 @@ +# Setting source parameters is more clear + +Originally, most of the sources used constructor parameters to set the +various options of the source. Although convenient, it was difficult to +keep track of what each parameter meant. To make the code more clear, +source parameters are now set with accessor functions (e.g. +`SetPointDimensions`). Although this makes code more verbose, it helps +prevent mistakes and makes the changes more resilient to future changes. diff --git a/docs/changelog/tube-cell-fields.md b/docs/changelog/tube-cell-fields.md new file mode 100644 index 000000000..540e86a13 --- /dev/null +++ b/docs/changelog/tube-cell-fields.md @@ -0,0 +1,19 @@ +# Fix handling of cell fields in Tube filter + +The `Tube` filter wraps a tube of polygons around poly line cells. +During this process it had a strange (and wrong) handling of cell data. +It assumed that each line had an independent field entry for each +segment of each line. It thus had lots of extra code to find the length +and offsets of the segment data in the cell data. + +This is simply not how cell fields work in VTK-m. In VTK-m, each cell +has exactly one entry in the cell field array. Even if a polyline has +100 segments, it only gets one cell field value. This behavior is +consistent with how VTK treats cell field arrays. + +The behavior the `Tube` filter was trying to implement was closer to an +"edge" field. However, edge fields are currently not supported in VTK-m. +The proper implementation would be to add edge fields to VTK-m. (This +would also get around some problems with the implementation that was +removed here when mixing polylines with other cell types and degenerate +lines.) diff --git a/docs/changelog/vtkm-cmake-targets-namespaces.md b/docs/changelog/vtkm-cmake-targets-namespaces.md new file mode 100644 index 000000000..ad1101855 --- /dev/null +++ b/docs/changelog/vtkm-cmake-targets-namespaces.md @@ -0,0 +1,42 @@ +# VTK-m namespace for its exported CMake targets + +VTK-m exported CMake targets are now prefixed with the `vtkm::` namespace. + +## What it means for VTK-m users + +VTK-m users will now need to prepend a `vtkm::` prefix when they refer to a +VTK-m CMake target in their projects as shown below: + +``` +add_executable(example example.cxx) +# Before: +target_link_libraries(example vtkm_cont vtkm_rendering) +# Now: +target_link_libraries(example vtkm::cont vtkm::rendering) +``` + +For compatibility purposes we still provide additional exported targets with the +previous naming scheme, in the form of `vtkm_TARGET`, when VTK-m is found +using: + +``` +# With any version less than 2.0 +find_package(VTK-m 1.9) + +add_executable(example example.cxx) +# This is still valid +target_link_libraries(example vtkm_cont vtkm_rendering) +``` + +Use with care since we might remove those targets in future releases. + +## What it means for VTK-m developers + +While VTK-m exported targets are now prefixed with the `vtkm::` prefix, internal +target names are still in the form of `vtkm_TARGET`. + +To perform this name transformation in VTK-m targets a new CMake function has +been provided that decorates the canonical `install` routine. Use this functions +instead of `install` when creating new `VTK-m` targets, further information can +be found at the `vtkm_install_targets` function header at +`CMake/VTKmWrappers.cmake`. diff --git a/docs/changelog/zfp-output-fields.md b/docs/changelog/zfp-output-fields.md new file mode 100644 index 000000000..dced4dc5a --- /dev/null +++ b/docs/changelog/zfp-output-fields.md @@ -0,0 +1,8 @@ +# Attach compressed ZFP data as WholeDatSet field + +Previously, point fields compressed by ZFP were attached as point fields +on the output. However, using them as a point field would cause +problems. So, instead attache them as `WholeDataSet` fields. + +Also fixed a problem where the 1D decompressor created an output of the +wrong size. diff --git a/docs/perftest_arch.png b/docs/perftest_arch.png new file mode 100644 index 000000000..f35520092 Binary files /dev/null and b/docs/perftest_arch.png differ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 26b66c494..e291ee6a6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,10 +8,27 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -#add the directory that contains the VTK-m config file to the cmake -#path so that our examples can find VTK-m - if(VTKm_ENABLE_EXAMPLES) + # VTKm examples expects vtkm libraries to be namespaced with the prefix vtkm::. + # However as the examples are also built as just another part of the VTK-m code + # those prefix are not added to the targets (This happens during the + # installation). To workaround this issue here, we create IMPORTED libs linking + # to the vtkm libraries used by the examples with expected the vtkm:: prefix. + vtkm_module_get_list(module_list) + foreach(tgt IN LISTS module_list) + if(TARGET ${tgt}) + # The reason of creating this phony IMPORTED libraries instead of making + # ALIAS libraries is that ALIAS libraries are GLOBAL whereas IMPORTED are + # local at the directory level where they are created. We do not want these + # phony targets to be visible outside of the example directory. + vtkm_target_mangle(tgt_name_mangled ${tgt}) + add_library("vtkm::${tgt_name_mangled}" INTERFACE IMPORTED) + target_link_libraries("vtkm::${tgt_name_mangled}" INTERFACE ${tgt}) + endif() + endforeach() + + #add the directory that contains the VTK-m config file to the cmake + #path so that our examples can find VTK-m set(CMAKE_PREFIX_PATH ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}) add_subdirectory(clipping) add_subdirectory(contour_tree) diff --git a/examples/clipping/CMakeLists.txt b/examples/clipping/CMakeLists.txt index 6803d4d3d..d4e08d711 100644 --- a/examples/clipping/CMakeLists.txt +++ b/examples/clipping/CMakeLists.txt @@ -13,5 +13,7 @@ project(Clipping CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Clipping Clipping.cxx) -target_link_libraries(Clipping PRIVATE vtkm_filter vtkm_io) +if(TARGET vtkm::filter_contour AND TARGET vtkm::io) + add_executable(Clipping Clipping.cxx) + target_link_libraries(Clipping PRIVATE vtkm::filter_contour vtkm::io) +endif() diff --git a/examples/contour_tree/CMakeLists.txt b/examples/contour_tree/CMakeLists.txt index 87c403c21..94e4a9c74 100644 --- a/examples/contour_tree/CMakeLists.txt +++ b/examples/contour_tree/CMakeLists.txt @@ -13,8 +13,10 @@ project(ContourTree CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(ContourTreeMesh2D ContourTreeMesh2D.cxx) -target_link_libraries(ContourTreeMesh2D vtkm_filter) +if (TARGET vtkm::filter_scalar_topology) + add_executable(ContourTreeMesh2D ContourTreeMesh2D.cxx) + target_link_libraries(ContourTreeMesh2D vtkm::filter_core vtkm::filter_scalar_topology) -add_executable(ContourTreeMesh3D ContourTreeMesh3D.cxx) -target_link_libraries(ContourTreeMesh3D vtkm_filter) + add_executable(ContourTreeMesh3D ContourTreeMesh3D.cxx) + target_link_libraries(ContourTreeMesh3D vtkm::filter_core vtkm::filter_scalar_topology) +endif() diff --git a/examples/contour_tree_augmented/CMakeLists.txt b/examples/contour_tree_augmented/CMakeLists.txt index 103e42385..68a4d0bc5 100644 --- a/examples/contour_tree_augmented/CMakeLists.txt +++ b/examples/contour_tree_augmented/CMakeLists.txt @@ -55,11 +55,16 @@ cmake_minimum_required(VERSION 3.12...3.15 FATAL_ERROR) # Find the VTK-m package find_package(VTKm REQUIRED QUIET) +if(NOT TARGET vtkm::io OR NOT TARGET vtkm::filter_scalar_topology) + # Libraries needed are not built. + return() +endif() + #################################### # Serial #################################### add_executable(ContourTree_Augmented ContourTreeApp.cxx) -target_link_libraries(ContourTree_Augmented vtkm_filter vtkm_io) +target_link_libraries(ContourTree_Augmented vtkm::filter_scalar_topology vtkm::io) vtkm_add_target_information(ContourTree_Augmented DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) @@ -79,7 +84,7 @@ endif() #################################### if (VTKm_ENABLE_MPI) add_executable(ContourTree_Augmented_MPI ContourTreeApp.cxx) - target_link_libraries(ContourTree_Augmented_MPI vtkm_filter vtkm_io MPI::MPI_CXX) + target_link_libraries(ContourTree_Augmented_MPI vtkm::filter_scalar_topology vtkm::io MPI::MPI_CXX) vtkm_add_target_information(ContourTree_Augmented_MPI MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) diff --git a/examples/contour_tree_augmented/ContourTreeApp.cxx b/examples/contour_tree_augmented/ContourTreeApp.cxx index c85243745..6e50a24e7 100644 --- a/examples/contour_tree_augmented/ContourTreeApp.cxx +++ b/examples/contour_tree_augmented/ContourTreeApp.cxx @@ -64,7 +64,6 @@ #include #include #include -#include #include #include #include diff --git a/examples/contour_tree_distributed/CMakeLists.txt b/examples/contour_tree_distributed/CMakeLists.txt index 6c146ac3a..cfa47b349 100644 --- a/examples/contour_tree_distributed/CMakeLists.txt +++ b/examples/contour_tree_distributed/CMakeLists.txt @@ -58,9 +58,9 @@ find_package(VTKm REQUIRED QUIET) #################################### # MPI #################################### -if (VTKm_ENABLE_MPI) +if (VTKm_ENABLE_MPI AND TARGET vtkm::filter_scalar_topology AND TARGET vtkm::io) add_executable(ContourTree_Distributed ContourTreeApp.cxx) - target_link_libraries(ContourTree_Distributed vtkm_filter vtkm_io MPI::MPI_CXX) + target_link_libraries(ContourTree_Distributed vtkm::filter_scalar_topology vtkm::io MPI::MPI_CXX) vtkm_add_target_information(ContourTree_Distributed MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) @@ -78,11 +78,11 @@ if (VTKm_ENABLE_MPI) endif() add_executable(TreeCompiler TreeCompilerApp.cxx) - target_link_libraries(TreeCompiler vtkm_filter) + target_link_libraries(TreeCompiler vtkm::filter_core) vtkm_add_target_information(TreeCompiler DROP_UNUSED_SYMBOLS) add_executable(BranchCompiler BranchCompilerApp.cxx) - target_link_libraries(BranchCompiler vtkm_filter) + target_link_libraries(BranchCompiler vtkm::filter) vtkm_add_target_information(BranchCompiler DROP_UNUSED_SYMBOLS) configure_file(split_data_2d.py split_data_2d.py COPYONLY) diff --git a/examples/cosmotools/CMakeLists.txt b/examples/cosmotools/CMakeLists.txt index 1ac62ef8c..6a4ad951c 100644 --- a/examples/cosmotools/CMakeLists.txt +++ b/examples/cosmotools/CMakeLists.txt @@ -15,8 +15,8 @@ find_package(VTKm REQUIRED QUIET) add_executable(CosmoCenterFinder CosmoCenterFinder.cxx) add_executable(CosmoHaloFinder CosmoHaloFinder.cxx) -target_link_libraries(CosmoCenterFinder PRIVATE vtkm_filter) -target_link_libraries(CosmoHaloFinder PRIVATE vtkm_filter) +target_link_libraries(CosmoCenterFinder PRIVATE vtkm::filter_core) +target_link_libraries(CosmoHaloFinder PRIVATE vtkm::filter_core) vtkm_add_target_information(CosmoCenterFinder CosmoHaloFinder DROP_UNUSED_SYMBOLS diff --git a/examples/demo/CMakeLists.txt b/examples/demo/CMakeLists.txt index 4a247a340..d088a37cc 100644 --- a/examples/demo/CMakeLists.txt +++ b/examples/demo/CMakeLists.txt @@ -13,7 +13,7 @@ project(VTKmDemo CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_rendering) +if(TARGET vtkm::rendering AND TARGET vtkm::filter_contour AND TARGET vtkm::source) add_executable(Demo Demo.cxx) - target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering vtkm_source) + target_link_libraries(Demo PRIVATE vtkm::rendering vtkm::filter_contour vtkm::source) endif() diff --git a/examples/demo/Demo.cxx b/examples/demo/Demo.cxx index 0cde88203..08f32717d 100644 --- a/examples/demo/Demo.cxx +++ b/examples/demo/Demo.cxx @@ -34,7 +34,8 @@ int main(int argc, char* argv[]) { vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict); - auto tangle = vtkm::source::Tangle(vtkm::Id3{ 50, 50, 50 }); + vtkm::source::Tangle tangle; + tangle.SetPointDimensions({ 50, 50, 50 }); vtkm::cont::DataSet tangleData = tangle.Execute(); std::string fieldName = "tangle"; diff --git a/examples/game_of_life/CMakeLists.txt b/examples/game_of_life/CMakeLists.txt index c15a41642..61ade086c 100644 --- a/examples/game_of_life/CMakeLists.txt +++ b/examples/game_of_life/CMakeLists.txt @@ -19,7 +19,7 @@ if(TARGET OpenGL::GL AND TARGET GLEW::GLEW) add_executable(GameOfLife GameOfLife.cxx LoadShaders.h) - target_link_libraries(GameOfLife PRIVATE vtkm_filter OpenGL::GL GLEW::GLEW GLUT::GLUT) + target_link_libraries(GameOfLife PRIVATE vtkm::filter_core OpenGL::GL GLEW::GLEW GLUT::GLUT) vtkm_add_target_information(GameOfLife DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES GameOfLife.cxx) diff --git a/examples/game_of_life/GameOfLife.cxx b/examples/game_of_life/GameOfLife.cxx index dc27f532d..5302cdd52 100644 --- a/examples/game_of_life/GameOfLife.cxx +++ b/examples/game_of_life/GameOfLife.cxx @@ -26,7 +26,7 @@ #include -#include +#include #include #include @@ -95,7 +95,7 @@ struct UpdateLifeState : public vtkm::worklet::WorkletPointNeighborhood }; -class GameOfLife : public vtkm::filter::NewFilterField +class GameOfLife : public vtkm::filter::FilterField { public: VTKM_CONT GameOfLife() { this->SetActiveField("state", vtkm::cont::Field::Association::Points); } @@ -138,7 +138,7 @@ struct UploadData bool operator()(DeviceAdapterTag device) { vtkm::cont::ArrayHandle colors; - this->Colors.GetData().CopyTo(colors); + this->Colors.GetData().AsArrayHandle(colors); vtkm::interop::TransferToOpenGL(colors, *this->ColorState, device); return true; } @@ -316,8 +316,8 @@ int main(int argc, char** argv) vtkm::cont::DataSetBuilderUniform builder; vtkm::cont::DataSet data = builder.Create(vtkm::Id2(x, y)); - auto stateField = - vtkm::cont::make_Field("state", vtkm::cont::Field::Association::Points, input_state); + auto stateField = vtkm::cont::make_FieldMove( + "state", vtkm::cont::Field::Association::Points, std::move(input_state)); data.AddField(stateField); GameOfLife filter; diff --git a/examples/hello_worklet/CMakeLists.txt b/examples/hello_worklet/CMakeLists.txt index eff9dfcae..f5d87197f 100644 --- a/examples/hello_worklet/CMakeLists.txt +++ b/examples/hello_worklet/CMakeLists.txt @@ -13,9 +13,12 @@ project(HelloWorklet CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(HelloWorklet HelloWorklet.cxx) -target_link_libraries(HelloWorklet PRIVATE vtkm_filter vtkm_io) +if(TARGET vtkm::io) + add_executable(HelloWorklet HelloWorklet.cxx) + target_link_libraries(HelloWorklet PRIVATE vtkm::filter_core vtkm::io) -vtkm_add_target_information(HelloWorklet - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES HelloWorklet.cxx) + vtkm_add_target_information(HelloWorklet + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES HelloWorklet.cxx) +endif() diff --git a/examples/hello_worklet/HelloWorklet.cxx b/examples/hello_worklet/HelloWorklet.cxx index a21523cf9..8cfa49b9c 100644 --- a/examples/hello_worklet/HelloWorklet.cxx +++ b/examples/hello_worklet/HelloWorklet.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include #include @@ -43,7 +43,7 @@ namespace vtkm namespace filter { -class HelloField : public vtkm::filter::NewFilterField +class HelloField : public vtkm::filter::FilterField { public: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inDataSet) diff --git a/examples/histogram/CMakeLists.txt b/examples/histogram/CMakeLists.txt index 0667bf146..81210e81a 100644 --- a/examples/histogram/CMakeLists.txt +++ b/examples/histogram/CMakeLists.txt @@ -12,9 +12,12 @@ project(Histogram CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if (VTKm_ENABLE_MPI) +if (VTKm_ENABLE_MPI AND vtkm::filter_density_estimate) + # TODO: this example desperately needs to be updated. The histogram filter has + # improved immensely since this has originally been written, and the code can + # be simplified a lot, which will make it more illustrative of using VTK-m. add_executable(Histogram Histogram.cxx HistogramMPI.h HistogramMPI.cxx) - target_link_libraries(Histogram PRIVATE vtkm_filter MPI::MPI_CXX) + target_link_libraries(Histogram PRIVATE vtkm::filter_density_estimate MPI::MPI_CXX) vtkm_add_target_information(Histogram DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES HistogramMPI.cxx) diff --git a/examples/histogram/HistogramMPI.cxx b/examples/histogram/HistogramMPI.cxx index cb2a334c8..417638b37 100644 --- a/examples/histogram/HistogramMPI.cxx +++ b/examples/histogram/HistogramMPI.cxx @@ -160,7 +160,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet HistogramMPI::DoExecutePartitions( const vtkm::cont::PartitionedDataSet& input) { this->PreExecute(input); - auto result = this->NewFilter::DoExecutePartitions(input); + auto result = this->Filter::DoExecutePartitions(input); this->PostExecute(input, result); return result; } diff --git a/examples/histogram/HistogramMPI.h b/examples/histogram/HistogramMPI.h index 1205a982b..64fab32ae 100644 --- a/examples/histogram/HistogramMPI.h +++ b/examples/histogram/HistogramMPI.h @@ -10,7 +10,7 @@ #ifndef vtk_m_examples_histogram_HistogramMPI_h #define vtk_m_examples_histogram_HistogramMPI_h -#include +#include namespace example { @@ -19,7 +19,7 @@ namespace example /// /// Construct a HistogramMPI with a default of 10 bins. /// -class HistogramMPI : public vtkm::filter::NewFilterField +class HistogramMPI : public vtkm::filter::FilterField { public: //currently the HistogramMPI filter only works on scalar data. diff --git a/examples/ising/CMakeLists.txt b/examples/ising/CMakeLists.txt index 54b701734..b0c45c1ae 100644 --- a/examples/ising/CMakeLists.txt +++ b/examples/ising/CMakeLists.txt @@ -13,9 +13,12 @@ project(IsingModel CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Ising Ising.cxx) -target_link_libraries(Ising PRIVATE vtkm_worklet vtkm_io vtkm_rendering) +if(TARGET vtkm::rendering) + add_executable(Ising Ising.cxx) + target_link_libraries(Ising PRIVATE vtkm::worklet vtkm::rendering) -vtkm_add_target_information(Ising - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES Ising.cxx) + vtkm_add_target_information(Ising + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES Ising.cxx) +endif() diff --git a/examples/lagrangian/CMakeLists.txt b/examples/lagrangian/CMakeLists.txt index 72e3326df..341f78584 100644 --- a/examples/lagrangian/CMakeLists.txt +++ b/examples/lagrangian/CMakeLists.txt @@ -12,21 +12,7 @@ cmake_minimum_required(VERSION 3.12...3.15 FATAL_ERROR) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if ((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda)) - # CUDA architecture has a limited amount of memory available for constants. The CUDA - # compiler uses this space to hold constants for some optimizations. However, for large - # kernels, the number of constants needed might be larger than the constant space - # available. For these conditions, you have to disable this form of optimization with - # the -Xptxas --disable-optimizer-constants flags. - # TODO: Find a more elegant way to do this. Either figure out a way around this problem - # or add more general flags to vtkm_library/vtkm_unit_tests for sources with "large" kernels. - set_source_files_properties(lagrangian.cxx PROPERTIES - COMPILE_OPTIONS "-Xptxas;--disable-optimizer-constants" - ) +if(TARGET vtkm::filter_flow) + add_executable(Lagrangian lagrangian.cxx ABCfield.h) + target_link_libraries(Lagrangian PRIVATE vtkm::filter_flow) endif() - -add_executable(Lagrangian lagrangian.cxx ABCfield.h) -target_link_libraries(Lagrangian PRIVATE vtkm_filter) -vtkm_add_target_information(Lagrangian - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES lagrangian.cxx) diff --git a/examples/lagrangian/lagrangian.cxx b/examples/lagrangian/lagrangian.cxx index 561031cf5..d8f13250e 100644 --- a/examples/lagrangian/lagrangian.cxx +++ b/examples/lagrangian/lagrangian.cxx @@ -14,14 +14,13 @@ #include #include #include -#include #include #include #include using namespace std; -vtkm::cont::DataSet make3DRectilinearDataSet(double time) +vtkm::cont::DataSet make3DUniformDataSet(double time) { ABCfield field; @@ -86,7 +85,7 @@ int main(int argc, char** argv) lagrangianFilter.SetWriteFrequency(10); for (int i = 0; i < 100; i++) { - vtkm::cont::DataSet inputData = make3DRectilinearDataSet((double)i * stepSize); + vtkm::cont::DataSet inputData = make3DUniformDataSet((double)i * stepSize); lagrangianFilter.SetActiveField("velocity"); vtkm::cont::DataSet extractedBasisFlows = lagrangianFilter.Execute(inputData); } diff --git a/examples/lagrangian_structures/CMakeLists.txt b/examples/lagrangian_structures/CMakeLists.txt index a64aa0187..80406f8f3 100644 --- a/examples/lagrangian_structures/CMakeLists.txt +++ b/examples/lagrangian_structures/CMakeLists.txt @@ -16,7 +16,7 @@ project(ParticleAdvection CXX) find_package(VTKm REQUIRED QUIET) add_executable(ftle LagrangianStructures.cxx) -target_link_libraries(ftle PRIVATE vtkm_cont vtkm_worklet) +target_link_libraries(ftle PRIVATE vtkm::cont vtkm::worklet) vtkm_add_target_information(ftle DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES LagrangianStructures.cxx) diff --git a/examples/logistic_map/CMakeLists.txt b/examples/logistic_map/CMakeLists.txt index cffeabf72..0f478c640 100644 --- a/examples/logistic_map/CMakeLists.txt +++ b/examples/logistic_map/CMakeLists.txt @@ -12,9 +12,12 @@ project(LogisticMap CXX) find_package(VTKm REQUIRED QUIET) -add_executable(LogisticMap LogisticMap.cxx) -target_link_libraries(LogisticMap PRIVATE vtkm_io) +if(TARGET vtkm::io) + add_executable(LogisticMap LogisticMap.cxx) + target_link_libraries(LogisticMap PRIVATE vtkm::io) -vtkm_add_target_information(LogisticMap - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES LogisticMap.cxx) + vtkm_add_target_information(LogisticMap + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES LogisticMap.cxx) +endif() diff --git a/examples/mesh_quality/CMakeLists.txt b/examples/mesh_quality/CMakeLists.txt index 04fdafc7c..66abdb9ee 100644 --- a/examples/mesh_quality/CMakeLists.txt +++ b/examples/mesh_quality/CMakeLists.txt @@ -25,5 +25,7 @@ project(MeshQuality CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(MeshQuality MeshQuality.cxx) -target_link_libraries(MeshQuality PRIVATE vtkm_filter vtkm_io) +if(TARGET vtkm::filter_mesh_info AND TARGET vtkm::io) + add_executable(MeshQuality MeshQuality.cxx) + target_link_libraries(MeshQuality PRIVATE vtkm::filter_mesh_info vtkm::io) +endif() diff --git a/examples/multi_backend/CMakeLists.txt b/examples/multi_backend/CMakeLists.txt index 2a05508a5..67cdcba9f 100644 --- a/examples/multi_backend/CMakeLists.txt +++ b/examples/multi_backend/CMakeLists.txt @@ -26,8 +26,11 @@ set(srcs IOGenerator.cxx ) -add_executable(MultiBackend ${srcs} ${headers}) -target_link_libraries(MultiBackend PRIVATE vtkm_filter Threads::Threads) -vtkm_add_target_information(MultiBackend - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES ${srcs}) +if(TARGET vtkm::filter_vector_analysis) + add_executable(MultiBackend ${srcs} ${headers}) + target_link_libraries(MultiBackend PRIVATE vtkm::filter_vector_analysis Threads::Threads) + vtkm_add_target_information(MultiBackend + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES ${srcs}) +endif() diff --git a/examples/multi_backend/MultiDeviceGradient.h b/examples/multi_backend/MultiDeviceGradient.h index 30d1a026b..334873bb0 100644 --- a/examples/multi_backend/MultiDeviceGradient.h +++ b/examples/multi_backend/MultiDeviceGradient.h @@ -10,7 +10,7 @@ #ifndef vtk_m_examples_multibackend_MultiDeviceGradient_h #define vtk_m_examples_multibackend_MultiDeviceGradient_h -#include +#include #include "TaskQueue.h" @@ -22,7 +22,7 @@ using RuntimeTaskQueue = TaskQueue>; /// /// The Policy used with MultiDeviceGradient must include the TBB and CUDA /// backends. -class MultiDeviceGradient : public vtkm::filter::NewFilterField +class MultiDeviceGradient : public vtkm::filter::FilterField { public: //Construct a MultiDeviceGradient and worker pool diff --git a/examples/oscillator/CMakeLists.txt b/examples/oscillator/CMakeLists.txt index 04fd75427..fff62c3a8 100644 --- a/examples/oscillator/CMakeLists.txt +++ b/examples/oscillator/CMakeLists.txt @@ -13,5 +13,7 @@ project(Oscillator CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Oscillator Oscillator.cxx) -target_link_libraries(Oscillator PRIVATE vtkm_source) +if(TARGET vtkm::source) + add_executable(Oscillator Oscillator.cxx) + target_link_libraries(Oscillator PRIVATE vtkm::source) +endif() diff --git a/examples/oscillator/Oscillator.cxx b/examples/oscillator/Oscillator.cxx index 14e3c2428..93a6d04a3 100644 --- a/examples/oscillator/Oscillator.cxx +++ b/examples/oscillator/Oscillator.cxx @@ -313,7 +313,9 @@ int main(int argc, char** argv) if (generateOutput) { vtkm::cont::ArrayHandleBasic tmp; - rdata.GetField("oscillating", vtkm::cont::Field::Association::Points).GetData().CopyTo(tmp); + rdata.GetField("oscillating", vtkm::cont::Field::Association::Points) + .GetData() + .AsArrayHandle(tmp); const double* values = tmp.GetReadPointer(); writeData(outputDirectory, count++, sizeX, sizeY, sizeZ, values); } diff --git a/examples/particle_advection/CMakeLists.txt b/examples/particle_advection/CMakeLists.txt index 12a8ef3b3..d270561e2 100644 --- a/examples/particle_advection/CMakeLists.txt +++ b/examples/particle_advection/CMakeLists.txt @@ -13,5 +13,7 @@ project(ParticleAdvection CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Particle_Advection ParticleAdvection.cxx) -target_link_libraries(Particle_Advection PRIVATE vtkm_filter_flow vtkm_io) +if(TARGET vtkm::filter_flow AND TARGET vtkm::io) + add_executable(Particle_Advection ParticleAdvection.cxx) + target_link_libraries(Particle_Advection PRIVATE vtkm::filter_flow vtkm::io) +endif() diff --git a/examples/particle_advection/ParticleAdvection.cxx b/examples/particle_advection/ParticleAdvection.cxx index 64172d152..cc2885918 100644 --- a/examples/particle_advection/ParticleAdvection.cxx +++ b/examples/particle_advection/ParticleAdvection.cxx @@ -66,10 +66,10 @@ int main(int argc, char** argv) vtkm::FloatDefault rx = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX; vtkm::FloatDefault ry = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX; vtkm::FloatDefault rz = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX; - p.Pos[0] = static_cast(bounds.X.Min + rx * bounds.X.Length()); - p.Pos[1] = static_cast(bounds.Y.Min + ry * bounds.Y.Length()); - p.Pos[2] = static_cast(bounds.Z.Min + rz * bounds.Z.Length()); - p.ID = i; + p.SetPosition({ static_cast(bounds.X.Min + rx * bounds.X.Length()), + static_cast(bounds.Y.Min + ry * bounds.Y.Length()), + static_cast(bounds.Z.Min + rz * bounds.Z.Length()) }); + p.SetID(i); seeds.push_back(p); } auto seedArray = vtkm::cont::make_ArrayHandle(seeds, vtkm::CopyFlag::Off); diff --git a/examples/polyline_archimedean_helix/CMakeLists.txt b/examples/polyline_archimedean_helix/CMakeLists.txt index b5c720642..53852397b 100644 --- a/examples/polyline_archimedean_helix/CMakeLists.txt +++ b/examples/polyline_archimedean_helix/CMakeLists.txt @@ -11,10 +11,17 @@ cmake_minimum_required(VERSION 3.12...3.15 FATAL_ERROR) project(PolyLineArchimedeanHelix CXX) find_package(VTKm REQUIRED QUIET) -if (VTKm_ENABLE_RENDERING) - add_executable(PolyLineArchimedeanHelix PolyLineArchimedeanHelix.cxx) - target_link_libraries(PolyLineArchimedeanHelix PRIVATE vtkm_filter vtkm_rendering) - vtkm_add_target_information(PolyLineArchimedeanHelix - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES PolyLineArchimedeanHelix.cxx) + +if (TARGET vtkm::rendering) + # TODO: This example should be changed from using the Tube worklet to using + # the Tube filter (in the vtkm::filter_geometry_refinement library). Then + # compiling it would no longer require a device compiler and the example + # would generally be simpler. + add_executable(PolyLineArchimedeanHelix PolyLineArchimedeanHelix.cxx) + target_link_libraries(PolyLineArchimedeanHelix PRIVATE vtkm::rendering) + vtkm_add_target_information(PolyLineArchimedeanHelix + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES PolyLineArchimedeanHelix.cxx + ) endif() diff --git a/examples/redistribute_points/CMakeLists.txt b/examples/redistribute_points/CMakeLists.txt index 7b6561077..34a073e0a 100644 --- a/examples/redistribute_points/CMakeLists.txt +++ b/examples/redistribute_points/CMakeLists.txt @@ -12,11 +12,16 @@ project(RedistributePoints CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(RedistributePoints RedistributePoints.cxx RedistributePoints.h main.cxx) -target_link_libraries(RedistributePoints PRIVATE vtkm_filter vtkm_io) -vtkm_add_target_information(RedistributePoints - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES RedistributePoints.cxx) -set_property(TARGET RedistributePoints PROPERTY CUDA_VISIBILITY_PRESET "hidden") -set_property(TARGET RedistributePoints PROPERTY CXX_VISIBILITY_PRESET "hidden") +if(TARGET vtkm::io AND TARGET vtkm::filter_entity_extraction) + add_executable(RedistributePoints RedistributePoints.cxx RedistributePoints.h main.cxx) + target_link_libraries(RedistributePoints PRIVATE vtkm::io vtkm::filter_entity_extraction) + vtkm_add_target_information(RedistributePoints + DROP_UNUSED_SYMBOLS + MODIFY_CUDA_FLAGS + DEVICE_SOURCES RedistributePoints.cxx + ) + + set_property(TARGET RedistributePoints PROPERTY CUDA_VISIBILITY_PRESET "hidden") + set_property(TARGET RedistributePoints PROPERTY CXX_VISIBILITY_PRESET "hidden") +endif() diff --git a/examples/redistribute_points/RedistributePoints.h b/examples/redistribute_points/RedistributePoints.h index 11a82b7b2..2d293ee14 100644 --- a/examples/redistribute_points/RedistributePoints.h +++ b/examples/redistribute_points/RedistributePoints.h @@ -10,12 +10,12 @@ #ifndef example_RedistributePoints_h #define example_RedistributePoints_h -#include +#include namespace example { -class RedistributePoints : public vtkm::filter::NewFilter +class RedistributePoints : public vtkm::filter::Filter { public: VTKM_CONT RedistributePoints() {} diff --git a/examples/smoke_test/CMakeLists.txt b/examples/smoke_test/CMakeLists.txt index d51f8a543..d28f63352 100644 --- a/examples/smoke_test/CMakeLists.txt +++ b/examples/smoke_test/CMakeLists.txt @@ -14,10 +14,12 @@ include(CTest) find_package(VTKm REQUIRED) -add_executable(smoke_test smoke_test.cxx) -target_link_libraries(smoke_test PRIVATE vtkm_source) +if(TARGET vtkm::source) + add_executable(smoke_test smoke_test.cxx) + target_link_libraries(smoke_test PRIVATE vtkm::source) -# Only add this test when this an standalone project -if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - add_test(NAME SmokeTestInternal COMMAND ${CMAKE_BINARY_DIR}/smoke_test) + # Only add this test when this a standalone project + if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + add_test(NAME SmokeTestInternal COMMAND ${CMAKE_BINARY_DIR}/smoke_test) + endif() endif() diff --git a/examples/smoke_test/smoke_test.cxx b/examples/smoke_test/smoke_test.cxx index baf62cc13..b6d48d0c5 100644 --- a/examples/smoke_test/smoke_test.cxx +++ b/examples/smoke_test/smoke_test.cxx @@ -13,7 +13,7 @@ int main(int argc, char** argv) { - vtkm::cont::Initialize(argc, argv); + vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict); vtkm::source::Wavelet source; auto output = source.Execute(); diff --git a/examples/streamline_mpi/CMakeLists.txt b/examples/streamline_mpi/CMakeLists.txt index 5ce083ae3..8a298a146 100644 --- a/examples/streamline_mpi/CMakeLists.txt +++ b/examples/streamline_mpi/CMakeLists.txt @@ -13,8 +13,8 @@ project(StreamlineMPI CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if (VTKm_ENABLE_MPI) +if (VTKm_ENABLE_MPI AND TARGET vtkm::io AND TARGET vtkm::filter_flow) add_executable(StreamlineMPI StreamlineMPI.cxx) target_compile_definitions(StreamlineMPI PRIVATE "MPI_ENABLED") - target_link_libraries(StreamlineMPI PRIVATE vtkm_filter_flow vtkm_io MPI::MPI_CXX) + target_link_libraries(StreamlineMPI PRIVATE vtkm::filter_flow vtkm::io MPI::MPI_CXX) endif() diff --git a/examples/temporal_advection/CMakeLists.txt b/examples/temporal_advection/CMakeLists.txt index eeed9ff44..6a2abfdf0 100644 --- a/examples/temporal_advection/CMakeLists.txt +++ b/examples/temporal_advection/CMakeLists.txt @@ -15,8 +15,10 @@ project(TemporalAdvection CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Temporal_Advection TemporalAdvection.cxx) -vtkm_add_target_information(Temporal_Advection - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES TemporalAdvection.cxx) -target_link_libraries(Temporal_Advection PRIVATE vtkm_filter vtkm_io) +if(TARGET vtkm::filter_flow AND TARGET vtkm::io) + add_executable(Temporal_Advection TemporalAdvection.cxx) + vtkm_add_target_information(Temporal_Advection + DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS + DEVICE_SOURCES TemporalAdvection.cxx) + target_link_libraries(Temporal_Advection PRIVATE vtkm::filter_flow vtkm::io) +endif() diff --git a/examples/temporal_advection/TemporalAdvection.cxx b/examples/temporal_advection/TemporalAdvection.cxx index 141833e6b..bb765dda2 100644 --- a/examples/temporal_advection/TemporalAdvection.cxx +++ b/examples/temporal_advection/TemporalAdvection.cxx @@ -87,8 +87,8 @@ int main(int argc, char** argv) for (vtkm::Id i = 0; i < numPts; i++) { vtkm::Particle p; - p.Pos = ptsPortal.Get(i); - p.ID = i; + p.SetPosition(ptsPortal.Get(i)); + p.SetID(i); seedPortal.Set(i, p); } diff --git a/examples/tetrahedra/CMakeLists.txt b/examples/tetrahedra/CMakeLists.txt index 633af87e2..efc3630ad 100644 --- a/examples/tetrahedra/CMakeLists.txt +++ b/examples/tetrahedra/CMakeLists.txt @@ -13,8 +13,10 @@ project(Tetrahedra CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -add_executable(Tetrahedralize Tetrahedralize.cxx) -target_link_libraries(Tetrahedralize PRIVATE vtkm_filter vtkm_io) +if(TARGET vtkm::filter_geometry_refinement AND TARGET vtkm::io) + add_executable(Tetrahedralize Tetrahedralize.cxx) + target_link_libraries(Tetrahedralize PRIVATE vtkm::filter_geometry_refinement vtkm::io) -add_executable(Triangulate Triangulate.cxx) -target_link_libraries(Triangulate PRIVATE vtkm_filter vtkm_io) + add_executable(Triangulate Triangulate.cxx) + target_link_libraries(Triangulate PRIVATE vtkm::filter_geometry_refinement vtkm::io) +endif() diff --git a/tutorial/extract_edges.cxx b/tutorial/extract_edges.cxx index ee31224ed..7f236cac9 100644 --- a/tutorial/extract_edges.cxx +++ b/tutorial/extract_edges.cxx @@ -20,9 +20,9 @@ #include #include +#include #include #include -#include #include #include @@ -149,7 +149,7 @@ VTKM_CONT bool DoMapField( } // anonymous namespace -class ExtractEdges : public vtkm::filter::NewFilter +class ExtractEdges : public vtkm::filter::Filter { public: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; @@ -195,7 +195,7 @@ VTKM_CONT vtkm::cont::DataSet ExtractEdges::DoExecute(const vtkm::cont::DataSet& auto mapper = [&](auto& outDataSet, const auto& f) { DoMapField(outDataSet, f, outputToInputCellMap, cellToEdgeKeys); }; - return this->CreateResult(inData, outCellSet, inData.GetCoordinateSystems(), mapper); + return this->CreateResult(inData, outCellSet, mapper); } int main(int argc, char** argv) diff --git a/tutorial/mag_grad.cxx b/tutorial/mag_grad.cxx index 72e7eaa0d..793e258ff 100644 --- a/tutorial/mag_grad.cxx +++ b/tutorial/mag_grad.cxx @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ struct ComputeMagnitude : vtkm::worklet::WorkletMapField // The filter class used by external code to run the algorithm. Normally the class definition // is in a separate header file. -class FieldMagnitude : public vtkm::filter::NewFilterField +class FieldMagnitude : public vtkm::filter::FilterField { protected: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inDataSet) override; diff --git a/tutorial/point_to_cell.cxx b/tutorial/point_to_cell.cxx index d639b299a..acf9ee1dd 100644 --- a/tutorial/point_to_cell.cxx +++ b/tutorial/point_to_cell.cxx @@ -46,14 +46,14 @@ struct ConvertPointFieldToCells : vtkm::worklet::WorkletVisitCellsWithPoints } // namespace worklet } // namespace vtkm -#include +#include namespace vtkm { namespace filter { -struct ConvertPointFieldToCells : vtkm::filter::NewFilterField +struct ConvertPointFieldToCells : vtkm::filter::FilterField { VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inDataSet) override; }; diff --git a/version.txt b/version.txt index f8e233b27..4be1db033 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.0 +1.9.9999 diff --git a/vtkm/Algorithms.h b/vtkm/Algorithms.h deleted file mode 100644 index 034bc36e4..000000000 --- a/vtkm/Algorithms.h +++ /dev/null @@ -1,79 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_Algorithms_h -#define vtk_m_Algorithms_h - -#include -#include -#include - -namespace vtkm -{ - -VTKM_DEPRECATED(1.7, "Use LowerBound.h, or UpperBound.h instead of Algorithms.h.") -inline void Algorithms_h_deprecated() {} - -inline void ActivateAlgorithms_h_deprecated_warning() -{ - Algorithms_h_deprecated(); -} - -template -VTKM_DEPRECATED(1.7, "Use LowerBound or UpperBound instead of BinarySearch.") -VTKM_EXEC_CONT IterT BinarySearch(IterT first, IterT last, const T& val, Comp comp) -{ - IterT found = vtkm::LowerBound(first, last, val, comp); - if ((found == last) || comp(val, *found) || comp(*found, val)) - { - // Element is not actually in the array - return last; - } - else - { - return found; - } -} - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -template -VTKM_DEPRECATED(1.7, "Use LowerBound or UpperBound instead of BinarySearch.") -VTKM_EXEC_CONT IterT BinarySearch(IterT first, IterT last, const T& val) -{ - return vtkm::BinarySearch(first, last, val, vtkm::SortLess{}); -} - -template -VTKM_DEPRECATED(1.7, "Use LowerBound or UpperBound instead of BinarySearch.") -VTKM_EXEC_CONT vtkm::Id BinarySearch(const PortalT& portal, const T& val, Comp comp) -{ - auto first = vtkm::cont::ArrayPortalToIteratorBegin(portal); - auto last = vtkm::cont::ArrayPortalToIteratorEnd(portal); - auto result = vtkm::BinarySearch(first, last, val, comp); - return result == last ? static_cast(-1) : static_cast(result - first); -} - -// Return -1 if not found -template -VTKM_DEPRECATED(1.7, "Use LowerBound or UpperBound instead of BinarySearch.") -VTKM_EXEC_CONT vtkm::Id BinarySearch(const PortalT& portal, const T& val) -{ - auto first = vtkm::cont::ArrayPortalToIteratorBegin(portal); - auto last = vtkm::cont::ArrayPortalToIteratorEnd(portal); - auto result = vtkm::BinarySearch(first, last, val, vtkm::SortLess{}); - return result == last ? static_cast(-1) : static_cast(result - first); -} - -VTKM_DEPRECATED_SUPPRESS_END - -} // end namespace vtkm - -#endif // vtk_m_Algorithms_h diff --git a/vtkm/Bounds.h b/vtkm/Bounds.h index 9ef8de5c4..6cd30034b 100644 --- a/vtkm/Bounds.h +++ b/vtkm/Bounds.h @@ -149,6 +149,22 @@ struct Bounds return vtkm::Vec3f_64(this->X.Center(), this->Y.Center(), this->Z.Center()); } + /// \b Returns the min point of the bounds + /// + /// \c MinCorder returns the minium point of the bounds.If the bounds + /// are empty, the results are undefined. + /// + VTKM_EXEC_CONT + vtkm::Vec3f_64 MinCorner() const { return vtkm::Vec3f_64(this->X.Min, this->Y.Min, this->Z.Min); } + + /// \b Returns the max point of the bounds + /// + /// \c MaxCorder returns the minium point of the bounds.If the bounds + /// are empty, the results are undefined. + /// + VTKM_EXEC_CONT + vtkm::Vec3f_64 MaxCorner() const { return vtkm::Vec3f_64(this->X.Max, this->Y.Max, this->Z.Max); } + /// \b Expand bounds to include a point. /// /// This version of \c Include expands the bounds just enough to include the diff --git a/vtkm/CMakeLists.txt b/vtkm/CMakeLists.txt index 4c53caf3b..dc88e725d 100644 --- a/vtkm/CMakeLists.txt +++ b/vtkm/CMakeLists.txt @@ -17,7 +17,6 @@ vtkm_install_headers( vtkm ${VTKm_BINARY_INCLUDE_DIR}/${kit_dir}/Version.h) set(headers - Algorithms.h # Deprecated, split into LowerBound.h, UpperBound.h Assert.h Atomic.h BinaryPredicates.h @@ -34,7 +33,6 @@ set(headers Hash.h ImplicitFunction.h List.h - ListTag.h # Deprecated, replaced by List.h LowerBound.h Math.h Matrix.h @@ -51,18 +49,15 @@ set(headers Transform3D.h Tuple.h TypeList.h - TypeListTag.h # Deprecated, replaced by TypeList.h Types.h TypeTraits.h VecAxisAlignedPointCoordinates.h VecFromPortal.h VecFromPortalPermute.h - VecFromVirtPortal.h VectorAnalysis.h VecFlat.h VecTraits.h VecVariable.h - VirtualObjectBase.h UnaryPredicates.h UpperBound.h ) @@ -79,46 +74,11 @@ vtkm_declare_headers( ${template_sources} ) -#----------------------------------------------------------------------------- -#first add all the components vtkm that are shared between control and exec -add_subdirectory(thirdparty/diy) -add_subdirectory(thirdparty/lodepng) -if(VTKm_ENABLE_LOGGING) - add_subdirectory(thirdparty/loguru) -endif() -add_subdirectory(thirdparty/optionparser) -add_subdirectory(thirdparty/lcl) +# Declare testing headers to install. (Needs to be special because they are in a different dir.) +set(testing_headers + testing/Testing.h + testing/VecTraitsTests.h + ) +vtkm_install_headers(${kit_dir}/testing ${testing_headers}) -if(VTKm_ENABLE_TESTING_LIBRARY) - add_subdirectory(testing) -endif() add_subdirectory(internal) - -#----------------------------------------------------------------------------- -#add the control and exec folders -add_subdirectory(cont) -add_subdirectory(exec) - -#----------------------------------------------------------------------------- -#add the worklet folder -add_subdirectory(worklet) - -#----------------------------------------------------------------------------- -#add the filter folder -add_subdirectory(filter) - -#----------------------------------------------------------------------------- -# Build rendering -add_subdirectory(rendering) - -add_subdirectory(interop) - -#----------------------------------------------------------------------------- -#add the io folder -add_subdirectory(io) - -#add the source folder -add_subdirectory(source) - -#add Pseudo Random Number Generator folder -add_subdirectory(random) diff --git a/vtkm/CellClassification.h b/vtkm/CellClassification.h index c9a068ae3..6f001c9a7 100644 --- a/vtkm/CellClassification.h +++ b/vtkm/CellClassification.h @@ -10,7 +10,6 @@ #ifndef vtk_m_CellClassification_h #define vtk_m_CellClassification_h -#include #include namespace vtkm @@ -45,15 +44,6 @@ public: Unused3 = 1 << 4, Unused4 = 1 << 5, Unused5 = 1 << 6, - - NORMAL VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Normal") = Normal, - GHOST VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Ghost") = Ghost, - INVALID VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Invalid") = Invalid, - UNUSED0 VTKM_DEPRECATED(1.8) = Unused0, - BLANKED VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Blanked") = Blanked, - UNUSED3 VTKM_DEPRECATED(1.8) = Unused3, - UNUSED4 VTKM_DEPRECATED(1.8) = Unused4, - UNUSED5 VTKM_DEPRECATED(1.8) = Unused5, }; VTKM_EXEC constexpr CellClassification(vtkm::UInt8 flags = vtkm::UInt8{ Normal }) @@ -64,16 +54,6 @@ public: VTKM_EXEC constexpr operator vtkm::UInt8() const { return this->Flags; } }; -// Deprecated scoping. -VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Normal.") -constexpr vtkm::CellClassification NORMAL = vtkm::CellClassification::Normal; -VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Ghost.") -constexpr vtkm::CellClassification GHOST = vtkm::CellClassification::Ghost; -VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Invalid.") -constexpr vtkm::CellClassification INVALID = vtkm::CellClassification::Invalid; -VTKM_DEPRECATED(1.8, "Use vtkm::CellClassification::Blanked.") -constexpr vtkm::CellClassification BLANKED = vtkm::CellClassification::Blanked; - } // namespace vtkm #endif // vtk_m_CellClassification_h diff --git a/vtkm/ImplicitFunction.h b/vtkm/ImplicitFunction.h index 59472c211..993c46eb3 100644 --- a/vtkm/ImplicitFunction.h +++ b/vtkm/ImplicitFunction.h @@ -11,48 +11,17 @@ #define vtk_m_ImplicitFunction_h #include -#include #include #include -#include +#include // For interface class only. #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif // VTKM_NO_DEPRECATED_VIRTUAL - namespace vtkm { -//============================================================================ -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN -class VTKM_DEPRECATED(1.6, "ImplicitFunction with virtual methods no longer supported.") - VTKM_ALWAYS_EXPORT ImplicitFunction : public vtkm::VirtualObjectBase -{ -public: - using Scalar = vtkm::FloatDefault; - using Vector = vtkm::Vec; - - VTKM_EXEC_CONT virtual Scalar Value(const Vector& point) const = 0; - VTKM_EXEC_CONT virtual Vector Gradient(const Vector& point) const = 0; - - VTKM_EXEC_CONT Scalar Value(Scalar x, Scalar y, Scalar z) const - { - return this->Value(Vector(x, y, z)); - } - - VTKM_EXEC_CONT Vector Gradient(Scalar x, Scalar y, Scalar z) const - { - return this->Gradient(Vector(x, y, z)); - } -}; -VTKM_DEPRECATED_SUPPRESS_END -#endif // VTKM_NO_DEPRECATED_VIRTUAL - //============================================================================ namespace internal { @@ -93,73 +62,6 @@ public: } // namespace vtkm::internal -//============================================================================ -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN - -/// A helpful functor that calls the (virtual) value method of a given ImplicitFunction. Can be -/// passed to things that expect a functor instead of an ImplictFunction class (like an array -/// transform). -/// -class VTKM_DEPRECATED(1.6, - "Use ImplicitFunctionValueFunctor.") VTKM_ALWAYS_EXPORT ImplicitFunctionValue -{ -public: - using Scalar = vtkm::ImplicitFunction::Scalar; - using Vector = vtkm::ImplicitFunction::Vector; - - VTKM_EXEC_CONT ImplicitFunctionValue() - : Function(nullptr) - { - } - - VTKM_EXEC_CONT ImplicitFunctionValue(const ImplicitFunction* function) - : Function(function) - { - } - - VTKM_EXEC_CONT Scalar operator()(const Vector& point) const - { - return this->Function->Value(point); - } - -private: - const vtkm::ImplicitFunction* Function; -}; - -/// A helpful functor that calls the (virtual) gradient method of a given ImplicitFunction. Can be -/// passed to things that expect a functor instead of an ImplictFunction class (like an array -/// transform). -/// -class VTKM_DEPRECATED(1.6, "Use ImplicitFunctionGradientFunctor.") - VTKM_ALWAYS_EXPORT ImplicitFunctionGradient -{ -public: - using Scalar = vtkm::ImplicitFunction::Scalar; - using Vector = vtkm::ImplicitFunction::Vector; - - VTKM_EXEC_CONT ImplicitFunctionGradient() - : Function(nullptr) - { - } - - VTKM_EXEC_CONT ImplicitFunctionGradient(const ImplicitFunction* function) - : Function(function) - { - } - - VTKM_EXEC_CONT Vector operator()(const Vector& point) const - { - return this->Function->Gradient(point); - } - -private: - const vtkm::ImplicitFunction* Function; -}; - -VTKM_DEPRECATED_SUPPRESS_END -#endif // VTKM_NO_DEPRECATED_VIRTUAL - //============================================================================ /// A helpful functor that calls the value method of a given `ImplicitFunction`. Can be /// passed to things that expect a functor instead of an `ImplictFunction` class (like an array @@ -470,11 +372,6 @@ public: return normal; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC Box* operator->() { return this; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC const Box* operator->() const { return this; } - private: Vector MinPoint; Vector MaxPoint; @@ -538,11 +435,6 @@ public: return (point - closestPoint) * FloatDefault(2); } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC Cylinder* operator->() { return this; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC const Cylinder* operator->() const { return this; } - private: Vector Center; Vector Axis; @@ -651,11 +543,6 @@ public: return this->Normals[maxValIdx]; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC Frustum* operator->() { return this; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC const Frustum* operator->() const { return this; } - private: Vector Points[6] = { { -0.5f, 0.0f, 0.0f }, { 0.5f, 0.0f, 0.0f }, { 0.0f, -0.5f, 0.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, 0.5f } }; @@ -708,11 +595,6 @@ public: VTKM_EXEC_CONT Vector Gradient(const Vector&) const { return this->Normal; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC Plane* operator->() { return this; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC const Plane* operator->() const { return this; } - private: Vector Origin; Vector Normal; @@ -767,11 +649,6 @@ public: return Scalar(2) * (point - this->Center); } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC Sphere* operator->() { return this; } - VTKM_DEPRECATED(1.6, "ImplicitFunctions are no longer pointers. Use . operator.") - VTKM_EXEC const Sphere* operator->() const { return this; } - private: Scalar Radius; Vector Center; @@ -826,7 +703,7 @@ class ImplicitFunctionMultiplexer : public vtkm::internal::ImplicitFunctionBase< ImplicitFunctionMultiplexer> { - vtkm::exec::internal::Variant Variant; + vtkm::exec::Variant Variant; using Superclass = vtkm::internal::ImplicitFunctionBase>; diff --git a/vtkm/List.h b/vtkm/List.h index c9686f6fb..52c17845d 100644 --- a/vtkm/List.h +++ b/vtkm/List.h @@ -36,23 +36,13 @@ struct List VTKM_CHECK_LIST_SIZE(sizeof...(Ts)); }; -namespace detail -{ - -// This prototype is here to detect deprecated ListTag objects. When ListTags are removed, then -// this should be removed too. -struct ListRoot; -} - namespace internal { template struct IsListImpl { - // This prototype is here to detect deprecated ListTag objects. When ListTags are removed, then - // this should be changed to be just std::false_type. - using type = std::is_base_of; + using type = std::false_type; }; template @@ -88,25 +78,6 @@ struct UniversalTypeTag } // namespace detail -namespace internal -{ - -// This is here so that the old (deprecated) `ListTag`s can convert themselves to the new -// `List` style and be operated on. When that deprecated functionality goes away, we can -// probably remove `AsList` and just operate directly on the `List`s. -template -struct AsListImpl; - -template -struct AsListImpl> -{ - using type = vtkm::List; -}; - -template -using AsList = typename AsListImpl::type; -} - /// A special tag for an empty list. /// using ListEmpty = vtkm::List<>; @@ -134,7 +105,7 @@ struct ListSizeImpl> /// Becomes an std::integral_constant containing the number of types in a list. /// template -using ListSize = typename detail::ListSizeImpl>::type; +using ListSize = typename detail::ListSizeImpl::type; namespace detail { @@ -158,7 +129,7 @@ struct ListApplyImpl; /// represented by the ListTag. /// template class Target> -using ListApply = typename detail::ListApplyImpl, Target>::type; +using ListApply = typename detail::ListApplyImpl::type; namespace detail { @@ -301,7 +272,7 @@ struct ListAppendImpl, /// /// Note that this does not work correctly with `vtkm::ListUniversal`. template -using ListAppend = typename detail::ListAppendImpl...>::type; +using ListAppend = typename detail::ListAppendImpl::type; namespace detail { @@ -370,7 +341,7 @@ struct ListAtImpl, Index> /// This becomes the type of the list at the given index. /// template -using ListAt = typename detail::ListAtImpl, Index>::type; +using ListAt = typename detail::ListAtImpl::type; namespace detail { @@ -573,7 +544,7 @@ struct ListIndexOfImpl /// given type is not in the list, the value is set to -1. /// template -using ListIndexOf = typename detail::ListIndexOfImpl, T>::type; +using ListIndexOf = typename detail::ListIndexOfImpl::type; namespace detail { @@ -597,7 +568,7 @@ struct ListHasImpl /// Becomes `std::true_type` if the `T` is in `List`. `std::false_type` otherwise. /// template -using ListHas = typename detail::ListHasImpl, T>::type; +using ListHas = typename detail::ListHasImpl::type; namespace detail { @@ -618,7 +589,7 @@ struct ListTransformImpl; /// Constructs a list containing all types in a source list applied to a transform template. /// template class Transform> -using ListTransform = typename detail::ListTransformImpl, Transform>::type; +using ListTransform = typename detail::ListTransformImpl::type; namespace detail { @@ -700,7 +671,7 @@ struct ListRemoveIfImpl, Predicate> /// `std::is_integral` and `std::is_integral` resolve to `std::false_type`. /// template class Predicate> -using ListRemoveIf = typename detail::ListRemoveIfImpl, Predicate>::type; +using ListRemoveIf = typename detail::ListRemoveIfImpl::type; namespace detail { @@ -738,50 +709,27 @@ struct ListIntersectImpl /// Constructs a list containing types present in all lists. /// template -using ListIntersect = - typename detail::ListIntersectImpl, internal::AsList>::type; - -namespace detail -{ - -// We want to use an initializer list as a trick to call a function once for each type, but -// an initializer list needs a type, so create wrapper function that returns a value. -VTKM_SUPPRESS_EXEC_WARNINGS -template -VTKM_EXEC_CONT inline bool ListForEachCallThrough(Functor&& f, Args&&... args) -{ - f(std::forward(args)...); - return false; // Return value does not matter. Hopefully just thrown away. -} - -VTKM_SUPPRESS_EXEC_WARNINGS -template -VTKM_EXEC_CONT void ListForEachImpl(Functor&& f, vtkm::List, Args&&... args) -{ - VTKM_STATIC_ASSERT_MSG((!std::is_same, vtkm::ListUniversal>::value), - "Cannot call ListFor on vtkm::ListUniversal."); - auto init_list = { ListForEachCallThrough( - std::forward(f), Ts{}, std::forward(args)...)... }; - (void)init_list; -} - -template -VTKM_EXEC_CONT void ListForEachImpl(Functor&&, vtkm::ListEmpty, Args&&...) -{ - // No types to run functor on. -} - -} // namespace detail +using ListIntersect = typename detail::ListIntersectImpl::type; +///@{ /// For each typename represented by the list, call the functor with a /// default instance of that type. /// -template -VTKM_EXEC_CONT void ListForEach(Functor&& f, List, Args&&... args) +VTKM_SUPPRESS_EXEC_WARNINGS +template +VTKM_EXEC_CONT void ListForEach(Functor&& f, vtkm::List, Args&&... args) { - detail::ListForEachImpl( - std::forward(f), internal::AsList{}, std::forward(args)...); + VTKM_STATIC_ASSERT_MSG((!std::is_same, vtkm::ListUniversal>::value), + "Cannot call ListFor on vtkm::ListUniversal."); + auto init_list = { (f(Ts{}, std::forward(args)...), false)... }; + (void)init_list; } +template +VTKM_EXEC_CONT void ListForEach(Functor&&, vtkm::ListEmpty, Args&&...) +{ + // No types to run functor on. +} +///@} namespace detail { @@ -808,8 +756,7 @@ struct ListCrossImpl, vtkm::List> /// The resulting list has the form of `vtkm::List, vtkm::List,...>` /// template -using ListCross = - typename detail::ListCrossImpl, internal::AsList>::type; +using ListCross = typename detail::ListCrossImpl::type; namespace detail { @@ -865,7 +812,7 @@ struct ListReduceImpl, Ope /// This continues until a single value is left. /// template class Operator, typename Initial> -using ListReduce = typename detail::ListReduceImpl, Operator, Initial>::type; +using ListReduce = typename detail::ListReduceImpl::type; /// \brief Determines whether all the types in the list are "true." /// diff --git a/vtkm/ListTag.h b/vtkm/ListTag.h deleted file mode 100644 index 5be227089..000000000 --- a/vtkm/ListTag.h +++ /dev/null @@ -1,327 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_ListTag_h -#define vtk_m_ListTag_h - -#include - -#include - -#include -#include - -#include - -struct VTKM_DEPRECATED(1.6, "ListTag.h is deprecated. Include List.h and use vtkm::List instead.") - VTKmListTagHeaderDeprecationWarning -{ -}; - -inline VTKmListTagHeaderDeprecationWarning IssueVTKmListTagHeaderDeprecationWarning() -{ - return {}; -} - -namespace vtkm -{ -namespace detail -{ - -//----------------------------------------------------------------------------- - -/// Base class that all ListTag classes inherit from. Helps identify lists -/// in macros like VTKM_IS_LIST_TAG. -/// -struct ListRoot -{ -}; - -template -using ListBase = vtkm::List; - -/// list value that is used to represent a list actually matches all values -struct UniversalTag -{ - //We never want this tag constructed, and by deleting the constructor - //we get an error when trying to use this class with ForEach. - UniversalTag() = delete; -}; - -} // namespace detail - -//----------------------------------------------------------------------------- -/// A basic tag for a list of typenames. This struct can be subclassed -/// and still behave like a list tag. -/// @cond NONE -template -struct VTKM_DEPRECATED(1.6, "ListTagBase replace by List. Note that List cannot be subclassed.") - ListTagBase : detail::ListRoot -{ - using list = detail::ListBase; -}; -/// @endcond - -/// A special tag for a list that represents holding all potential values -/// -/// Note: Can not be used with ForEach for obvious reasons. -/// @cond NONE -struct VTKM_DEPRECATED( - 1.6, - "ListTagUniversal replaced by ListUniversal. Note that ListUniversal cannot be subclassed.") - ListTagUniversal : detail::ListRoot -{ - using list = vtkm::detail::ListBase; -}; -/// @endcond - -namespace internal -{ - -/// @cond NONE -template -struct ListTagCheck : std::is_base_of -{ - static constexpr bool Valid = std::is_base_of::value; -}; -/// @endcond - -} // namespace internal - -namespace detail -{ - -/// @cond NONE -template -struct VTKM_DEPRECATED(1.6, "VTKM_IS_LIST_TAG replaced with VTKM_IS_LIST.") ListTagAssert - : internal::IsList -{ -}; -/// @endcond - -} // namespace detal - -/// Checks that the argument is a proper list tag. This is a handy concept -/// check for functions and classes to make sure that a template argument is -/// actually a device adapter tag. (You can get weird errors elsewhere in the -/// code when a mistake is made.) -/// -#define VTKM_IS_LIST_TAG(tag) \ - VTKM_STATIC_ASSERT_MSG((::vtkm::detail::ListTagAssert::value), \ - "Provided type is not a valid VTK-m list tag.") - -namespace internal -{ - -namespace detail -{ - -/// @cond NONE -template -struct ListTagAsListImpl -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - VTKM_IS_LIST_TAG(ListTag); - using type = typename ListTag::list; - VTKM_DEPRECATED_SUPPRESS_END -}; -/// @endcond - -} // namespace detail - -/// Converts a ListTag to a vtkm::List. -/// -template -using ListTagAsList = typename detail::ListTagAsListImpl::type; - -VTKM_DEPRECATED_SUPPRESS_BEGIN -namespace detail -{ - -// Could use ListApply instead, but that causes deprecation warnings. -template -struct ListAsListTagImpl; -template -struct ListAsListTagImpl> -{ - using type = vtkm::ListTagBase; -}; - -} // namespace detail - -template -using ListAsListTag = typename detail::ListAsListTagImpl::type; -VTKM_DEPRECATED_SUPPRESS_END - -// This allows the new `List` operations work on `ListTag`s. -template -struct AsListImpl -{ - VTKM_STATIC_ASSERT_MSG(ListTagCheck::value, - "Attempted to use something that is not a List with a List operation."); - VTKM_DEPRECATED_SUPPRESS_BEGIN - using type = typename std::conditional::value, - vtkm::ListUniversal, - ListTagAsList>::type; - VTKM_DEPRECATED_SUPPRESS_END -}; - -} // namespace internal - - -/// \brief Applies the list of types to a template. -/// -/// Given a ListTag and a templated class, returns the class instantiated with the types -/// represented by the ListTag. -/// -template class Target> -using ListTagApply VTKM_DEPRECATED(1.6, "ListTagApply replaced by ListApply.") = - vtkm::ListApply; - -/// A special tag for an empty list. -/// -/// @cond NONE -struct VTKM_DEPRECATED( - 1.6, - "ListTagEmpty replaced by ListEmpty. Note that ListEmpty cannot be subclassed.") ListTagEmpty - : detail::ListRoot -{ - using list = vtkm::detail::ListBase<>; -}; -/// @endcond - -/// A tag that is a construction of two other tags joined together. This struct -/// can be subclassed and still behave like a list tag. -/// @cond NONE -template -struct VTKM_DEPRECATED( - 1.6, - "ListTagJoin replaced by ListAppend. Note that ListAppend cannot be subclassed.") ListTagJoin - : vtkm::internal::ListAsListTag> -{ -}; -/// @endcond - - -/// A tag that is constructed by appending \c Type to \c ListTag. -/// @cond NONE -template -struct VTKM_DEPRECATED(1.6, - "ListTagAppend replaced by ListAppend. " - "Note that ListAppend cannot be subclassed.") ListTagAppend - : vtkm::internal::ListAsListTag>> -{ -}; -/// @endcond - -/// Append \c Type to \c ListTag only if \c ListTag does not already contain \c Type. -/// No checks are performed to see if \c ListTag itself has only unique elements. -/// @cond NONE -template -struct VTKM_DEPRECATED(1.6) ListTagAppendUnique - : std::conditional< - vtkm::ListHas::value, - vtkm::internal::ListAsListTag>, - vtkm::internal::ListAsListTag>>>::type -{ -}; -/// @endcond - -/// A tag that consists of elements that are found in both tags. This struct -/// can be subclassed and still behave like a list tag. -/// @cond NONE -template -struct VTKM_DEPRECATED( - 1.6, - "ListTagIntersect replaced by ListIntersect. Note that ListIntersect cannot be subclassed.") - ListTagIntersect : vtkm::internal::ListAsListTag> -{ -}; -/// @endcond - -/// A list tag that consists of each item in another list tag fed into a template that takes -/// a single parameter. -/// @cond NONE -template class Transform> -struct VTKM_DEPRECATED( - 1.6, - "ListTagTransform replaced by ListTransform. Note that ListTransform cannot be subclassed.") - ListTagTransform : vtkm::internal::ListAsListTag> -{ -}; -/// @endcond - -/// A list tag that takes an existing ListTag and a predicate template that is applied to -/// each type in the ListTag. Any type in the ListTag that has a value element equal to true -/// (the equivalent of std::true_type), that item will be removed from the list. For example -/// the following type -/// -/// ```cpp -/// vtkm::ListTagRemoveIf, std::is_integral> -/// ``` -/// -/// resolves to a ListTag that is equivalent to `vtkm::ListTag` because -/// `std::is_integral` and `std::is_integral` resolve to `std::true_type` -/// whereas `std::is_integral` and `std::is_integral` resolve to -/// `std::false_type`. -/// @cond NONE -template class Predicate> -struct VTKM_DEPRECATED( - 1.6, - "ListTagRemoveIf replaced by ListRemoveIf. Note that ListRemoveIf cannot be subclassed.") - ListTagRemoveIf : vtkm::internal::ListAsListTag> -{ -}; -/// @endcond - -/// Generate a tag that is the cross product of two other tags. The resulting -/// tag has the form of Tag< vtkm::List, vtkm::List .... > -/// -/// Note that as of VTK-m 1.8, the behavior of this (already depreciated) operation -/// was changed to return pairs in vtkm::List instead of brigand::list. -/// -/// @cond NONE -template -struct VTKM_DEPRECATED( - 1.6, - "ListCrossProduct replaced by ListCross. Note that ListCross cannot be subclassed.") - ListCrossProduct : vtkm::internal::ListAsListTag> -{ -}; -/// @endcond - -/// \brief Checks to see if the given \c Type is in the list pointed to by \c ListTag. -/// -/// There is a static boolean named \c value that is set to true if the type is -/// contained in the list and false otherwise. -/// -/// @cond NONE -template -struct VTKM_DEPRECATED(1.6, "ListContains replaced by ListHas.") ListContains - : vtkm::ListHas -{ -}; -/// @endcond - -/// \brief Finds the type at the given index. -/// -/// This struct contains subtype \c type that resolves to the type at the given index. -/// -template -struct VTKM_DEPRECATED(1.6, "ListTypeAt::type replaced by ListAt.") ListTypeAt -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - VTKM_IS_LIST_TAG(ListTag); - VTKM_DEPRECATED_SUPPRESS_END - using type = vtkm::ListAt; -}; - -} // namespace vtkm - -#endif //vtk_m_ListTag_h diff --git a/vtkm/Particle.h b/vtkm/Particle.h index 1708c3ab0..015bca388 100644 --- a/vtkm/Particle.h +++ b/vtkm/Particle.h @@ -99,7 +99,7 @@ public: const vtkm::Id& numSteps = 0, const vtkm::ParticleStatus& status = vtkm::ParticleStatus(), const vtkm::FloatDefault& time = 0) - : Pos(p) + : Position(p) , ID(id) , NumSteps(numSteps) , Status(status) @@ -109,7 +109,7 @@ public: VTKM_EXEC_CONT Particle(const vtkm::Particle& p) - : Pos(p.Pos) + : Position(p.Position) , ID(p.ID) , NumSteps(p.NumSteps) , Status(p.Status) @@ -125,6 +125,22 @@ public: // troublesome with CUDA __host__ __device__ markup. } + VTKM_EXEC_CONT const vtkm::Vec3f& GetPosition() const { return this->Position; } + VTKM_EXEC_CONT void SetPosition(const vtkm::Vec3f& position) { this->Position = position; } + + VTKM_EXEC_CONT vtkm::Id GetID() const { return this->ID; } + VTKM_EXEC_CONT void SetID(vtkm::Id id) { this->ID = id; } + + VTKM_EXEC_CONT vtkm::Id GetNumberOfSteps() const { return this->NumSteps; } + VTKM_EXEC_CONT void SetNumberOfSteps(vtkm::Id numSteps) { this->NumSteps = numSteps; } + + VTKM_EXEC_CONT vtkm::ParticleStatus GetStatus() const { return this->Status; } + VTKM_EXEC_CONT vtkm::ParticleStatus& GetStatus() { return this->Status; } + VTKM_EXEC_CONT void SetStatus(vtkm::ParticleStatus status) { this->Status = status; } + + VTKM_EXEC_CONT vtkm::FloatDefault GetTime() const { return this->Time; } + VTKM_EXEC_CONT void SetTime(vtkm::FloatDefault time) { this->Time = time; } + VTKM_EXEC_CONT vtkm::Vec3f Velocity(const vtkm::VecVariable& vectors, const vtkm::FloatDefault& vtkmNotUsed(length)) @@ -139,22 +155,24 @@ public: vtkm::Vec3f GetEvaluationPosition(const vtkm::FloatDefault& deltaT) const { (void)deltaT; // unused for a general particle advection case - return this->Pos; + return this->Position; } inline VTKM_CONT friend std::ostream& operator<<(std::ostream& out, const vtkm::Particle& p) { - out << "v(" << p.Time << ") = " << p.Pos << ", ID: " << p.ID << ", NumSteps: " << p.NumSteps - << ", Status: " << p.Status; + out << "v(" << p.Time << ") = " << p.Position << ", ID: " << p.ID + << ", NumSteps: " << p.NumSteps << ", Status: " << p.Status; return out; } - vtkm::Vec3f Pos; +private: + vtkm::Vec3f Position; vtkm::Id ID = -1; vtkm::Id NumSteps = 0; vtkm::ParticleStatus Status; vtkm::FloatDefault Time = 0; +public: static size_t Sizeof() { constexpr std::size_t sz = sizeof(vtkm::Vec3f) // Pos @@ -183,7 +201,7 @@ public: const vtkm::Id& numSteps = 0, const vtkm::ParticleStatus& status = vtkm::ParticleStatus(), const vtkm::FloatDefault& time = 0) - : Pos(position) + : Position(position) , ID(id) , NumSteps(numSteps) , Status(status) @@ -195,6 +213,22 @@ public: { } + VTKM_EXEC_CONT const vtkm::Vec3f& GetPosition() const { return this->Position; } + VTKM_EXEC_CONT void SetPosition(const vtkm::Vec3f& position) { this->Position = position; } + + VTKM_EXEC_CONT vtkm::Id GetID() const { return this->ID; } + VTKM_EXEC_CONT void SetID(vtkm::Id id) { this->ID = id; } + + VTKM_EXEC_CONT vtkm::Id GetNumberOfSteps() const { return this->NumSteps; } + VTKM_EXEC_CONT void SetNumberOfSteps(vtkm::Id numSteps) { this->NumSteps = numSteps; } + + VTKM_EXEC_CONT vtkm::ParticleStatus GetStatus() const { return this->Status; } + VTKM_EXEC_CONT vtkm::ParticleStatus& GetStatus() { return this->Status; } + VTKM_EXEC_CONT void SetStatus(vtkm::ParticleStatus status) { this->Status = status; } + + VTKM_EXEC_CONT vtkm::FloatDefault GetTime() const { return this->Time; } + VTKM_EXEC_CONT void SetTime(vtkm::FloatDefault time) { this->Time = time; } + VTKM_EXEC_CONT vtkm::Float64 Gamma(vtkm::Vec3f momentum, bool reciprocal = false) const { @@ -248,24 +282,23 @@ public: // Translation is in -ve Z direction, // this needs to be a parameter. auto translation = this->NumSteps * deltaT * SPEED_OF_LIGHT * vtkm::Vec3f{ 0., 0., -1.0 }; - return this->Pos + translation; + return this->Position + translation; } inline VTKM_CONT friend std::ostream& operator<<(std::ostream& out, const vtkm::ChargedParticle& p) { - out << "v(" << p.Time << ") = " << p.Pos << ", ID: " << p.ID << ", NumSteps: " << p.NumSteps - << ", Status: " << p.Status; + out << "v(" << p.Time << ") = " << p.Position << ", ID: " << p.ID + << ", NumSteps: " << p.NumSteps << ", Status: " << p.Status; return out; } - vtkm::Vec3f Pos; +private: + vtkm::Vec3f Position; vtkm::Id ID = -1; vtkm::Id NumSteps = 0; vtkm::ParticleStatus Status; vtkm::FloatDefault Time = 0; - -private: vtkm::Float64 Mass; vtkm::Float64 Charge; vtkm::Float64 Weighting; @@ -303,20 +336,34 @@ struct Serialization public: static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::Particle& p) { - vtkmdiy::save(bb, p.Pos); - vtkmdiy::save(bb, p.ID); - vtkmdiy::save(bb, p.NumSteps); - vtkmdiy::save(bb, p.Status); - vtkmdiy::save(bb, p.Time); + vtkmdiy::save(bb, p.GetPosition()); + vtkmdiy::save(bb, p.GetID()); + vtkmdiy::save(bb, p.GetNumberOfSteps()); + vtkmdiy::save(bb, p.GetStatus()); + vtkmdiy::save(bb, p.GetTime()); } static VTKM_CONT void load(BinaryBuffer& bb, vtkm::Particle& p) { - vtkmdiy::load(bb, p.Pos); - vtkmdiy::load(bb, p.ID); - vtkmdiy::load(bb, p.NumSteps); - vtkmdiy::load(bb, p.Status); - vtkmdiy::load(bb, p.Time); + vtkm::Vec3f pos; + vtkmdiy::load(bb, pos); + p.SetPosition(pos); + + vtkm::Id id; + vtkmdiy::load(bb, id); + p.SetID(id); + + vtkm::Id numSteps; + vtkmdiy::load(bb, numSteps); + p.SetNumberOfSteps(numSteps); + + vtkm::ParticleStatus status; + vtkmdiy::load(bb, status); + p.SetStatus(status); + + vtkm::FloatDefault time; + vtkmdiy::load(bb, time); + p.SetTime(time); } }; @@ -326,7 +373,7 @@ struct Serialization public: static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::ChargedParticle& e) { - vtkmdiy::save(bb, e.Pos); + vtkmdiy::save(bb, e.Position); vtkmdiy::save(bb, e.ID); vtkmdiy::save(bb, e.NumSteps); vtkmdiy::save(bb, e.Status); @@ -339,7 +386,7 @@ public: static VTKM_CONT void load(BinaryBuffer& bb, vtkm::ChargedParticle& e) { - vtkmdiy::load(bb, e.Pos); + vtkmdiy::load(bb, e.Position); vtkmdiy::load(bb, e.ID); vtkmdiy::load(bb, e.NumSteps); vtkmdiy::load(bb, e.Status); diff --git a/vtkm/TypeListTag.h b/vtkm/TypeListTag.h deleted file mode 100644 index 0555a105d..000000000 --- a/vtkm/TypeListTag.h +++ /dev/null @@ -1,115 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_TypeListTag_h -#define vtk_m_TypeListTag_h - -// Everything in this header file is deprecated and movded to TypeList.h. -#include - -struct VTKM_DEPRECATED(1.6, "TypeListTag.h is deprecated. Include TypeList.h and use vtkm::TypeList* instead.") -VTKmTypeListTagHeaderDeprecationWarning -{ -}; - -inline VTKmTypeListTagHeaderDeprecationWarning IssueVTKmTypeListTagHeaderDeprecationWarning() -{ - return {}; -} - -#ifndef VTKM_DEFAULT_TYPE_LIST_TAG -#define VTKM_DEFAULT_TYPE_LIST_TAG ::vtkm::internal::TypeListTagDefault -#endif - -#include -#include - -#define VTK_M_OLD_TYPE_LIST_DEFINITION(name) \ - struct VTKM_ALWAYS_EXPORT \ - VTKM_DEPRECATED( \ - 1.6, \ - "TypeListTag" #name " replaced by TypeList" #name ". " \ - "Note that the new TypeList" #name " cannot be subclassed.") \ - TypeListTag ## name : vtkm::internal::ListAsListTag \ - { \ - } - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ - -VTK_M_OLD_TYPE_LIST_DEFINITION(Id); -VTK_M_OLD_TYPE_LIST_DEFINITION(Id2); -VTK_M_OLD_TYPE_LIST_DEFINITION(Id3); -VTK_M_OLD_TYPE_LIST_DEFINITION(IdComponent); -VTK_M_OLD_TYPE_LIST_DEFINITION(Index); -VTK_M_OLD_TYPE_LIST_DEFINITION(FieldScalar); -VTK_M_OLD_TYPE_LIST_DEFINITION(FieldVec2); -VTK_M_OLD_TYPE_LIST_DEFINITION(FieldVec3); -VTK_M_OLD_TYPE_LIST_DEFINITION(FieldVec4); -VTK_M_OLD_TYPE_LIST_DEFINITION(FloatVec); -VTK_M_OLD_TYPE_LIST_DEFINITION(Field); -VTK_M_OLD_TYPE_LIST_DEFINITION(ScalarAll); -VTK_M_OLD_TYPE_LIST_DEFINITION(VecCommon); -VTK_M_OLD_TYPE_LIST_DEFINITION(VecAll); -VTK_M_OLD_TYPE_LIST_DEFINITION(All); -VTK_M_OLD_TYPE_LIST_DEFINITION(Common); - -namespace internal -{ - -VTK_M_OLD_TYPE_LIST_DEFINITION(VecUncommon); - -// Special definition of TypeListTagCommon to give descriptive warning when -// VTKM_DEFAULT_TYPE_LIST_TAG is used. -/// @cond NONE -struct VTKM_ALWAYS_EXPORT -VTKM_DEPRECATED( - 1.6, - "VTKM_DEFAULT_TYPE_LIST_TAG replaced by VTKM_DEFAULT_TYPE_LIST. " - "Note that the new VTKM_DEFAULT_TYPE_LIST cannot be subclassed.") -TypeListTagDefault : vtkm::internal::ListAsListTag -{ -}; -/// @endcond - -} // namespace internal - -// Special implementation of ListContains for TypeListTagAll to always be -// true. Although TypeListTagAll is necessarily finite, the point is to -// be all inclusive. Besides, this should speed up the compilation when -// checking a list that should contain everything. -template -struct ListContains -{ - static constexpr bool value = true; -}; - -// Special implementation of ListHas for TypeListTagAll to always be -// true. Although TypeListTagAll is necessarily finite, the point is to -// be all inclusive. Besides, this should speed up the compilation when -// checking a list that should contain everything. -namespace detail -{ - -template -struct ListHasImpl -{ - using type = std::true_type; -}; - -} // namespace detail - -} // namespace vtkm - -VTKM_DEPRECATED_SUPPRESS_END -#undef VTK_M_OLD_TYPE_LIST_DEFINITION - -#endif //vtk_m_TypeListTag_h diff --git a/vtkm/VecFromVirtPortal.h b/vtkm/VecFromVirtPortal.h deleted file mode 100644 index d7d8845a7..000000000 --- a/vtkm/VecFromVirtPortal.h +++ /dev/null @@ -1,69 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_VecFromVirtPortal_h -#define vtk_m_VecFromVirtPortal_h - -#include - -#include -#include - -namespace vtkm -{ - -/// \brief A short variable-length array from a window in an ArrayPortal. -/// -/// The \c VecFromPortal class is a Vec-like class that holds an array portal -/// and exposes a small window of that portal as if it were a \c Vec. -/// -template -class VTKM_ALWAYS_EXPORT VecFromVirtPortal -{ - using RefType = vtkm::internal::ArrayPortalValueReference>; - -public: - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - VecFromVirtPortal(const vtkm::ArrayPortalRef* portal, - vtkm::IdComponent numComponents, - vtkm::Id offset) - : Portal(portal) - , NumComponents(numComponents) - , Offset(offset) - { - } - - VTKM_EXEC_CONT - vtkm::IdComponent GetNumberOfComponents() const { return this->NumComponents; } - - template - VTKM_EXEC_CONT void CopyInto(vtkm::Vec& dest) const - { - vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->NumComponents); - for (vtkm::IdComponent index = 0; index < numComponents; index++) - { - dest[index] = this->Portal->Get(index + this->Offset); - } - } - - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - RefType operator[](vtkm::IdComponent index) const - { - return RefType(*this->Portal, index + this->Offset); - } - -private: - const vtkm::ArrayPortalRef* Portal = nullptr; - vtkm::IdComponent NumComponents = 0; - vtkm::Id Offset = 0; -}; -} -#endif diff --git a/vtkm/VirtualObjectBase.h b/vtkm/VirtualObjectBase.h deleted file mode 100644 index c5b7bcb1f..000000000 --- a/vtkm/VirtualObjectBase.h +++ /dev/null @@ -1,94 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_VirtualObjectBase_h -#define vtk_m_VirtualObjectBase_h - -#include -#include - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -// Do not include this class at all if not compiling virtual methods. - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ - -/// \brief Base class for virtual objects that work in the execution environment -/// -/// Any class built in VTK-m that has virtual methods and is intended to work in both the control -/// and execution environment should inherit from \c VirtualObjectBase. Hierarchies under \c -/// VirtualObjectBase can be used in conjunction with \c VirtualObjectHandle to transfer from the -/// control environment (where they are set up) to the execution environment (where they are used). -/// -/// In addition to inheriting from \c VirtualObjectBase, virtual objects have to satisfy 2 other -/// conditions to work correctly. First, they have to be a plain old data type that can be copied -/// with \c memcpy (with the exception of the virtual table, which \c VirtualObjectHandle will take -/// care of). Second, if the object changes its state in the control environment, it should call -/// \c Modified on itself so the \c VirtualObjectHandle will know it update the object in the -/// execution environment. -/// -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.7, - "Virtual methods are no longer supported in the execution environment.") VirtualObjectBase -{ -public: - VTKM_EXEC_CONT virtual ~VirtualObjectBase() noexcept - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC_CONT void Modified() { this->ModifiedCount++; } - - VTKM_EXEC_CONT vtkm::Id GetModifiedCount() const { return this->ModifiedCount; } - -protected: - VTKM_EXEC_CONT VirtualObjectBase() - : ModifiedCount(0) - { - } - - VTKM_EXEC_CONT VirtualObjectBase(const VirtualObjectBase& other) - { //we implement this as we need a copy constructor with cuda markup - //but using =default causes warnings with CUDA 9 - this->ModifiedCount = other.ModifiedCount; - } - - VTKM_EXEC_CONT VirtualObjectBase(VirtualObjectBase&& other) - : ModifiedCount(other.ModifiedCount) - { - } - - VTKM_EXEC_CONT VirtualObjectBase& operator=(const VirtualObjectBase&) - { - this->Modified(); - return *this; - } - - VTKM_EXEC_CONT VirtualObjectBase& operator=(VirtualObjectBase&&) - { - this->Modified(); - return *this; - } - -private: - vtkm::Id ModifiedCount; -}; - -} // namespace vtkm - -VTKM_DEPRECATED_SUPPRESS_END - -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -#endif //vtk_m_VirtualObjectBase_h diff --git a/vtkm/cont/ArrayCopyDevice.h b/vtkm/cont/ArrayCopyDevice.h index fcd94a7ac..443e97c46 100644 --- a/vtkm/cont/ArrayCopyDevice.h +++ b/vtkm/cont/ArrayCopyDevice.h @@ -17,8 +17,6 @@ #include #include -#include - #include // TODO: When virtual arrays are available, compile the implementation in a .cxx/.cu file. Common @@ -32,62 +30,20 @@ namespace cont namespace detail { -// Element-wise copy. -template -void ArrayCopyWithAlgorithm(const InArrayType& source, OutArrayType& destination) +template +VTKM_CONT void ArrayCopyImpl(const vtkm::cont::ArrayHandle& source, + vtkm::cont::ArrayHandle& destination) { + VTKM_STATIC_ASSERT((!std::is_same::value || !std::is_same::value)); + // Current implementation of Algorithm::Copy will first try to copy on devices where the // data is already available. vtkm::cont::Algorithm::Copy(source, destination); } -// TODO: Remove last argument once ArryHandleNewStyle becomes ArrayHandle -template -void ArrayCopyOldImpl(const InArrayType& in, OutArrayType& out, std::false_type /* Copy storage */) -{ - ArrayCopyWithAlgorithm(in, out); -} - -// Copy storage for implicit arrays, must be of same type: -// TODO: This will go away once ArrayHandleNewStyle becomes ArrayHandle. -template -void ArrayCopyOldImpl(const ArrayType& in, ArrayType& out, std::true_type /* Copy storage */) -{ - // This is only called if in/out are the same type and the handle is not - // writable. This allows read-only implicit array handles to be copied. - auto newStorage = in.GetStorage(); - out = ArrayType(newStorage); -} - -// TODO: This will go away once ArrayHandleNewStyle becomes ArrayHandle. -template -VTKM_CONT void ArrayCopyImpl(const InArrayType& source, - OutArrayType& destination, - std::false_type /* New style */) -{ - using SameTypes = std::is_same; - using IsWritable = vtkm::cont::internal::IsWritableArrayHandle; - using JustCopyStorage = std::integral_constant; - ArrayCopyOldImpl(source, destination, JustCopyStorage{}); -} - -// TODO: ArrayHandleNewStyle will eventually become ArrayHandle, in which case this -// will become ArrayCopyWithAlgorithm -template -VTKM_CONT void ArrayCopyImpl(const vtkm::cont::ArrayHandle& source, - vtkm::cont::ArrayHandle& destination, - std::true_type /* New style */) -{ - VTKM_STATIC_ASSERT((!std::is_same::value || !std::is_same::value)); - ArrayCopyWithAlgorithm(source, destination); -} - -// TODO: ArrayHandleNewStyle will eventually become ArrayHandle, in which case this -// will become the only version with the same array types. template VTKM_CONT void ArrayCopyImpl(const vtkm::cont::ArrayHandle& source, - vtkm::cont::ArrayHandle& destination, - std::true_type /* New style */) + vtkm::cont::ArrayHandle& destination) { destination.DeepCopyFrom(source); } @@ -137,12 +93,8 @@ VTKM_CONT void ArrayCopyDevice(const vtkm::cont::ArrayHandle, - InArrayType>; - // Static dispatch cases 1 & 2 - detail::ArrayCopyImpl(source, destination, std::integral_constant{}); + detail::ArrayCopyImpl(source, destination); } /// @} diff --git a/vtkm/cont/ArrayHandle.cxx b/vtkm/cont/ArrayHandle.cxx index 3ecbc7776..2d5770ce8 100644 --- a/vtkm/cont/ArrayHandle.cxx +++ b/vtkm/cont/ArrayHandle.cxx @@ -43,45 +43,3 @@ VTKM_CONT bool ArrayHandleIsOnDevice(const std::vector& buffers) - { - if (this->FoundDevice == vtkm::cont::DeviceAdapterTagUndefined{}) - { - if (vtkm::cont::detail::ArrayHandleIsOnDevice(buffers, device)) - { - this->FoundDevice = device; - } - } - } -}; - -} // anonymous namespace - -namespace vtkm -{ -namespace cont -{ -namespace detail -{ - -VTKM_CONT vtkm::cont::DeviceAdapterId ArrayHandleGetDeviceAdapterId( - const std::vector& buffers) -{ - DeviceCheckFunctor functor; - - vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST{}, buffers); - - return functor.FoundDevice; -} -} -} -} // namespace vtkm::cont::detail diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index c8fb07cb9..09a40f346 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -260,9 +259,6 @@ VTKM_CONT_EXPORT VTKM_CONT bool ArrayHandleIsOnDevice( const std::vector& buffers, vtkm::cont::DeviceAdapterId device); -VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::DeviceAdapterId ArrayHandleGetDeviceAdapterId( - const std::vector& buffers); - } // namespace detail /// \brief Manages an array-worth of data. @@ -298,19 +294,6 @@ public: using ReadPortalType = typename StorageType::ReadPortalType; using WritePortalType = typename StorageType::WritePortalType; - // TODO: Deprecate this - template - struct VTKM_DEPRECATED(1.6, "Use ReadPortalType and WritePortalType.") ExecutionTypes - { - using Portal = WritePortalType; - using PortalConst = ReadPortalType; - }; - - using PortalControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::WritePortalType instead.") = - WritePortalType; - using PortalConstControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::ReadPortalType instead.") = - ReadPortalType; - /// Constructs an empty ArrayHandle. /// VTKM_CONT ArrayHandle() @@ -413,45 +396,11 @@ public: return true; // different valuetype and/or storage } - VTKM_DEPRECATED(1.9, "Use the size of the std::vector returned from GetBuffers.") - VTKM_CONT constexpr vtkm::IdComponent GetNumberOfBuffers() - { - return static_cast(this->GetBuffers().size()); - } - /// Get the storage. /// VTKM_CONT StorageType GetStorage() const { return StorageType{}; } - /// Get the array portal of the control array. - /// Since worklet invocations are asynchronous and this routine is a synchronization point, - /// exceptions maybe thrown for errors from previously executed worklets. - /// - /// \deprecated Use `WritePortal` instead. - /// - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use ArrayHandle::WritePortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - - /// \cond NOPE - WritePortalType GetPortalControl() const { return this->WritePortal(); } - /// \endcond - - /// Get the array portal of the control array. - /// Since worklet invocations are asynchronous and this routine is a synchronization point, - /// exceptions maybe thrown for errors from previously executed worklets. - /// - /// \deprecated Use `ReadPortal` instead. - /// - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use ArrayHandle::ReadPortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - /// \cond NOPE - ReadPortalType GetPortalConstControl() const { return this->ReadPortal(); } - /// \endcond - + ///@{ /// \brief Get an array portal that can be used in the control environment. /// /// The returned array can be used in the control environment to read values from the array. (It @@ -465,9 +414,14 @@ public: VTKM_CONT ReadPortalType ReadPortal() const { vtkm::cont::Token token; + return this->ReadPortal(token); + } + VTKM_CONT ReadPortalType ReadPortal(vtkm::cont::Token& token) const + { return StorageType::CreateReadPortal( this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token); } + ///@} /// \brief Get an array portal that can be used in the control environment. /// @@ -481,7 +435,10 @@ public: VTKM_CONT WritePortalType WritePortal() const { vtkm::cont::Token token; - + return this->WritePortal(token); + } + VTKM_CONT WritePortalType WritePortal(vtkm::cont::Token& token) const + { return StorageType::CreateWritePortal( this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token); } @@ -563,12 +520,6 @@ public: } ///@} - VTKM_DEPRECATED(1.6, "Use Allocate(n, vtkm::CopyFlag::On) instead of Shrink(n).") - VTKM_CONT void Shrink(vtkm::Id numberOfValues) - { - this->Allocate(numberOfValues, vtkm::CopyFlag::On); - } - /// @{ /// \brief Fills the array with a given value. /// @@ -667,25 +618,6 @@ public: return StorageType::CreateWritePortal(this->GetBuffers(), device, token); } - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInput now requires a vtkm::cont::Token object.") - ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, token); - } - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForOutput now requires a vtkm::cont::Token object.") - WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device) - { - vtkm::cont::Token token; - return this->PrepareForOutput(numberOfValues, device, token); - } - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInPlace now requires a vtkm::cont::Token object.") - WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForInPlace(device, token); - } - /// Returns true if the ArrayHandle's data is on the given device. If the data are on the given /// device, then preparing for that device should not require any data movement. /// @@ -702,19 +634,6 @@ public: return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{}); } - /// Returns a DeviceAdapterId for a device currently allocated on. If there is no device - /// with an up-to-date copy of the data, VTKM_DEVICE_ADAPTER_UNDEFINED is - /// returned. - /// - /// Note that in a multithreaded environment the validity of this result can - /// change. - /// - VTKM_CONT - VTKM_DEPRECATED(1.7, "Use ArrayHandle::IsOnDevice.") DeviceAdapterId GetDeviceAdapterId() const - { - return detail::ArrayHandleGetDeviceAdapterId(this->Buffers); - } - /// 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). diff --git a/vtkm/cont/ArrayHandleBasic.h b/vtkm/cont/ArrayHandleBasic.h index 0570ce420..8486d05b9 100644 --- a/vtkm/cont/ArrayHandleBasic.h +++ b/vtkm/cont/ArrayHandleBasic.h @@ -232,13 +232,6 @@ VTKM_CONT vtkm::cont::ArrayHandleBasic make_ArrayHandle(const T* array, } } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -VTKM_CONT vtkm::cont::ArrayHandleBasic make_ArrayHandle(const T* array, vtkm::Id numberOfValues) -{ - return make_ArrayHandle(array, numberOfValues, vtkm::CopyFlag::Off); -} - /// A convenience function to move a user-allocated array into an `ArrayHandle`. /// The provided array pointer will be reset to `nullptr`. /// If the array was not allocated with the `new[]` operator, then deleter and reallocater @@ -273,13 +266,6 @@ VTKM_CONT vtkm::cont::ArrayHandleBasic make_ArrayHandle(const std::vector -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -VTKM_CONT vtkm::cont::ArrayHandleBasic make_ArrayHandle(const std::vector& array) -{ - return make_ArrayHandle(array, vtkm::CopyFlag::Off); -} - /// Move an std::vector into an ArrayHandle. /// template diff --git a/vtkm/cont/ArrayHandleCompositeVector.h b/vtkm/cont/ArrayHandleCompositeVector.h index 775021b91..57ba4d2ba 100644 --- a/vtkm/cont/ArrayHandleCompositeVector.h +++ b/vtkm/cont/ArrayHandleCompositeVector.h @@ -13,7 +13,6 @@ #include #include -#include #include #include #include diff --git a/vtkm/cont/ArrayHandleConcatenate.h b/vtkm/cont/ArrayHandleConcatenate.h index 292283123..a8a1cdc2f 100644 --- a/vtkm/cont/ArrayHandleConcatenate.h +++ b/vtkm/cont/ArrayHandleConcatenate.h @@ -10,7 +10,6 @@ #ifndef vtk_m_cont_ArrayHandleConcatenate_h #define vtk_m_cont_ArrayHandleConcatenate_h -#include #include #include @@ -117,57 +116,14 @@ class VTKM_ALWAYS_EXPORT StorageTagConcatenate namespace internal { -namespace detail -{ - -template -struct ConcatinateTypeArgImpl; - -template -struct ConcatinateTypeArgImpl -{ - using StorageTag = StorageTag_; - using Storage = vtkm::cont::internal::Storage; - using ArrayHandle = vtkm::cont::ArrayHandle; -}; - -template -struct ConcatinateTypeArgImpl -{ - VTKM_STATIC_ASSERT_MSG((std::is_same::value), - "Used array with wrong type in ArrayHandleConcatinate."); - using StorageTag VTKM_DEPRECATED( - 1.6, - "Use storage tags instead of array handles in StorageTagConcatenate.") = - typename Array::StorageTag; - using Storage VTKM_DEPRECATED( - 1.6, - "Use storage tags instead of array handles in StorageTagConcatenate.") = - vtkm::cont::internal::Storage; - using ArrayHandle VTKM_DEPRECATED( - 1.6, - "Use storage tags instead of array handles in StorageTagConcatenate.") = - vtkm::cont::ArrayHandle; -}; - -template -struct ConcatinateTypeArg - : ConcatinateTypeArgImpl::type::value> -{ -}; - -} // namespace detail - template class Storage> { - using SourceStorage1 = typename detail::ConcatinateTypeArg::Storage; - using SourceStorage2 = typename detail::ConcatinateTypeArg::Storage; + using SourceStorage1 = vtkm::cont::internal::Storage; + using SourceStorage2 = vtkm::cont::internal::Storage; - using ArrayHandleType1 = typename detail::ConcatinateTypeArg::ArrayHandle; - using ArrayHandleType2 = typename detail::ConcatinateTypeArg::ArrayHandle; + using ArrayHandleType1 = vtkm::cont::ArrayHandle; + using ArrayHandleType2 = vtkm::cont::ArrayHandle; struct Info { @@ -338,9 +294,8 @@ struct SerializableTypeString> template struct SerializableTypeString< vtkm::cont::ArrayHandle>> - : SerializableTypeString::ArrayHandle, - typename internal::detail::ConcatinateTypeArg::ArrayHandle>> + : SerializableTypeString, + vtkm::cont::ArrayHandle>> { }; } @@ -378,11 +333,11 @@ public: template struct Serialization>> - : Serialization::ArrayHandle, - typename vtkm::cont::internal::detail::ConcatinateTypeArg::ArrayHandle>> + : Serialization, + vtkm::cont::ArrayHandle>> { }; + } // diy /// @endcond SERIALIZATION diff --git a/vtkm/cont/ArrayHandleMultiplexer.h b/vtkm/cont/ArrayHandleMultiplexer.h index 1819c1d7c..d05ab60c3 100644 --- a/vtkm/cont/ArrayHandleMultiplexer.h +++ b/vtkm/cont/ArrayHandleMultiplexer.h @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include namespace vtkm { @@ -90,7 +90,7 @@ private: template struct ArrayPortalMultiplexer { - using PortalVariantType = vtkm::exec::internal::Variant; + using PortalVariantType = vtkm::exec::Variant; PortalVariantType PortalVariant; using ValueType = typename PortalVariantType::template TypeAt<0>::ValueType; @@ -214,7 +214,7 @@ struct MultiplexerCreateWritePortalFunctor template struct MultiplexerArrayHandleVariantFunctor { - using VariantType = vtkm::cont::internal::Variant...>; + using VariantType = vtkm::cont::Variant...>; template VTKM_CONT VariantType operator()(vtkm::cont::internal::Storage, @@ -232,7 +232,7 @@ class Storage> template using StorageFor = vtkm::cont::internal::Storage; - using StorageVariant = vtkm::cont::internal::Variant...>; + using StorageVariant = vtkm::cont::Variant...>; VTKM_CONT static StorageVariant Variant(const std::vector& buffers) { @@ -433,20 +433,6 @@ public: } }; -/// \brief Converts a \c vtkm::ListTag to an \c ArrayHandleMultiplexer -/// -/// The argument of this template must be a vtkm::ListTag and furthermore all the types in -/// the list tag must be some type of \c ArrayHandle. The templated type gets aliased to -/// an \c ArrayHandleMultiplexer that can store any of these ArrayHandle types. -/// -/// Deprecated. Use `ArrayHandleMultiplexerFromList` instead. -/// -template -using ArrayHandleMultiplexerFromListTag VTKM_DEPRECATED( - 1.6, - "vtkm::ListTag is no longer supported. Use vtkm::List instead.") = - vtkm::ListApply; - /// \brief Converts a`vtkm::List` to an `ArrayHandleMultiplexer` /// /// The argument of this template must be a `vtkm::List` and furthermore all the types in diff --git a/vtkm/cont/ArrayHandleReverse.h b/vtkm/cont/ArrayHandleReverse.h index 51918747d..4a41d2905 100644 --- a/vtkm/cont/ArrayHandleReverse.h +++ b/vtkm/cont/ArrayHandleReverse.h @@ -16,8 +16,6 @@ #include #include -#include - namespace vtkm { namespace cont @@ -81,50 +79,13 @@ class VTKM_ALWAYS_EXPORT StorageTagReverse namespace internal { -namespace detail -{ - -template -struct ReverseTypeArgImpl; - -template -struct ReverseTypeArgImpl -{ - using StorageTag = Storage; - using ArrayHandle = vtkm::cont::ArrayHandle; -}; - -template -struct ReverseTypeArgImpl -{ - VTKM_STATIC_ASSERT_MSG((std::is_same::value), - "Used array with wrong type in ArrayHandleReverse."); - using StorageTag VTKM_DEPRECATED( - 1.6, - "Use storage tag instead of array handle in StorageTagReverse.") = typename Array::StorageTag; - using ArrayHandle VTKM_DEPRECATED( - 1.6, - "Use storage tag instead of array handle in StorageTagReverse.") = - vtkm::cont::ArrayHandle; -}; - -template -struct ReverseTypeArg - : ReverseTypeArgImpl::type::value> -{ -}; - -} // namespace detail - template class Storage> { - using SourceStorage = Storage::StorageTag>; + using SourceStorage = Storage; public: - using ArrayHandleType = typename detail::ReverseTypeArg::ArrayHandle; + using ArrayHandleType = vtkm::cont::ArrayHandle; using ReadPortalType = ArrayPortalReverse; using WritePortalType = ArrayPortalReverse; diff --git a/vtkm/cont/ArrayHandleSOA.h b/vtkm/cont/ArrayHandleSOA.h index 1849e5404..552ab5d5a 100644 --- a/vtkm/cont/ArrayHandleSOA.h +++ b/vtkm/cont/ArrayHandleSOA.h @@ -328,24 +328,6 @@ public: VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == NUM_COMPONENTS); } - // This only works if all the templated arguments are of type std::vector. - template -#ifndef VTKM_MSVC - // For some reason, having VTKM_DEPRECATED here is causing a syntax error in some MSVC - // compilers. - VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -#endif - ArrayHandleSOA(const std::vector& vector0, - const RemainingVectors&... componentVectors) - : Superclass(std::vector{ - vtkm::cont::make_ArrayHandle(vector0, vtkm::CopyFlag::Off).GetBuffers()[0], - vtkm::cont::make_ArrayHandle(std::forward(componentVectors), - vtkm::CopyFlag::Off) - .GetBuffers()[0]... }) - { - VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == NUM_COMPONENTS); - } - ArrayHandleSOA(std::initializer_list componentArrays, vtkm::Id length, vtkm::CopyFlag copy) @@ -360,20 +342,6 @@ public: } } - VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") - ArrayHandleSOA(std::initializer_list componentArrays, vtkm::Id length) - { - VTKM_ASSERT(componentArrays.size() == NUM_COMPONENTS); - vtkm::IdComponent componentIndex = 0; - for (auto&& vectorIter = componentArrays.begin(); vectorIter != componentArrays.end(); - ++vectorIter) - { - this->SetArray(componentIndex, - vtkm::cont::make_ArrayHandle(*vectorIter, length, vtkm::CopyFlag::Off)); - ++componentIndex; - } - } - // This only works if all the templated arguments are of type std::vector. template ArrayHandleSOA(vtkm::Id length, @@ -387,24 +355,6 @@ public: VTKM_STATIC_ASSERT(sizeof...(RemainingArrays) + 1 == NUM_COMPONENTS); } - // This only works if all the templated arguments are of type std::vector. - template -#ifndef VTKM_MSVC - // For some reason, having VTKM_DEPRECATED here is causing a syntax error in some MSVC - // compilers. - VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -#endif - ArrayHandleSOA(vtkm::Id length, - const ComponentType* array0, - const RemainingArrays&... componentArrays) - : Superclass(std::vector{ - vtkm::cont::make_ArrayHandle(array0, length, vtkm::CopyFlag::Off).GetBuffers()[0], - vtkm::cont::make_ArrayHandle(componentArrays, length, vtkm::CopyFlag::Off) - .GetBuffers()[0]... }) - { - VTKM_STATIC_ASSERT(sizeof...(RemainingArrays) + 1 == NUM_COMPONENTS); - } - VTKM_CONT vtkm::cont::ArrayHandleBasic GetArray(vtkm::IdComponent index) const { return ComponentArrayType({ this->GetBuffers()[index] }); @@ -471,19 +421,6 @@ VTKM_CONT vtkm::cont::make_ArrayHandle(std::forward(componentVectors), copy)...); } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -VTKM_CONT ArrayHandleSOA< - vtkm::Vec> make_ArrayHandleSOA(const std::vector& vector0, - const RemainingVectors&... componentVectors) -{ - return ArrayHandleSOA< - vtkm::Vec>( - vector0, componentVectors...); -} - // This only works if all the templated arguments are rvalues of std::vector. template VTKM_CONT @@ -505,16 +442,6 @@ VTKM_CONT ArrayHandleSOA make_ArrayHandleSOA( return ArrayHandleSOA(std::move(componentVectors), length, copy); } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -VTKM_CONT ArrayHandleSOA make_ArrayHandleSOA( - std::initializer_list::ComponentType*>&& - componentVectors, - vtkm::Id length) -{ - return vtkm::cont::make_ArrayHandleSOA(std::move(componentVectors), length, vtkm::CopyFlag::Off); -} - // This only works if all the templated arguments are of type std::vector. template VTKM_CONT @@ -529,20 +456,6 @@ VTKM_CONT length, copy, array0, componentArrays...); } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.") -VTKM_CONT ArrayHandleSOA< - vtkm::Vec> make_ArrayHandleSOA(vtkm::Id length, - const ComponentType* array0, - const RemainingArrays*... componentArrays) -{ - return ArrayHandleSOA< - vtkm::Vec>( - length, array0, componentArrays...); -} - namespace internal { diff --git a/vtkm/cont/ArrayHandleView.h b/vtkm/cont/ArrayHandleView.h index 7bc8daa80..ff286439d 100644 --- a/vtkm/cont/ArrayHandleView.h +++ b/vtkm/cont/ArrayHandleView.h @@ -11,7 +11,6 @@ #define vtk_m_cont_ArrayHandleView_h #include -#include #include #include @@ -101,46 +100,10 @@ struct VTKM_ALWAYS_EXPORT StorageTagView namespace internal { -namespace detail -{ - -template -struct ViewTypeArgImpl; - -template -struct ViewTypeArgImpl -{ - using StorageTag = Storage; - using ArrayHandle = vtkm::cont::ArrayHandle; -}; - -template -struct ViewTypeArgImpl -{ - VTKM_STATIC_ASSERT_MSG((std::is_same::value), - "Used array with wrong type in ArrayHandleView."); - using StorageTag VTKM_DEPRECATED(1.6, - "Use storage tag instead of array handle in StorageTagView.") = - typename Array::StorageTag; - using ArrayHandle VTKM_DEPRECATED(1.6, - "Use storage tag instead of array handle in StorageTagView.") = - vtkm::cont::ArrayHandle; -}; - -template -struct ViewTypeArg - : ViewTypeArgImpl::type::value> -{ -}; - -} // namespace detail - template class Storage> { - using ArrayHandleType = typename detail::ViewTypeArg::ArrayHandle; + using ArrayHandleType = vtkm::cont::ArrayHandle; using SourceStorage = Storage; static std::vector SourceBuffers( diff --git a/vtkm/cont/ArrayHandleVirtual.cxx b/vtkm/cont/ArrayHandleVirtual.cxx deleted file mode 100644 index 062573a68..000000000 --- a/vtkm/cont/ArrayHandleVirtual.cxx +++ /dev/null @@ -1,47 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#define vtk_m_cont_ArrayHandleVirtual_cxx -#include - -namespace vtkm -{ -namespace cont -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#define VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(T) \ - template class VTKM_CONT_EXPORT ArrayHandle; \ - template class VTKM_CONT_EXPORT ArrayHandleVirtual; \ - template class VTKM_CONT_EXPORT ArrayHandle, StorageTagVirtual>; \ - template class VTKM_CONT_EXPORT ArrayHandleVirtual>; \ - template class VTKM_CONT_EXPORT ArrayHandle, StorageTagVirtual>; \ - template class VTKM_CONT_EXPORT ArrayHandleVirtual>; \ - template class VTKM_CONT_EXPORT ArrayHandle, StorageTagVirtual>; \ - template class VTKM_CONT_EXPORT ArrayHandleVirtual> - -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(char); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Int8); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::UInt8); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Int16); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::UInt16); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Int32); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::UInt32); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Int64); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::UInt64); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Float32); -VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE(vtkm::Float64); - -#undef VTK_M_ARRAY_HANDLE_VIRTUAL_INSTANTIATE - -VTKM_DEPRECATED_SUPPRESS_END - -} -} //namespace vtkm::cont diff --git a/vtkm/cont/ArrayHandleVirtual.h b/vtkm/cont/ArrayHandleVirtual.h deleted file mode 100644 index eaca10347..000000000 --- a/vtkm/cont/ArrayHandleVirtual.h +++ /dev/null @@ -1,285 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_ArrayHandleVirtual_h -#define vtk_m_cont_ArrayHandleVirtual_h - -#include - -#include -#include -#include -#include - -#include - -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "ArrayHandleVirtual is removed. Do not include ArrayHandleVirtual.h" -#endif - -namespace vtkm -{ -namespace cont -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -template -VTKM_ARRAY_HANDLE_DEPRECATED(T, vtkm::cont::StorageTagVirtual); - -template -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6) ArrayHandleVirtual - : public vtkm::cont::ArrayHandle -{ - using StorageType = vtkm::cont::internal::Storage; - -public: - VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleVirtual, - (ArrayHandleVirtual), - (vtkm::cont::ArrayHandle)); - - ///Construct a valid ArrayHandleVirtual from an existing ArrayHandle - ///that doesn't derive from ArrayHandleVirtual. - ///Note left non-explicit to allow: - /// - /// std::vector> vectorOfArrays; - /// //Make basic array. - /// vtkm::cont::ArrayHandle basicArray; - /// //Fill basicArray... - /// vectorOfArrays.push_back(basicArray); - /// - /// // Make fancy array. - /// vtkm::cont::ArrayHandleCounting fancyArray(-1.0, 0.1, ARRAY_SIZE); - /// vectorOfArrays.push_back(fancyArray); - template - ArrayHandleVirtual(const vtkm::cont::ArrayHandle& ah) - : Superclass(StorageType(ah)) - { - using is_base = std::is_base_of; - static_assert(!is_base::value, "Wrong specialization for ArrayHandleVirtual selected"); - } - - /// Returns true if this array matches the type passed in. - /// - template - VTKM_CONT bool IsType() const - { - VTKM_IS_ARRAY_HANDLE(ArrayHandleType); - - //We need to determine if we are checking that `ArrayHandleType` - //is a virtual array handle since that is an easy check. - //Or if we have to go ask the storage if they are holding - // - using ST = typename ArrayHandleType::StorageTag; - using is_base = std::is_same; - - //Determine if the Value type of the virtual and ArrayHandleType - //are the same. This an easy compile time check, and doesn't need - // to be done at runtime. - using VT = typename ArrayHandleType::ValueType; - using same_value_type = std::is_same; - - return this->IsSameType(same_value_type{}, is_base{}); - } - - /// Returns this array cast to the given \c ArrayHandle type. Throws \c - /// ErrorBadType if the cast does not work. Use \c IsType - /// to check if the cast can happen. - /// - template - VTKM_CONT ArrayHandleType Cast() const - { - VTKM_IS_ARRAY_HANDLE(ArrayHandleType); - //We need to determine if we are checking that `ArrayHandleType` - //is a virtual array handle since that is an easy check. - //Or if we have to go ask the storage if they are holding - // - using ST = typename ArrayHandleType::StorageTag; - using is_base = std::is_same; - - //Determine if the Value type of the virtual and ArrayHandleType - //are the same. This an easy compile time check, and doesn't need - // to be done at runtime. - using VT = typename ArrayHandleType::ValueType; - using same_value_type = std::is_same; - - return this->CastToType(same_value_type{}, is_base{}); - } - - /// Returns a new instance of an ArrayHandleVirtual with the same storage - /// - VTKM_CONT ArrayHandleVirtual NewInstance() const - { - return ArrayHandleVirtual(this->GetStorage().NewInstance()); - } - -private: - template - inline bool IsSameType(std::false_type, std::true_type) const - { - return false; - } - template - inline bool IsSameType(std::false_type, std::false_type) const - { - return false; - } - - template - inline bool IsSameType(std::true_type vtkmNotUsed(valueTypesMatch), - std::true_type vtkmNotUsed(inheritsFromArrayHandleVirtual)) const - { - //The type being past has no requirements in being the most derived type - //so the typeid info won't match but dynamic_cast will work - auto casted = dynamic_cast(this); - return casted != nullptr; - } - - template - inline bool IsSameType(std::true_type vtkmNotUsed(valueTypesMatch), - std::false_type vtkmNotUsed(notFromArrayHandleVirtual)) const - { - auto* storage = this->GetStorage().GetStorageVirtual(); - if (!storage) - { - return false; - } - using S = typename ArrayHandleType::StorageTag; - return storage->template IsType>(); - } - - template - inline ArrayHandleType CastToType(std::false_type vtkmNotUsed(valueTypesMatch), - std::true_type vtkmNotUsed(notFromArrayHandleVirtual)) const - { - VTKM_LOG_CAST_FAIL(*this, ArrayHandleType); - throwFailedDynamicCast("ArrayHandleVirtual", vtkm::cont::TypeToString()); - return ArrayHandleType{}; - } - - template - inline ArrayHandleType CastToType(std::false_type vtkmNotUsed(valueTypesMatch), - std::false_type vtkmNotUsed(notFromArrayHandleVirtual)) const - { - VTKM_LOG_CAST_FAIL(*this, ArrayHandleType); - throwFailedDynamicCast("ArrayHandleVirtual", vtkm::cont::TypeToString()); - return ArrayHandleType{}; - } - - template - inline ArrayHandleType CastToType( - std::true_type vtkmNotUsed(valueTypesMatch), - std::true_type vtkmNotUsed(inheritsFromArrayHandleVirtual)) const - { - //The type being passed has no requirements in being the most derived type - //so the typeid info won't match but dynamic_cast will work - const ArrayHandleType* derived = dynamic_cast(this); - if (!derived) - { - VTKM_LOG_CAST_FAIL(*this, ArrayHandleType); - throwFailedDynamicCast("ArrayHandleVirtual", vtkm::cont::TypeToString()); - } - VTKM_LOG_CAST_SUCC(*this, derived); - return *derived; - } - - template - ArrayHandleType CastToType(std::true_type vtkmNotUsed(valueTypesMatch), - std::false_type vtkmNotUsed(notFromArrayHandleVirtual)) const; -}; - - -//============================================================================= -/// A convenience function for creating an ArrayHandleVirtual. -template -VTKM_CONT vtkm::cont::ArrayHandleVirtual make_ArrayHandleVirtual( - const vtkm::cont::ArrayHandle& ah) -{ - return vtkm::cont::ArrayHandleVirtual(ah); -} - -//============================================================================= -// Free function casting helpers - -/// Returns true if \c virtHandle matches the type of ArrayHandleType. -/// -template -VTKM_CONT inline bool IsType( - const vtkm::cont::ArrayHandle& virtHandle) -{ - return static_cast>(virtHandle) - .template IsType(); -} - -/// Returns \c virtHandle cast to the given \c ArrayHandle type. Throws \c -/// ErrorBadType if the cast does not work. Use \c IsType -/// to check if the cast can happen. -/// -template -VTKM_CONT inline ArrayHandleType Cast( - const vtkm::cont::ArrayHandle& virtHandle) -{ - return static_cast>(virtHandle) - .template Cast(); -} -//============================================================================= -// Specializations of serialization related classes -/// @cond SERIALIZATION -template -struct SerializableTypeString> -{ - static VTKM_CONT const std::string& Get() - { - static std::string name = "AH_Virtual<" + SerializableTypeString::Get() + ">"; - return name; - } -}; - -template -struct SerializableTypeString> - : public SerializableTypeString> -{ -}; - -#ifndef vtk_m_cont_ArrayHandleVirtual_cxx - -#define VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(T) \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleVirtual; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle, StorageTagVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle, StorageTagVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle, StorageTagVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleVirtual> - -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(char); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Int8); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::UInt8); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Int16); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::UInt16); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Int32); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::UInt32); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Int64); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::UInt64); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Float32); -VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(vtkm::Float64); - -#undef VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT - -#endif //vtk_m_cont_ArrayHandleVirtual_cxx -VTKM_DEPRECATED_SUPPRESS_END -} -} //namespace vtkm::cont - -/// @endcond SERIALIZATION - -#endif //vtk_m_cont_ArrayHandleVirtual_h diff --git a/vtkm/cont/ArrayHandleVirtual.hxx b/vtkm/cont/ArrayHandleVirtual.hxx deleted file mode 100644 index d96e59ba0..000000000 --- a/vtkm/cont/ArrayHandleVirtual.hxx +++ /dev/null @@ -1,186 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_ArrayHandleVirtual_hxx -#define vtk_m_cont_ArrayHandleVirtual_hxx - -#include -#include - -VTKM_DEPRECATED_SUPPRESS_BEGIN -namespace vtkm -{ -namespace cont -{ - -template -template -ArrayHandleType inline ArrayHandleVirtual::CastToType( - std::true_type vtkmNotUsed(valueTypesMatch), - std::false_type vtkmNotUsed(notFromArrayHandleVirtual)) const -{ - auto* storage = this->GetStorage().GetStorageVirtual(); - if (!storage) - { - VTKM_LOG_CAST_FAIL(*this, ArrayHandleType); - throwFailedDynamicCast("ArrayHandleVirtual", vtkm::cont::TypeToString()); - } - using S = typename ArrayHandleType::StorageTag; - const auto* castStorage = - storage->template Cast>(); - return castStorage->GetHandle(); -} -} -} // namespace vtkm::cont -VTKM_DEPRECATED_SUPPRESS_END - - -#include -#include - -//============================================================================= -// Specializations of serialization related classes -/// @cond SERIALIZATION -VTKM_DEPRECATED_SUPPRESS_BEGIN -namespace mangled_diy_namespace -{ - -template -struct Serialization> -{ - - static VTKM_CONT void save(vtkmdiy::BinaryBuffer& bb, - const vtkm::cont::ArrayHandleVirtual& obj) - { - vtkm::cont::ArrayHandle array; - if (obj.template IsType()) - { - array = obj.template Cast(); - } - else - { - vtkm::Id size = obj.GetNumberOfValues(); - array.Allocate(size); - auto src = obj.ReadPortal(); - auto dest = array.WritePortal(); - for (vtkm::IdComponent index = 0; index < size; ++index) - { - dest.Set(index, src.Get(index)); - } - } - vtkmdiy::save(bb, array); - } - - static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::ArrayHandleVirtual& obj) - { - vtkm::cont::ArrayHandle array; - vtkmdiy::load(bb, array); - obj = std::move(vtkm::cont::ArrayHandleVirtual{ array }); - } -}; - -template -struct IntAnySerializer -{ - using CountingType = vtkm::cont::ArrayHandleCounting; - using ConstantType = vtkm::cont::ArrayHandleConstant; - using BasicType = vtkm::cont::ArrayHandle; - - static VTKM_CONT void save(vtkmdiy::BinaryBuffer& bb, - const vtkm::cont::ArrayHandleVirtual& obj) - { - if (obj.template IsType()) - { - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - - using S = typename CountingType::StorageTag; - const vtkm::cont::internal::detail::StorageVirtual* storage = - obj.GetStorage().GetStorageVirtual(); - auto* castStorage = storage->Cast>(); - vtkmdiy::save(bb, castStorage->GetHandle()); - } - else if (obj.template IsType()) - { - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - - using S = typename ConstantType::StorageTag; - const vtkm::cont::internal::detail::StorageVirtual* storage = - obj.GetStorage().GetStorageVirtual(); - auto* castStorage = storage->Cast>(); - vtkmdiy::save(bb, castStorage->GetHandle()); - } - else - { - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - BasicType array; - vtkm::Id size = obj.GetNumberOfValues(); - array.Allocate(size); - auto src = obj.ReadPortal(); - auto dest = array.WritePortal(); - for (vtkm::IdComponent index = 0; index < size; ++index) - { - dest.Set(index, src.Get(index)); - } - vtkmdiy::save(bb, array); - } - } - - static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::ArrayHandleVirtual& obj) - { - std::string typeString; - vtkmdiy::load(bb, typeString); - - if (typeString == vtkm::cont::SerializableTypeString::Get()) - { - CountingType array; - vtkmdiy::load(bb, array); - obj = std::move(vtkm::cont::ArrayHandleVirtual{ array }); - } - else if (typeString == vtkm::cont::SerializableTypeString::Get()) - { - ConstantType array; - vtkmdiy::load(bb, array); - obj = std::move(vtkm::cont::ArrayHandleVirtual{ array }); - } - else - { - vtkm::cont::ArrayHandle array; - vtkmdiy::load(bb, array); - obj = std::move(vtkm::cont::ArrayHandleVirtual{ array }); - } - } -}; - - -template <> -struct Serialization> - : public IntAnySerializer -{ -}; -template <> -struct Serialization> - : public IntAnySerializer -{ -}; -template <> -struct Serialization> - : public IntAnySerializer -{ -}; - -template -struct Serialization> - : public Serialization> -{ -}; - -} // mangled_diy_namespace -VTKM_DEPRECATED_SUPPRESS_END - -#endif diff --git a/vtkm/cont/ArrayHandleVirtualCoordinates.h b/vtkm/cont/ArrayHandleVirtualCoordinates.h deleted file mode 100644 index bebb5b7f2..000000000 --- a/vtkm/cont/ArrayHandleVirtualCoordinates.h +++ /dev/null @@ -1,191 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_ArrayHandleVirtualCoordinates_h -#define vtk_m_cont_ArrayHandleVirtualCoordinates_h - -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "ArrayHandleVirtualCoordiantes is removed. Do not include ArrayHandleVirtualCoordinates.h" -#endif - -namespace vtkm -{ -namespace cont -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -/// ArrayHandleVirtualCoordinates is a specialization of ArrayHandle. -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Virtual ArrayHandles are being phased out.") - ArrayHandleVirtualCoordinates final : public vtkm::cont::ArrayHandleVirtual -{ -public: - VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleVirtualCoordinates, - (vtkm::cont::ArrayHandleVirtual)); - - template - explicit ArrayHandleVirtualCoordinates(const vtkm::cont::ArrayHandle& ah) - : vtkm::cont::ArrayHandleVirtual(vtkm::cont::make_ArrayHandleCast(ah)) - { - } -}; - -template -void CastAndCall(const vtkm::cont::ArrayHandleVirtualCoordinates& coords, - Functor&& f, - Args&&... args) -{ - using HandleType = ArrayHandleUniformPointCoordinates; - if (coords.IsType()) - { - HandleType uniform = coords.Cast(); - f(uniform, std::forward(args)...); - } - else - { - f(coords, std::forward(args)...); - } -} - - -template <> -struct SerializableTypeString -{ - static VTKM_CONT const std::string Get() { return "AH_VirtualCoordinates"; } -}; - -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace cont -} // namespace vtkm - -//============================================================================= -// Specializations of serialization related classes -/// @cond SERIALIZATION -namespace mangled_diy_namespace -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -template <> -struct Serialization -{ -private: - using Type = vtkm::cont::ArrayHandleVirtualCoordinates; - using BaseType = vtkm::cont::ArrayHandle; - - using BasicCoordsType = vtkm::cont::ArrayHandle; - using RectilinearCoordsArrayType = - vtkm::cont::ArrayHandleCartesianProduct, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle>; - -public: - static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& baseObj) - { - Type obj(baseObj); - const vtkm::cont::internal::detail::StorageVirtual* storage = - obj.GetStorage().GetStorageVirtual(); - if (obj.IsType()) - { - using HandleType = vtkm::cont::ArrayHandleUniformPointCoordinates; - using T = typename HandleType::ValueType; - using S = typename HandleType::StorageTag; - auto array = storage->Cast>(); - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - vtkmdiy::save(bb, array->GetHandle()); - } - else if (obj.IsType()) - { - using HandleType = RectilinearCoordsArrayType; - using T = typename HandleType::ValueType; - using S = typename HandleType::StorageTag; - auto array = storage->Cast>(); - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - vtkmdiy::save(bb, array->GetHandle()); - } - else - { - using HandleType = BasicCoordsType; - using T = typename HandleType::ValueType; - using S = typename HandleType::StorageTag; - HandleType array; - if (obj.IsType()) - { - // If the object actually is a BasicCoordsType, just save it. - array = - storage->Cast>()->GetHandle(); - } - else - { - // Give up and deep copy data. - vtkm::Id size = obj.GetNumberOfValues(); - array.Allocate(size); - auto src = obj.ReadPortal(); - auto dest = array.WritePortal(); - for (vtkm::IdComponent index = 0; index < size; ++index) - { - dest.Set(index, src.Get(index)); - } - } - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - vtkmdiy::save(bb, array); - } - } - - static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj) - { - std::string typeString; - vtkmdiy::load(bb, typeString); - - if (typeString == - vtkm::cont::SerializableTypeString::Get()) - { - vtkm::cont::ArrayHandleUniformPointCoordinates array; - vtkmdiy::load(bb, array); - obj = vtkm::cont::ArrayHandleVirtualCoordinates(array); - } - else if (typeString == vtkm::cont::SerializableTypeString::Get()) - { - RectilinearCoordsArrayType array; - vtkmdiy::load(bb, array); - obj = vtkm::cont::ArrayHandleVirtualCoordinates(array); - } - else if (typeString == vtkm::cont::SerializableTypeString::Get()) - { - BasicCoordsType array; - vtkmdiy::load(bb, array); - obj = vtkm::cont::ArrayHandleVirtualCoordinates(array); - } - else - { - throw vtkm::cont::ErrorBadType( - "Error deserializing ArrayHandleVirtualCoordinates. TypeString: " + typeString); - } - } -}; - -VTKM_DEPRECATED_SUPPRESS_END - -} // diy -/// @endcond SERIALIZATION - -#endif // vtk_m_cont_ArrayHandleVirtualCoordinates_h diff --git a/vtkm/cont/ArrayRangeCompute.hxx b/vtkm/cont/ArrayRangeCompute.hxx deleted file mode 100644 index d382ce9f2..000000000 --- a/vtkm/cont/ArrayRangeCompute.hxx +++ /dev/null @@ -1,29 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_ArrayRangeCompute_hxx -#define vtk_m_cont_ArrayRangeCompute_hxx - -#include -#include - -namespace vtkm -{ - -VTKM_DEPRECATED(1.6, "Use ArrayRangeComputeTemplate.h instead of ArrayRangeCompute.hxx.") -inline void ArrayRangeCompute_hxx_deprecated() {} - -inline void ActivateArrayRangeCompute_hxx_deprecated_warning() -{ - ArrayRangeCompute_hxx_deprecated(); -} - -} // namespace vtkm - -#endif //vtk_m_cont_ArrayRangeCompute_hxx diff --git a/vtkm/cont/ArrayRangeComputeTemplate.h b/vtkm/cont/ArrayRangeComputeTemplate.h index cd67d327d..2e593e1aa 100644 --- a/vtkm/cont/ArrayRangeComputeTemplate.h +++ b/vtkm/cont/ArrayRangeComputeTemplate.h @@ -17,10 +17,6 @@ #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif - #include namespace vtkm @@ -100,49 +96,6 @@ inline vtkm::cont::ArrayHandle ArrayRangeComputeImpl( } // namespace detail -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN -VTKM_CONT -inline vtkm::cont::ArrayHandle ArrayRangeCompute( - const vtkm::cont::ArrayHandleVirtual& input, - vtkm::cont::DeviceAdapterId device) -{ - using UniformHandleType = ArrayHandleUniformPointCoordinates; - using RectilinearHandleType = - vtkm::cont::ArrayHandleCartesianProduct, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle>; - - if (input.IsType()) - { - using T = typename UniformHandleType::ValueType; - using S = typename UniformHandleType::StorageTag; - const vtkm::cont::internal::detail::StorageVirtual* storage = - input.GetStorage().GetStorageVirtual(); - const auto* castStorage = - storage->Cast>(); - - return ArrayRangeCompute(castStorage->GetHandle(), device); - } - else if (input.IsType()) - { - using T = typename RectilinearHandleType::ValueType; - using S = typename RectilinearHandleType::StorageTag; - const vtkm::cont::internal::detail::StorageVirtual* storage = - input.GetStorage().GetStorageVirtual(); - const auto* castStorage = - storage->Cast>(); - - return ArrayRangeCompute(castStorage->GetHandle(), device); - } - else - { - return detail::ArrayRangeComputeImpl(input, device); - } -} -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - template inline vtkm::cont::ArrayHandle ArrayRangeCompute( const ArrayHandleType& input, diff --git a/vtkm/cont/AtomicArray.h b/vtkm/cont/AtomicArray.h index 72ccc2815..eeeab6264 100644 --- a/vtkm/cont/AtomicArray.h +++ b/vtkm/cont/AtomicArray.h @@ -10,7 +10,6 @@ #ifndef vtk_m_cont_AtomicArray_h #define vtk_m_cont_AtomicArray_h -#include #include #include #include @@ -18,11 +17,6 @@ #include #include -// Support deprecated features -VTKM_DEPRECATED_SUPPRESS_BEGIN -#include -VTKM_DEPRECATED_SUPPRESS_END - namespace vtkm { namespace cont @@ -33,13 +27,6 @@ namespace cont /// @cond NONE using AtomicArrayTypeList = vtkm::List; - -struct VTKM_DEPRECATED(1.6, - "AtomicArrayTypeListTag replaced by AtomicArrayTypeList. Note that the " - "new AtomicArrayTypeList cannot be subclassed.") AtomicArrayTypeListTag - : vtkm::internal::ListAsListTag -{ -}; /// @endcond @@ -86,14 +73,6 @@ public: return vtkm::exec::AtomicArrayExecutionObject(this->Handle, device, token); } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object.") - vtkm::exec::AtomicArrayExecutionObject PrepareForExecution(Device device) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); - } - private: /// @cond NONE vtkm::cont::ArrayHandle Handle; diff --git a/vtkm/cont/BitField.cxx b/vtkm/cont/BitField.cxx index cef32e6cd..82a0fa842 100644 --- a/vtkm/cont/BitField.cxx +++ b/vtkm/cont/BitField.cxx @@ -11,28 +11,6 @@ #include #include -namespace -{ - -struct DeviceCheckFunctor -{ - vtkm::cont::DeviceAdapterId FoundDevice = vtkm::cont::DeviceAdapterTagUndefined{}; - - VTKM_CONT void operator()(vtkm::cont::DeviceAdapterId device, - const vtkm::cont::internal::Buffer& buffer) - { - if (this->FoundDevice == vtkm::cont::DeviceAdapterTagUndefined{}) - { - if (buffer.IsAllocatedOnDevice(device)) - { - this->FoundDevice = device; - } - } - } -}; - -} // anonymous namespace - namespace vtkm { namespace cont @@ -100,13 +78,6 @@ bool BitField::IsOnDevice(vtkm::cont::DeviceAdapterId device) const return this->Buffer.IsAllocatedOnDevice(device); } -vtkm::cont::DeviceAdapterId BitField::GetDeviceAdapterId() const -{ - DeviceCheckFunctor functor; - vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST{}, this->Buffer); - return functor.FoundDevice; -} - BitField::WritePortalType BitField::WritePortal() const { vtkm::cont::Token token; diff --git a/vtkm/cont/BitField.h b/vtkm/cont/BitField.h index 68243d442..aed7e0bab 100644 --- a/vtkm/cont/BitField.h +++ b/vtkm/cont/BitField.h @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -458,13 +457,6 @@ public: return true; } - VTKM_DEPRECATED(1.6, "Use CompareExchangeBitAtomic. (Note the changed interface.)") - VTKM_EXEC_CONT bool CompareAndSwapBitAtomic(vtkm::Id bitIdx, bool newBit, bool expectedBit) const - { - this->CompareExchangeBitAtomic(bitIdx, &expectedBit, newBit); - return expectedBit; - } - /// Perform an atomic compare-exchange operation on the word at @a wordIdx. /// If the word in memory is equal to @a oldWord, it is replaced with /// the value of @a newWord and true returned. If the word in memory is not @@ -484,15 +476,6 @@ public: return vtkm::AtomicCompareExchange(addr, oldWord, newWord); } - template - VTKM_DEPRECATED(1.6, "Use CompareExchangeWordAtomic. (Note the changed interface.)") - VTKM_EXEC_CONT WordType - CompareAndSwapWordAtomic(vtkm::Id wordIdx, WordType newWord, WordType expected) const - { - this->CompareExchangeWordAtomic(wordIdx, &expected, newWord); - return expected; - } - private: template VTKM_EXEC_CONT MaybeConstPointer GetWordAddress(vtkm::Id wordId) const noexcept @@ -509,21 +492,6 @@ using BitPortal = BitPortalBase; using BitPortalConst = BitPortalBase; -template -struct IsValidWordTypeDeprecated -{ - using type VTKM_DEPRECATED( - 1.6, - "BitField::IsValidWordTypeAtomic no longer takes a second Device parameter.") = - detail::BitFieldTraits::IsValidWordTypeAtomic; -}; - -template -struct IsValidWordTypeDeprecated -{ - using type = detail::BitFieldTraits::IsValidWordTypeAtomic; -}; - } // end namespace detail class VTKM_CONT_EXPORT BitField @@ -531,21 +499,12 @@ class VTKM_CONT_EXPORT BitField static constexpr vtkm::Id BlockSize = detail::BitFieldTraits::BlockSize; public: - /// The type array handle used to store the bit data internally: - using ArrayHandleType VTKM_DEPRECATED(1.6, "BitField now uses a Buffer to store data.") = - ArrayHandle; - /// The BitPortal used in the control environment. using WritePortalType = detail::BitPortal; /// A read-only BitPortal used in the control environment. using ReadPortalType = detail::BitPortalConst; - using PortalControl VTKM_DEPRECATED(1.6, - "Use BitField::WritePortalType instead.") = detail::BitPortal; - using PortalConstControl VTKM_DEPRECATED(1.6, "Use ArrayBitField::ReadPortalType instead.") = - detail::BitPortalConst; - using WordTypePreferred = vtkm::AtomicTypePreferred; template @@ -569,12 +528,6 @@ public: template using IsValidWordTypeAtomic = detail::BitFieldTraits::IsValidWordTypeAtomic; - /// Check whether a word type is valid for atomic operations from the control - /// environment. - template - using IsValidWordTypeAtomicControl VTKM_DEPRECATED(1.6, "Use IsValidWordTypeAtomic instead.") = - detail::BitFieldTraits::IsValidWordTypeAtomic; - VTKM_CONT BitField(); VTKM_CONT BitField(const BitField&) = default; VTKM_CONT BitField(BitField&&) noexcept = default; @@ -591,14 +544,6 @@ public: /// Return the internal `Buffer` used to store the `BitField`. VTKM_CONT vtkm::cont::internal::Buffer GetBuffer() const { return this->Buffer; } - /// Return the internal ArrayHandle used to store the BitField. - VTKM_CONT VTKM_DEPRECATED(1.6, "BitField now uses a Buffer to store data.") - ArrayHandle GetData() const - { - return vtkm::cont::ArrayHandle( - std::vector(1, this->Buffer)); - } - /// Return the number of bits stored by this BitField. VTKM_CONT vtkm::Id GetNumberOfBits() const; @@ -672,13 +617,6 @@ public: this->Fill(value, token); } - /// Shrink the bit field to the requested number of bits. - VTKM_CONT VTKM_DEPRECATED(1.6, - "Use Allocate with preserve = On.") void Shrink(vtkm::Id numberOfBits) - { - this->Allocate(numberOfBits, vtkm::CopyFlag::On); - } - /// Release all execution-side resources held by this BitField. VTKM_CONT void ReleaseResourcesExecution(); @@ -701,9 +639,6 @@ public: return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{}); } - VTKM_CONT VTKM_DEPRECATED(1.6, "Data can be on multiple devices. Use IsOnDevice.") - vtkm::cont::DeviceAdapterId GetDeviceAdapterId() const; - /// \brief Get a portal to the data that is usable from the control environment. /// /// As long as this portal is in scope, no one else will be able to read or write the BitField. @@ -714,20 +649,6 @@ public: /// As long as this portal is in scope, no one else will be able to write in the BitField. VTKM_CONT ReadPortalType ReadPortal() const; - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use BitField::WritePortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - detail::BitPortal GetPortalControl() { return this->WritePortal(); } - - /// Get a read-only portal to the data that is usable from the control - /// environment. - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use BitField::ReadPortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - detail::BitPortalConst GetPortalConstControl() const { return this->ReadPortal(); } - /// Prepares this BitField to be used as an input to an operation in the /// execution environment. If necessary, copies data to the execution /// environment. Can throw an exception if this BitField does not yet contain @@ -736,15 +657,6 @@ public: VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const; - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInput now requires a vtkm::cont::Token object.") - typename ExecutionTypes::PortalConst - PrepareForInput(DeviceAdapterTag device) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, token); - } - /// Prepares (allocates) this BitField to be used as an output from an /// operation in the execution environment. The internal state of this class /// is set to have valid data in the execution BitField with the assumption @@ -755,15 +667,6 @@ public: vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const; - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForOutput now requires a vtkm::cont::Token object.") - typename ExecutionTypes::Portal - PrepareForOutput(vtkm::Id numBits, DeviceAdapterTag device) const - { - vtkm::cont::Token token; - return this->PrepareForOutput(numBits, device, token); - } - /// Prepares this BitField to be used in an in-place operation (both as input /// and output) in the execution environment. If necessary, copies data to /// the execution environment. Can throw an exception if this BitField does @@ -772,15 +675,6 @@ public: VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const; - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInPlace now requires a vtkm::cont::Token object.") - typename ExecutionTypes::Portal - PrepareForInPlace(DeviceAdapterTag device) const - { - vtkm::cont::Token token; - return this->PrepareForInPlace(device, token); - } - private: mutable vtkm::cont::internal::Buffer Buffer; }; diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index 460168639..17273aee9 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -59,6 +59,7 @@ set(headers CellLocatorBoundingIntervalHierarchy.h CellLocatorChooser.h CellLocatorGeneral.h + CellLocatorPartitioned.h CellLocatorRectilinearGrid.h CellLocatorTwoLevel.h CellLocatorUniformBins.h @@ -67,7 +68,6 @@ set(headers CellSetExplicit.h CellSetExtrude.h CellSetList.h - CellSetListTag.h CellSetPermutation.h CellSetSingleType.h CellSetStructured.h @@ -81,13 +81,10 @@ set(headers DataSetBuilderExplicit.h DataSetBuilderRectilinear.h DataSetBuilderUniform.h - DataSetFieldAdd.h DeviceAdapter.h DeviceAdapterAlgorithm.h DeviceAdapterList.h - DeviceAdapterListTag.h DeviceAdapterTag.h - DynamicCellSet.h # Deprecated, replaced by Unknown/UncertainCellSet.h EnvironmentTracker.h Error.h ErrorBadAllocation.h @@ -102,22 +99,18 @@ set(headers Field.h FieldRangeCompute.h FieldRangeGlobalCompute.h - ImplicitFunctionHandle.h Initialize.h Invoker.h Logging.h MergePartitionedDataSet.h ParticleArrayCopy.h PartitionedDataSet.h - PointLocatorUniformGrid.h PointLocatorSparseGrid.h RuntimeDeviceInformation.h RuntimeDeviceTracker.h Serialization.h Storage.h - StorageImplicit.h # Deprecated, rolled into ArrayHandleImplicit.h StorageList.h - StorageListTag.h Timer.h Token.h TryExecute.h @@ -126,14 +119,12 @@ set(headers UncertainCellSet.h UnknownArrayHandle.h UnknownCellSet.h - VariantArrayHandle.h # Deprecated, replaces with Unknown/UncertainArrayHandle.h + Variant.h ) set(template_sources - ArrayRangeCompute.hxx # Deprecated, replaced with ArrayRangeComputeTemplate.h CellSetExplicit.hxx ParticleArrayCopy.hxx - VirtualObjectHandle.hxx ) set(sources @@ -147,7 +138,9 @@ set(sources BoundsCompute.cxx BoundsGlobalCompute.cxx CellLocatorGeneral.cxx + CellLocatorPartitioned.cxx CellLocatorRectilinearGrid.cxx + CellLocatorUniformBins.cxx CellLocatorUniformGrid.cxx CellSet.cxx CellSetStructured.cxx @@ -181,18 +174,6 @@ set(sources UnknownCellSet.cxx ) -if(VTKm_ENABLE_TESTING_LIBRARY) - list(APPEND sources - # This file should really be part of the vtkm_cont_testing library (in the testing - # subdirectory) It supports external code using deprecated functionality. In particular, - # testing/MakeTestDataSet.h now needs symbols compiled in MakeTestDataSet.cxx, but the - # deprecated behavior expects to only need to include vtkm_cont. As a workaround, add the code - # to vtkm_cont for now. This should probably be changed back to be in vtkm_cont_testing for the - # 2.0 release. - testing/MakeTestDataSet.cxx - ) -endif() - # 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 @@ -200,6 +181,7 @@ set(device_sources ArrayGetValues.cxx ArrayRangeCompute.cxx CellLocatorBoundingIntervalHierarchy.cxx + CellLocatorUniformBins.cxx CellLocatorTwoLevel.cxx CellSetExplicit.cxx CellSetExtrude.cxx @@ -215,31 +197,6 @@ set(device_sources Timer.cxx ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - ArrayHandleVirtual.h - ArrayHandleVirtualCoordinates.h - CellLocator.h - PointLocator.h - StorageVirtual.h - VirtualObjectHandle.h - ) - - set(template_sources ${template_sources} - ArrayHandleVirtual.hxx - StorageVirtual.hxx - ) - - set(device_sources ${device_sources} - ArrayHandleVirtual.cxx - CellLocator.cxx - internal/TransferInfo.cxx - internal/VirtualObjectTransfer.cxx - PointLocator.cxx - StorageVirtual.cxx - ) -endif() - #----------------------------------------------------------------------------- # Set up default types, which can be custom configured by other build systems. vtkm_get_kit_name(kit_name kit_dir) @@ -312,21 +269,16 @@ vtkm_library( NAME vtkm_cont add_subdirectory(internal) add_subdirectory(arg) -add_subdirectory(serial) -add_subdirectory(tbb) -add_subdirectory(openmp) -add_subdirectory(cuda) -add_subdirectory(kokkos) set(backends ) -if(TARGET vtkm::tbb) - list(APPEND backends vtkm::tbb) +if(TARGET vtkm_tbb) + list(APPEND backends vtkm_tbb) endif() -if(TARGET vtkm::cuda) - list(APPEND backends vtkm::cuda) +if(TARGET vtkm_cuda) + list(APPEND backends vtkm_cuda) endif() -if(TARGET vtkm::openmp) - list(APPEND backends vtkm::openmp) +if(TARGET vtkm_openmp) + list(APPEND backends vtkm_openmp) endif() if(TARGET vtkm::kokkos) list(APPEND backends vtkm::kokkos) @@ -334,12 +286,3 @@ endif() target_link_libraries(vtkm_cont PUBLIC vtkm_compiler_flags ${backends}) target_link_libraries(vtkm_cont PUBLIC Threads::Threads) -target_link_libraries(vtkm_cont PUBLIC vtkm_optionparser vtkm_diy vtkm_lcl) -if(TARGET vtkm_loguru) - target_link_libraries(vtkm_cont PRIVATE vtkm_loguru) -endif() - -#----------------------------------------------------------------------------- -if(VTKm_ENABLE_TESTING_LIBRARY) - add_subdirectory(testing) -endif() diff --git a/vtkm/cont/CellLocator.cxx b/vtkm/cont/CellLocator.cxx deleted file mode 100644 index 146290e45..000000000 --- a/vtkm/cont/CellLocator.cxx +++ /dev/null @@ -1,21 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include - -namespace vtkm -{ -namespace cont -{ -VTKM_DEPRECATED_SUPPRESS_BEGIN -CellLocator::~CellLocator() = default; -VTKM_DEPRECATED_SUPPRESS_END -} -} diff --git a/vtkm/cont/CellLocator.h b/vtkm/cont/CellLocator.h deleted file mode 100644 index a4c6596dc..000000000 --- a/vtkm/cont/CellLocator.h +++ /dev/null @@ -1,96 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_CellLocator_h -#define vtk_m_cont_CellLocator_h - -#include - -#include -#include -#include -#include -#include - -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "CellLocator with virtual methods is removed. Do not include CellLocator.h" -#endif - -namespace vtkm -{ -namespace cont -{ - -class VTKM_CONT_EXPORT VTKM_DEPRECATED(1.6, - "CellLocator with virtual methods no longer supported. Use " - "CellLocatorGeneral or CellLocatorChooser.") CellLocator - : public vtkm::cont::ExecutionObjectBase -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - -public: - virtual ~CellLocator(); - - const vtkm::cont::UnknownCellSet& GetCellSet() const { return this->CellSet; } - - void SetCellSet(const vtkm::cont::UnknownCellSet& cellSet) - { - this->CellSet = cellSet; - this->SetModified(); - } - - const vtkm::cont::CoordinateSystem& GetCoordinates() const { return this->Coords; } - - void SetCoordinates(const vtkm::cont::CoordinateSystem& coords) - { - this->Coords = coords; - this->SetModified(); - } - - void Update() - { - if (this->Modified) - { - this->Build(); - this->Modified = false; - } - } - - VTKM_CONT virtual const vtkm::exec::CellLocator* PrepareForExecution( - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const = 0; - - VTKM_CONT - VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object.") - const vtkm::exec::CellLocator* PrepareForExecution(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); - } - -protected: - void SetModified() { this->Modified = true; } - bool GetModified() const { return this->Modified; } - - //This is going to need a TryExecute - VTKM_CONT virtual void Build() = 0; - -private: - vtkm::cont::UnknownCellSet CellSet; - vtkm::cont::CoordinateSystem Coords; - bool Modified = true; -}; -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace cont -} // namespace vtkm - -#endif // vtk_m_cont_CellLocator_h diff --git a/vtkm/cont/CellLocatorGeneral.h b/vtkm/cont/CellLocatorGeneral.h index cf4461478..85b4d63f6 100644 --- a/vtkm/cont/CellLocatorGeneral.h +++ b/vtkm/cont/CellLocatorGeneral.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -60,7 +60,7 @@ public: vtkm::cont::Token& token) const; private: - vtkm::cont::internal::ListAsVariant LocatorImpl; + vtkm::cont::ListAsVariant LocatorImpl; friend Superclass; VTKM_CONT void Build(); diff --git a/vtkm/cont/CellLocatorPartitioned.cxx b/vtkm/cont/CellLocatorPartitioned.cxx new file mode 100644 index 000000000..6eb42e796 --- /dev/null +++ b/vtkm/cont/CellLocatorPartitioned.cxx @@ -0,0 +1,87 @@ +//============================================================================ +// 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. +//============================================================================ + +#include +#include +#include +#include + +namespace vtkm +{ +namespace cont +{ + +void CellLocatorPartitioned::Update() +{ + if (this->Modified) + { + this->Build(); + this->Modified = false; + } +} + + +void CellLocatorPartitioned::Build() +{ + vtkm::Id numPartitions = this->Partitions.GetNumberOfPartitions(); + this->LocatorsCont.resize(numPartitions); + this->GhostsCont.resize(numPartitions); + for (vtkm::Id index = 0; index < numPartitions; ++index) + { + const vtkm::cont::DataSet& dataset = this->Partitions.GetPartition(index); + + // fill vector of cellLocators + vtkm::cont::CellLocatorGeneral cellLocator; + cellLocator.SetCellSet(dataset.GetCellSet()); + cellLocator.SetCoordinates(dataset.GetCoordinateSystem()); + cellLocator.Update(); + this->LocatorsCont.at(index) = cellLocator; + + // fill vector of ghostFields + vtkm::cont::ArrayHandle ghostArrayHandle; + if (dataset.HasCellField("vtkGhostType")) + { + dataset.GetField("vtkGhostType").GetData().AsArrayHandle(ghostArrayHandle); + } + else + { + vtkm::cont::ArrayCopy( + vtkm::cont::ArrayHandleConstant(0, dataset.GetNumberOfCells()), + ghostArrayHandle); + } + this->GhostsCont.at(index) = ghostArrayHandle; + } +} + +const vtkm::exec::CellLocatorPartitioned CellLocatorPartitioned::PrepareForExecution( + vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token) +{ + this->Update(); + + vtkm::Id numPartitions = this->Partitions.GetNumberOfPartitions(); + this->LocatorsExec.Allocate(numPartitions, vtkm::CopyFlag::Off, token); + auto portalLocators = this->LocatorsExec.WritePortal(token); + this->GhostsExec.Allocate(numPartitions, vtkm::CopyFlag::Off, token); + auto portalGhosts = this->GhostsExec.WritePortal(token); + for (vtkm::Id index = 0; index < numPartitions; ++index) + { + // fill arrayhandle of cellLocators + portalLocators.Set(index, this->LocatorsCont.at(index).PrepareForExecution(device, token)); + + // fill arrayhandle of ghostFields + portalGhosts.Set(index, this->GhostsCont.at(index).PrepareForInput(device, token)); + } + return vtkm::exec::CellLocatorPartitioned(this->LocatorsExec.PrepareForInput(device, token), + this->GhostsExec.PrepareForInput(device, token)); +} + +} // namespace cont +} //namespace vtkm diff --git a/vtkm/cont/CellLocatorPartitioned.h b/vtkm/cont/CellLocatorPartitioned.h new file mode 100644 index 000000000..ebce9b29a --- /dev/null +++ b/vtkm/cont/CellLocatorPartitioned.h @@ -0,0 +1,58 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtkm_cont_CellLocatorPartitioned_h +#define vtkm_cont_CellLocatorPartitioned_h + +#include +#include +#include + +namespace vtkm +{ +namespace cont +{ +class VTKM_CONT_EXPORT CellLocatorPartitioned : public vtkm::cont::ExecutionObjectBase +{ + +public: + virtual ~CellLocatorPartitioned() = default; + + VTKM_CONT CellLocatorPartitioned() = default; + + void SetPartitions(const vtkm::cont::PartitionedDataSet& partitions) + { + this->Partitions = partitions; + this->SetModified(); + } + const vtkm::cont::PartitionedDataSet& GetPartitions() const { return this->Partitions; } + + void Update(); + + void SetModified() { this->Modified = true; } + bool GetModified() const { return this->Modified; } + + void Build(); + + VTKM_CONT const vtkm::exec::CellLocatorPartitioned PrepareForExecution( + vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token); + +private: + vtkm::cont::PartitionedDataSet Partitions; + std::vector LocatorsCont; + std::vector> GhostsCont; + vtkm::cont::ArrayHandle LocatorsExec; + vtkm::cont::ArrayHandle::ReadPortalType> GhostsExec; + bool Modified = true; +}; +} // namespace cont +} //namespace vtkm + +#endif //vtkm_cont_CellLocatorPartitioned_h diff --git a/vtkm/cont/CellLocatorUniformBins.cxx b/vtkm/cont/CellLocatorUniformBins.cxx new file mode 100644 index 000000000..99241b48c --- /dev/null +++ b/vtkm/cont/CellLocatorUniformBins.cxx @@ -0,0 +1,340 @@ +//============================================================================ +// 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. +//============================================================================ +#include +#include +#include +#include +#include +#include +#include + +namespace vtkm +{ +namespace cont +{ + +namespace +{ + +VTKM_EXEC +inline vtkm::Id ComputeFlatIndex(const vtkm::Id3& idx, const vtkm::Id3& dims) +{ + return idx[0] + (dims[0] * (idx[1] + (dims[1] * idx[2]))); +} + +VTKM_EXEC +inline vtkm::Id3 GetFlatIndex(const vtkm::Vec3f& pt, + const vtkm::Vec3f& origin, + const vtkm::Vec3f& invSpacing, + const vtkm::Id3& maxCellIds) +{ + auto temp = pt - origin; + temp = temp * invSpacing; + + auto logicalIdx = vtkm::Min(vtkm::Id3(temp), maxCellIds); + return logicalIdx; +} + +template +VTKM_EXEC inline void MinMaxIndicesForCellPoints(const PointsVecType& points, + const vtkm::Vec3f& origin, + const vtkm::Vec3f& invSpacing, + const vtkm::Id3& maxCellIds, + vtkm::Id3& minIdx, + vtkm::Id3& maxIdx) +{ + auto numPoints = vtkm::VecTraits::GetNumberOfComponents(points); + + vtkm::Bounds bounds; + for (vtkm::IdComponent i = 0; i < numPoints; ++i) + bounds.Include(points[i]); + + //Get 8 corners of bbox. + minIdx = GetFlatIndex(bounds.MinCorner(), origin, invSpacing, maxCellIds); + maxIdx = GetFlatIndex(bounds.MaxCorner(), origin, invSpacing, maxCellIds); +} + +class CountCellBins : public vtkm::worklet::WorkletVisitCellsWithPoints +{ +public: + using ControlSignature = void(CellSetIn cellset, FieldInPoint coords, FieldOutCell bincount); + using ExecutionSignature = void(_2, _3); + using InputDomain = _1; + + CountCellBins(const vtkm::Vec3f& origin, + const vtkm::Vec3f& invSpacing, + const vtkm::Id3& maxCellIds) + : InvSpacing(invSpacing) + , MaxCellIds(maxCellIds) + , Origin(origin) + { + } + + template + VTKM_EXEC void operator()(const PointsVecType& points, vtkm::Id& numBins) const + { + vtkm::Id3 idx000, idx111; + MinMaxIndicesForCellPoints( + points, this->Origin, this->InvSpacing, this->MaxCellIds, idx000, idx111); + + //Count the number of bins for this cell + numBins = + (idx111[0] - idx000[0] + 1) * (idx111[1] - idx000[1] + 1) * (idx111[2] - idx000[2] + 1); + } + +private: + vtkm::Vec3f InvSpacing; + vtkm::Id3 MaxCellIds; + vtkm::Vec3f Origin; +}; + +class RecordBinsPerCell : public vtkm::worklet::WorkletVisitCellsWithPoints +{ +public: + using ControlSignature = void(CellSetIn cellset, + FieldInPoint coords, + FieldInCell start, + WholeArrayInOut binsPerCell, + WholeArrayInOut cellIds, + AtomicArrayInOut cellCounts); + using ExecutionSignature = void(InputIndex, _2, _3, _4, _5, _6); + using InputDomain = _1; + + RecordBinsPerCell(const vtkm::Vec3f& origin, + const vtkm::Vec3f& invSpacing, + const vtkm::Id3& dims, + const vtkm::Id3& maxCellIds) + : Dims(dims) + , InvSpacing(invSpacing) + , MaxCellIds(maxCellIds) + , Origin(origin) + { + } + + + template + VTKM_EXEC void operator()(const vtkm::Id& cellIdx, + const PointsVecType& points, + const vtkm::Id& start, + ResultArrayType& binsPerCell, + ResultArrayType& cellIds, + CellCountType cellCounts) const + { + vtkm::Id3 idx000, idx111; + MinMaxIndicesForCellPoints( + points, this->Origin, this->InvSpacing, this->MaxCellIds, idx000, idx111); + + vtkm::Id cnt = 0; + vtkm::Id sliceStart = ComputeFlatIndex(idx000, this->Dims); + for (vtkm::Id k = idx000[2]; k <= idx111[2]; k++) + { + vtkm::Id shaftStart = sliceStart; + for (vtkm::Id j = idx000[1]; j <= idx111[1]; j++) + { + vtkm::Id flatIdx = shaftStart; + for (vtkm::Id i = idx000[0]; i <= idx111[0]; i++) + { + // set portals and increment cnt... + binsPerCell.Set(start + cnt, flatIdx); + cellIds.Set(start + cnt, cellIdx); + cellCounts.Add(flatIdx, 1); + ++flatIdx; + ++cnt; + } + shaftStart += this->Dims[0]; + } + sliceStart += this->Dims[0] * this->Dims[1]; + } + } + +private: + vtkm::Id3 Dims; + vtkm::Vec3f InvSpacing; + vtkm::Id3 MaxCellIds; + vtkm::Vec3f Origin; +}; + +} //namespace detail + + +//---------------------------------------------------------------------------- +/// Builds the cell locator lookup structure +/// +VTKM_CONT void CellLocatorUniformBins::Build() +{ + if (this->UniformDims[0] <= 0 || this->UniformDims[1] <= 0 || this->UniformDims[2] <= 0) + throw vtkm::cont::ErrorBadValue("Grid dimensions of CellLocatorUniformBins must be > 0"); + + VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "CellLocatorUniformBins::Build"); + + this->MaxCellIds = (vtkm::Max(this->UniformDims - vtkm::Id3(1), vtkm::Id3(0))); + vtkm::Id totalNumBins = this->UniformDims[0] * this->UniformDims[1] * this->UniformDims[2]; + + vtkm::cont::Invoker invoker; + + auto cellset = this->GetCellSet(); + const auto& coords = this->GetCoordinates(); + + auto bounds = coords.GetBounds(); + this->Origin = vtkm::Vec3f(bounds.MinCorner()); + this->MaxPoint = vtkm::Vec3f(bounds.MaxCorner()); + auto size = this->MaxPoint - this->Origin; + vtkm::Vec3f spacing( + size[0] / this->UniformDims[0], size[1] / this->UniformDims[1], size[2] / this->UniformDims[2]); + + for (vtkm::IdComponent i = 0; i < 3; i++) + { + if (vtkm::Abs(spacing[i]) > 0) + this->InvSpacing[i] = 1.0f / spacing[i]; + else + this->InvSpacing[i] = 0; + } + + // The following example will be used in the explanation below + // Dataset with 3 cells: c0, c1, c2 + // 2x2 uniform grid: b0, b1, b2, b3 + // Assume that the bounding box for each cell overlaps as follows: + // c0: b0, b1, b2 + // c1: b1 + // c2: b2 + // + // The acceleration structure is an array of cell ids that are grouped + // by the overlapping bin. This information can be represented using + // vtkm::cont::ArrayHandleGroupVecVariable + // In the example above: + // CellIds = {c0, c0,c1, c0,c2, } + // b0 b1 b2 b3 + // + // The algorithm runs as follows: + // Given a point p, find the bin (b) that contains p. + // Do a point-in-cell test for each cell in bin b. + // + // Example: point p is in b=1 + // vtkm::cont::ArrayHandleGroupVecVariable provides the offset and number + // cells in bin b=1. The offset is 1 and the count is 2. + // Do a point-in-cell test on the 2 cells that start at offset 1 + // CellIds[ 1 + 0], which is c0 + // CellIds[ 1 + 1], which is c1 + + + //Computing this involves several steps which are described below. + //Step 1: + // For each cell in cellSet, count the number of bins that overlap with the cell bbox. + // For the example above + // binCountsPerCell = {3, 1, 1} + // cell0 overlaps with 3 bins + // cell1 overlaps with 1 bin + // cell2 overlaps with 1 bin + vtkm::cont::ArrayHandle binCountsPerCell; + CountCellBins countCellBins(this->Origin, this->InvSpacing, this->MaxCellIds); + invoker(countCellBins, cellset, coords, binCountsPerCell); + + //2: Compute number of unique cell/bin pairs and start indices. + + //Step 2: + // Given the number of bins for each cell, we can compute the offset for each cell. + // For the example above, binOffset is: + // {0, 3, 4} + // and the total number, num is 5 + // c0 begins at idx=0 + // c1 begins at idx=3 + // c2 begins at idx=4 + vtkm::cont::ArrayHandle binOffset; + auto num = vtkm::cont::Algorithm::ScanExclusive(binCountsPerCell, binOffset); + + //Step 3: + // Now that we know the start index and numbers, we can fill an array of bin ids. + // binsPerCell is the list of binIds for each cell. In the example above, + // binsPerCell = {b0,b1,b2, b2, b2} + // \ cell0 / cell1 cell2 + // We can also compute the cellIds and number of cells per bin, cellCount + // cids = {c0,c0,c0, c1, c2} + // cellCount = {3, 1, 1, 0} + // These are set using RecordBinsPerCell worklet, which does the following + // for each cell + // compute cell bbox and list of overlaping bins + // for each overlaping bin + // add the bin id to binsPerCell starting at binOffset + // add the cell id to the CellIds starting at binOffset + // increment CellCount for the bin (uses an atomic for thread safety). + + vtkm::cont::ArrayHandle binsPerCell, cids, cellCount; + binsPerCell.AllocateAndFill(num, 0); + cids.Allocate(num); + cellCount.AllocateAndFill(totalNumBins, 0); + RecordBinsPerCell recordBinsPerCell( + this->Origin, this->InvSpacing, this->UniformDims, this->MaxCellIds); + invoker(recordBinsPerCell, cellset, coords, binOffset, binsPerCell, cids, cellCount); + + //Step 4: + // binsPerCell is the overlapping bins for each cell. + // We want to sort CellIds by the bin ID. SortByKey does this. + vtkm::cont::Algorithm::SortByKey(binsPerCell, cids); + + // Convert the cell counts to offsets using the helper function + // vtkm::cont::ConvertNumComponentsToOffsets, and create the + // CellIds that are used as the acceleration structure. + this->CellIds = vtkm::cont::make_ArrayHandleGroupVecVariable( + cids, vtkm::cont::ConvertNumComponentsToOffsets(cellCount)); +} + +//---------------------------------------------------------------------------- +struct CellLocatorUniformBins::MakeExecObject +{ + template + VTKM_CONT void operator()(const CellSetType& cellSet, + vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token, + const CellLocatorUniformBins& self, + ExecObjType& execObject) const + { + using CellStructureType = CellSetContToExec; + + execObject = vtkm::exec::CellLocatorUniformBins(self.UniformDims, + self.Origin, + self.MaxPoint, + self.InvSpacing, + self.MaxCellIds, + self.CellIds, + cellSet, + self.GetCoordinates(), + device, + token); + } +}; + +CellLocatorUniformBins::ExecObjType CellLocatorUniformBins::PrepareForExecution( + vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token) const +{ + this->Update(); + ExecObjType execObject; + vtkm::cont::CastAndCall(this->GetCellSet(), MakeExecObject{}, device, token, *this, execObject); + return execObject; +} + +//---------------------------------------------------------------------------- +void CellLocatorUniformBins::PrintSummary(std::ostream& out) const +{ + out << std::endl; + out << "CellLocatorUniformBins" << std::endl; + out << " UniformDims: " << this->UniformDims << std::endl; + out << " Origin: " << this->Origin << std::endl; + out << " MaxPoint: " << this->MaxPoint << std::endl; + out << " InvSpacing: " << this->InvSpacing << std::endl; + out << " MaxCellIds: " << this->MaxCellIds << std::endl; + + out << "Input CellSet: \n"; + this->GetCellSet().PrintSummary(out); + out << "Input Coordinates: \n"; + this->GetCoordinates().PrintSummary(out); +} +} +} // vtkm::cont diff --git a/vtkm/cont/CellLocatorUniformBins.h b/vtkm/cont/CellLocatorUniformBins.h index 4c3010b5c..aa806cdfd 100644 --- a/vtkm/cont/CellLocatorUniformBins.h +++ b/vtkm/cont/CellLocatorUniformBins.h @@ -10,21 +10,80 @@ #ifndef vtk_m_cont_CellLocatorUniformBins_h #define vtk_m_cont_CellLocatorUniformBins_h -#include +#include +#include + +#include +#include + +#include +#include -#include namespace vtkm { namespace cont { -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Replaced with CellLocatorTwoLevel.") - CellLocatorUniformBins : vtkm::cont::CellLocatorTwoLevel +/// \brief A locator that uses a uniform grid +/// +/// `CellLocatorUniformBins` creates a cell search structure using a single uniform +/// grid. The size of the uniform grid is specified using the `SetDims` method. +/// In general, the `CellLocatorTwoLevel` has the better performance. However, +/// there are some cases where this is not the case. One example of this is +/// a uniformly dense triangle grid. In some cases the `CellLocatorUniformBins` +/// produces a more efficient search structure, especially for GPUs where memory +/// access patterns are critical to performance. + +class VTKM_CONT_EXPORT CellLocatorUniformBins + : public vtkm::cont::internal::CellLocatorBase { + using Superclass = vtkm::cont::internal::CellLocatorBase; + + template + using CellSetContToExec = + typename CellSetCont::template ExecConnectivityType; + +public: + using SupportedCellSets = VTKM_DEFAULT_CELL_SET_LIST; + + using CellExecObjectList = vtkm::ListTransform; + using CellLocatorExecList = + vtkm::ListTransform; + + using ExecObjType = vtkm::ListApply; + using LastCell = typename ExecObjType::LastCell; + + CellLocatorUniformBins() {} + void SetDims(const vtkm::Id3& dims) { this->UniformDims = dims; } + vtkm::Id3 GetDims() const { return this->UniformDims; } + + void PrintSummary(std::ostream& out) const; + +public: + ExecObjType PrepareForExecution(vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token) const; + +private: + friend Superclass; + VTKM_CONT void Build(); + + vtkm::Vec3f InvSpacing; + vtkm::Vec3f MaxPoint; + vtkm::Vec3f Origin; + vtkm::Id3 UniformDims; + vtkm::Id3 MaxCellIds; + + using CellIdArrayType = vtkm::cont::ArrayHandle; + using CellIdOffsetArrayType = vtkm::cont::ArrayHandle; + + vtkm::cont::ArrayHandleGroupVecVariable CellIds; + + struct MakeExecObject; }; } -} // namespace vtkm::cont +} // vtkm::cont -#endif //vtk_m_cont_CellLocatorUniformBins_h +#endif // vtk_m_cont_CellLocatorUniformBins_h diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index 3a290e44b..69fb5db06 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -11,7 +11,6 @@ #define vtk_m_cont_CellSetExplicit_h #include -#include #include #include #include @@ -164,32 +163,6 @@ public: const vtkm::cont::ArrayHandle& connectivity, const vtkm::cont::ArrayHandle& offsets); - template - struct VTKM_DEPRECATED( - 1.6, - "Replace ExecutionTypes::ExecObjectType with ExecConnectivityType.") - ExecutionTypes - { - private: - VTKM_IS_DEVICE_ADAPTER_TAG(Device); - VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology); - VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology); - - using Chooser = ConnectivityChooser; - - using ShapesAT = typename Chooser::ShapesArrayType; - using ConnAT = typename Chooser::ConnectivityArrayType; - using OffsetsAT = typename Chooser::OffsetsArrayType; - - public: - using ShapesPortalType = typename ShapesAT::ReadPortalType; - using ConnectivityPortalType = typename ConnAT::ReadPortalType; - using OffsetsPortalType = typename OffsetsAT::ReadPortalType; - - using ExecObjectType = - vtkm::exec::ConnectivityExplicit; - }; - template using ExecConnectivityType = typename ConnectivityChooser::ExecConnectivityType; @@ -201,17 +174,6 @@ public: IncidentTopology, vtkm::cont::Token&) const; - template - VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") - VTKM_CONT ExecConnectivityType PrepareForInput( - vtkm::cont::DeviceAdapterId device, - VisitTopology visitTopology, - IncidentTopology incidentTopology) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, visitTopology, incidentTopology, token); - } - template VTKM_CONT const typename ConnectivityChooser::ShapesArrayType& GetShapesArray(VisitTopology, IncidentTopology) const; diff --git a/vtkm/cont/CellSetExplicit.hxx b/vtkm/cont/CellSetExplicit.hxx index e9c5e76cc..99ae1f4fe 100644 --- a/vtkm/cont/CellSetExplicit.hxx +++ b/vtkm/cont/CellSetExplicit.hxx @@ -14,6 +14,8 @@ #include #include +#include + // This file uses a lot of very verbose identifiers and the clang formatted // code quickly becomes unreadable. Stick with manual formatting for now. // diff --git a/vtkm/cont/CellSetExtrude.h b/vtkm/cont/CellSetExtrude.h index 671ea709b..be8285779 100644 --- a/vtkm/cont/CellSetExtrude.h +++ b/vtkm/cont/CellSetExtrude.h @@ -110,15 +110,6 @@ public: typename detail::CellSetExtrudeConnectivityChooser::ExecConnectivityType; - template - struct VTKM_DEPRECATED( - 1.6, - "Replace ExecutionTypes::ExecObjectType with ExecConnectivityType.") - ExecutionTypes - { - using ExecObjectType = ExecConnectivityType; - }; - vtkm::exec::ConnectivityExtrude PrepareForInput(vtkm::cont::DeviceAdapterId, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, @@ -129,26 +120,6 @@ public: vtkm::TopologyElementTagCell, vtkm::cont::Token&) const; - VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") - vtkm::exec::ConnectivityExtrude PrepareForInput( - vtkm::cont::DeviceAdapterId device, - vtkm::TopologyElementTagCell visitTopology, - vtkm::TopologyElementTagPoint incidentTopology) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, visitTopology, incidentTopology, token); - } - - VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") - vtkm::exec::ReverseConnectivityExtrude PrepareForInput( - vtkm::cont::DeviceAdapterId device, - vtkm::TopologyElementTagPoint visitTopology, - vtkm::TopologyElementTagCell incidentTopology) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, visitTopology, incidentTopology, token); - } - private: void BuildReverseConnectivity(); diff --git a/vtkm/cont/CellSetListTag.h b/vtkm/cont/CellSetListTag.h deleted file mode 100644 index f0a5bc89e..000000000 --- a/vtkm/cont/CellSetListTag.h +++ /dev/null @@ -1,78 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_CellSetListTag_h -#define vtk_m_cont_CellSetListTag_h - -// Everything in this header file is deprecated and movded to CellSetList.h. - -#ifndef VTKM_DEFAULT_CELL_SET_LIST_TAG -#define VTKM_DEFAULT_CELL_SET_LIST_TAG ::vtkm::cont::detail::CellSetListTagDefault -#endif - -#include - -#include - -#define VTK_M_OLD_CELL_LIST_DEFINITION(name) \ - struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( \ - 1.6, \ - "CellSetListTag" #name " replaced by CellSetList" #name ". " \ - "Note that the new CellSetList" #name " cannot be subclassed.") CellSetListTag##name \ - : vtkm::internal::ListAsListTag \ - { \ - } - -namespace vtkm -{ -namespace cont -{ - -VTK_M_OLD_CELL_LIST_DEFINITION(Structured1D); -VTK_M_OLD_CELL_LIST_DEFINITION(Structured2D); -VTK_M_OLD_CELL_LIST_DEFINITION(Structured3D); -VTK_M_OLD_CELL_LIST_DEFINITION(ExplicitDefault); -VTK_M_OLD_CELL_LIST_DEFINITION(Common); -VTK_M_OLD_CELL_LIST_DEFINITION(Structured); -VTK_M_OLD_CELL_LIST_DEFINITION(Unstructured); - -/// @cond NONE -template -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.6, - "CellSetListTagExplicit replaced by CellSetListExplicit. " - "Note that the new CellSetListExplicit cannot be subclassed.") CellSetListTagExplicit - : vtkm::internal::ListAsListTag< - CellSetListExplicit> -{ -}; -/// @endcond - -namespace detail -{ - -/// @cond NONE -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.6, - "VTKM_DEFAULT_CELL_SET_LIST_TAG replaced by VTKM_DEFAULT_CELL_SET_LIST. " - "Note that the new VTKM_DEFAULT_CELL_SET_LIST cannot be subclassed.") CellSetListTagDefault - : vtkm::internal::ListAsListTag -{ -}; -/// @endcond - -} // namespace detail -} -} // namespace vtkm::cont - -#undef VTK_M_OLD_CELL_LIST_DEFINITION - -#endif //vtk_m_cont_CellSetListTag_h diff --git a/vtkm/cont/CellSetPermutation.h b/vtkm/cont/CellSetPermutation.h index a22165fb6..463f1605c 100644 --- a/vtkm/cont/CellSetPermutation.h +++ b/vtkm/cont/CellSetPermutation.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -451,15 +452,6 @@ public: OriginalCellSetType, PermutationArrayHandleType>::ExecConnectivityType; - template - struct VTKM_DEPRECATED( - 1.6, - "Replace ExecutionTypes::ExecObjectType with ExecConnectivityType.") - ExecutionTypes - { - using ExecObjectType = ExecConnectivityType; - }; - VTKM_CONT ExecConnectivityType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::TopologyElementTagCell visitTopology, @@ -492,17 +484,6 @@ public: this->VisitPointsWithCells.Offsets.PrepareForInput(device, token)); } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") - ExecConnectivityType PrepareForInput( - vtkm::cont::DeviceAdapterId device, - VisitTopology visitTopology, - IncidentTopology incidentTopology) - { - vtkm::cont::Token token; - return this->PrepareForInput(device, visitTopology, incidentTopology, token); - } - VTKM_CONT void PrintSummary(std::ostream& out) const override { diff --git a/vtkm/cont/CellSetStructured.h b/vtkm/cont/CellSetStructured.h index 6399c4ee4..96b3f5a7f 100644 --- a/vtkm/cont/CellSetStructured.h +++ b/vtkm/cont/CellSetStructured.h @@ -126,18 +126,6 @@ public: using ExecConnectivityType = vtkm::exec::ConnectivityStructured; - template - struct VTKM_DEPRECATED( - 1.6, - "Replace ExecutionTypes::ExecObjectType with ExecConnectivityType.") - ExecutionTypes - { - VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter); - VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology); - VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology); - using ExecObjectType = ExecConnectivityType; - }; - template ExecConnectivityType PrepareForInput(vtkm::cont::DeviceAdapterId, VisitTopology, @@ -147,17 +135,6 @@ public: return ExecConnectivityType(this->Structure); } - template - VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") - ExecConnectivityType PrepareForInput( - vtkm::cont::DeviceAdapterId device, - VisitTopology visitTopology, - IncidentTopology incidentTopology) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, visitTopology, incidentTopology, token); - } - void PrintSummary(std::ostream& out) const override { out << " StructuredCellSet:\n"; diff --git a/vtkm/cont/ColorTable.cxx b/vtkm/cont/ColorTable.cxx index 4095ba8a3..e0973a8ef 100644 --- a/vtkm/cont/ColorTable.cxx +++ b/vtkm/cont/ColorTable.cxx @@ -1271,12 +1271,6 @@ vtkm::exec::ColorTable ColorTable::PrepareForExecution(vtkm::cont::DeviceAdapter return execTable; } -vtkm::exec::ColorTable ColorTable::PrepareForExecution(vtkm::cont::DeviceAdapterId device) const -{ - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); -} - //--------------------------------------------------------------------------- vtkm::Id ColorTable::GetModifiedCount() const { diff --git a/vtkm/cont/ColorTable.h b/vtkm/cont/ColorTable.h index eb194705f..5b069e655 100644 --- a/vtkm/cont/ColorTable.h +++ b/vtkm/cont/ColorTable.h @@ -33,15 +33,6 @@ namespace detail struct ColorTableInternals; } -struct VTKM_DEPRECATED(1.6, "Use vtkm::ColorSpace.") ColorSpace -{ - static constexpr vtkm::ColorSpace RGB = vtkm::ColorSpace::RGB; - static constexpr vtkm::ColorSpace HSV = vtkm::ColorSpace::HSV; - static constexpr vtkm::ColorSpace HSV_WRAP = vtkm::ColorSpace::HSVWrap; - static constexpr vtkm::ColorSpace LAB = vtkm::ColorSpace::Lab; - static constexpr vtkm::ColorSpace DIVERGING = vtkm::ColorSpace::Diverging; -}; - /// \brief Color Table for coloring arbitrary fields /// /// @@ -120,25 +111,6 @@ public: RainbowUniform, Jet, RainbowDesaturated, - - DEFAULT VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Default."), - COOL_TO_WARM VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::CoolToWarm."), - COOL_TO_WARM_EXTENDED VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::CoolToWarmExtended."), - VIRIDIS VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Viridis."), - INFERNO VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Inferno."), - PLASMA VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Plasma."), - BLACK_BODY_RADIATION VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::BlackBodyRadiation."), - X_RAY VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::XRay."), - GREEN VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Green."), - BLACK_BLUE_WHITE VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::BlackBlueWhite."), - BLUE_TO_ORANGE VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::BlueToOrange."), - GRAY_TO_RED VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::GrayToRed."), - COLD_AND_HOT VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::ColdAndHot."), - BLUE_GREEN_ORANGE VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::BlueGreenOrange."), - YELLOW_GRAY_BLUE VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::YellowGrayBlue."), - RAINBOW_UNIFORM VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::RainbowUniform."), - JET VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::Jet."), - RAINBOW_DESATURATED VTKM_DEPRECATED(1.6, "Use vtkm::ColorTable::Preset::RainbowDesaturated.") }; /// \brief Construct a color table from a preset @@ -599,9 +571,6 @@ public: vtkm::exec::ColorTable PrepareForExecution(vtkm::cont::DeviceAdapterId deviceId, vtkm::cont::Token& token) const; - VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object") - inline vtkm::exec::ColorTable PrepareForExecution(vtkm::cont::DeviceAdapterId deviceId) const; - /// \brief Returns the modified count for changes of the color table /// /// The `ModifiedCount` of the color table starts at 1 and gets incremented diff --git a/vtkm/cont/ColorTablePresets.cxx b/vtkm/cont/ColorTablePresets.cxx index db650d800..e9a6f8f84 100644 --- a/vtkm/cont/ColorTablePresets.cxx +++ b/vtkm/cont/ColorTablePresets.cxx @@ -1371,51 +1371,9 @@ bool LoadColorTablePreset(vtkm::cont::ColorTable::Preset preset, vtkm::cont::Col } } - VTKM_DEPRECATED_SUPPRESS_BEGIN - // Handle deprecated names - switch (preset) - { - case vtkm::cont::ColorTable::Preset::DEFAULT: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Default, table); - case vtkm::cont::ColorTable::Preset::COOL_TO_WARM: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::CoolToWarm, table); - case vtkm::cont::ColorTable::Preset::COOL_TO_WARM_EXTENDED: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::CoolToWarmExtended, table); - case vtkm::cont::ColorTable::Preset::VIRIDIS: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Viridis, table); - case vtkm::cont::ColorTable::Preset::INFERNO: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Inferno, table); - case vtkm::cont::ColorTable::Preset::PLASMA: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Plasma, table); - case vtkm::cont::ColorTable::Preset::BLACK_BODY_RADIATION: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::BlackBodyRadiation, table); - case vtkm::cont::ColorTable::Preset::X_RAY: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::XRay, table); - case vtkm::cont::ColorTable::Preset::GREEN: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Green, table); - case vtkm::cont::ColorTable::Preset::BLACK_BLUE_WHITE: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::BlackBlueWhite, table); - case vtkm::cont::ColorTable::Preset::BLUE_TO_ORANGE: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::BlueToOrange, table); - case vtkm::cont::ColorTable::Preset::GRAY_TO_RED: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::GrayToRed, table); - case vtkm::cont::ColorTable::Preset::COLD_AND_HOT: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::ColdAndHot, table); - case vtkm::cont::ColorTable::Preset::BLUE_GREEN_ORANGE: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::BlueGreenOrange, table); - case vtkm::cont::ColorTable::Preset::YELLOW_GRAY_BLUE: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::YellowGrayBlue, table); - case vtkm::cont::ColorTable::Preset::RAINBOW_UNIFORM: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::RainbowUniform, table); - case vtkm::cont::ColorTable::Preset::JET: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::Jet, table); - case vtkm::cont::ColorTable::Preset::RAINBOW_DESATURATED: - return LoadColorTablePreset(vtkm::cont::ColorTable::Preset::RainbowDesaturated, table); - default: - // Should not get here. - return false; - } - VTKM_DEPRECATED_SUPPRESS_END + // Should not get here. + VTKM_LOG_S(vtkm::cont::LogLevel::Warn, "Missing ColorTable preset."); + return false; } VTKM_CONT_EXPORT std::set GetPresetNames() diff --git a/vtkm/cont/CoordinateSystem.cxx b/vtkm/cont/CoordinateSystem.cxx index 6e63b5037..b4128e296 100644 --- a/vtkm/cont/CoordinateSystem.cxx +++ b/vtkm/cont/CoordinateSystem.cxx @@ -11,31 +11,27 @@ #include #include #include +#include namespace vtkm { namespace cont { -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -namespace detail -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN -vtkm::cont::ArrayHandleVirtualCoordinates CoordDataDepWrapper::ToArray() const -{ - return this->AsArrayHandle(); -} -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace detail -#endif //VTKM_NO_DEPRECATED_VIRTUAL - VTKM_CONT CoordinateSystem::CoordinateSystem() : Superclass() { } +VTKM_CONT CoordinateSystem::CoordinateSystem(const vtkm::cont::Field& src) + : Superclass(src) +{ + if (src.GetAssociation() != vtkm::cont::Field::Association::Points) + { + throw vtkm::cont::ErrorBadValue("CoordinateSystems can only be point field."); + } +} + VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data) : Superclass(name, Association::Points, data) @@ -55,19 +51,12 @@ CoordinateSystem::CoordinateSystem(std::string name, { } -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_CONT vtkm::cont::detail::CoordDataDepWrapper CoordinateSystem::GetData() const -{ - return vtkm::cont::detail::CoordDataDepWrapper(this->Superclass::GetData()); -} -#else //!VTKM_NO_DEPRECATED_VIRTUAL VTKM_CONT vtkm::cont::UncertainArrayHandle CoordinateSystem::GetData() const { return vtkm::cont::UncertainArrayHandle( this->Superclass::GetData()); } -#endif //!VTKM_NO_DEPRECATED_VIRTUAL VTKM_CONT vtkm::cont::CoordinateSystem::MultiplexerArrayType diff --git a/vtkm/cont/CoordinateSystem.h b/vtkm/cont/CoordinateSystem.h index 5e11ab937..72f454d7a 100644 --- a/vtkm/cont/CoordinateSystem.h +++ b/vtkm/cont/CoordinateSystem.h @@ -11,120 +11,17 @@ #define vtk_m_cont_CoordinateSystem_h #include -#include #include #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif - namespace vtkm { namespace cont { -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -namespace detail -{ - -// CoordinateSystem::GetData used to return an ArrayHandleVirtualCoordinates. -// That behavior is deprecated, and CoordianteSystem::GetData now returns am -// UncertainArrayHandle similar (although slightly different than) its superclass. -// This wrapper class supports the old deprecated behavior until it is no longer -// supported. Once the behavior is removed (probably when -// ArrayHandleVirtualCoordinates is removed), then this class should be removed. -class VTKM_ALWAYS_EXPORT CoordDataDepWrapper - : public vtkm::cont::UncertainArrayHandle -{ - using Superclass = - vtkm::cont::UncertainArrayHandle; - - VTKM_DEPRECATED_SUPPRESS_BEGIN - VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates ToArray() const; - VTKM_DEPRECATED_SUPPRESS_END - -public: - using Superclass::Superclass; - - // Make the return also behave as ArrayHandleVirtualCoordiantes - VTKM_DEPRECATED_SUPPRESS_BEGIN - - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - operator vtkm::cont::ArrayHandleVirtualCoordinates() const - { - return this->ToArray(); - } - - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - operator vtkm::cont::ArrayHandle() const - { - return this->ToArray(); - } - - using ValueType VTKM_DEPRECATED( - 1.6, - "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") = vtkm::Vec3f; - - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - ArrayHandleVirtualCoordinates::ReadPortalType ReadPortal() const - { - return this->ToArray().ReadPortal(); - } - - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - ArrayHandleVirtualCoordinates::WritePortalType WritePortal() const - { - return this->ToArray().WritePortal(); - } - - template - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - typename ArrayHandleVirtualCoordinates::ReadPortalType - PrepareForInput(Device device, vtkm::cont::Token& token) const - { - return this->ToArray().PrepareForInput(device, token); - } - - template - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - typename ArrayHandleVirtualCoordinates::WritePortalType - PrepareForInPlace(Device device, vtkm::cont::Token& token) const - { - return this->ToArray().PrepareForInPlace(device, token); - } - - template - VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns an UncertainArrayHandle.") - typename ArrayHandleVirtualCoordinates::WritePortalType - PrepareForOutput(vtkm::Id numberOfValues, Device device, vtkm::cont::Token& token) const - { - return this->ToArray().PrepareForOutput(numberOfValues, device, token); - } - - VTKM_DEPRECATED_SUPPRESS_END -}; - -} // namespace detail - -VTKM_DEPRECATED_SUPPRESS_BEGIN -VTKM_CONT VTKM_DEPRECATED( - 1.6, - "CoordinateSystem::GetData() now returns an " - "UncertainArrayHandle.") inline void printSummary_ArrayHandle(const detail::CoordDataDepWrapper& - array, - std::ostream& out, - bool full = false) -{ - vtkm::cont::ArrayHandleVirtualCoordinates coordArray = array; - vtkm::cont::printSummary_ArrayHandle(coordArray, out, full); -} -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field { using Superclass = vtkm::cont::Field; @@ -133,6 +30,9 @@ public: VTKM_CONT CoordinateSystem(); + // It's OK for regular _point_ fields to become a CoordinateSystem object. + VTKM_CONT CoordinateSystem(const vtkm::cont::Field& src); + VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data); template @@ -152,12 +52,8 @@ public: VTKM_CONT vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); } -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_CONT detail::CoordDataDepWrapper GetData() const; -#else VTKM_CONT vtkm::cont::UncertainArrayHandle GetData() const; -#endif private: #ifdef VTKM_USE_DOUBLE_PRECISION @@ -275,14 +171,6 @@ struct DynamicTransformTraits using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; }; -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template <> -struct DynamicTransformTraits -{ - using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; -}; -#endif //VTKM_NO_DEPRECATED_VIRTUAL - } // namespace internal } // namespace cont @@ -294,16 +182,6 @@ struct DynamicTransformTraits namespace mangled_diy_namespace { -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template <> -struct Serialization - : public Serialization< - vtkm::cont::UncertainArrayHandle, - VTKM_DEFAULT_STORAGE_LIST>> -{ -}; -#endif //VTKM_NO_DEPRECATED_VIRTUAL - template <> struct Serialization : Serialization { diff --git a/vtkm/cont/DataSet.cxx b/vtkm/cont/DataSet.cxx index c4ee2b731..34c5b63bf 100644 --- a/vtkm/cont/DataSet.cxx +++ b/vtkm/cont/DataSet.cxx @@ -9,6 +9,60 @@ //============================================================================ #include +#include +#include + +#include + +namespace +{ + +VTKM_CONT void CheckFieldSize(const vtkm::cont::UnknownCellSet& cellSet, + const vtkm::cont::Field& field) +{ + if (!cellSet.IsValid()) + { + return; + } + switch (field.GetAssociation()) + { + case vtkm::cont::Field::Association::Points: + if (cellSet.GetNumberOfPoints() != field.GetData().GetNumberOfValues()) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Warn, + "The size of field `" + << field.GetName() << "` (" << field.GetData().GetNumberOfValues() + << " values) does not match the size of the data set structure (" + << cellSet.GetNumberOfPoints() << " points)."); + } + break; + case vtkm::cont::Field::Association::Cells: + if (cellSet.GetNumberOfCells() != field.GetData().GetNumberOfValues()) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Warn, + "The size of field `" + << field.GetName() << "` (" << field.GetData().GetNumberOfValues() + << " values) does not match the size of the data set structure (" + << cellSet.GetNumberOfCells() << " cells)."); + } + break; + default: + // Ignore as the association does not match any topological element. + break; + } +} + +VTKM_CONT void CheckFieldSizes(const vtkm::cont::UnknownCellSet& cellSet, + const vtkm::cont::internal::FieldCollection& fields) +{ + vtkm::IdComponent numFields = fields.GetNumberOfFields(); + for (vtkm::IdComponent fieldIndex = 0; fieldIndex < numFields; ++fieldIndex) + { + CheckFieldSize(cellSet, fields.GetField(fieldIndex)); + } +} + +} // anonymous namespace namespace vtkm { @@ -33,11 +87,17 @@ VTKM_CONT void SetGlobalGhostCellFieldName(const std::string& name) noexcept void DataSet::Clear() { - this->CoordSystems.clear(); + this->CoordSystemNames.clear(); this->Fields.Clear(); this->CellSet = this->CellSet.NewInstance(); } +void DataSet::AddField(const Field& field) +{ + CheckFieldSize(this->CellSet, field); + this->Fields.AddField(field); +} + vtkm::Id DataSet::GetNumberOfCells() const { return this->CellSet.GetNumberOfCells(); @@ -45,72 +105,197 @@ vtkm::Id DataSet::GetNumberOfCells() const vtkm::Id DataSet::GetNumberOfPoints() const { - if (this->CoordSystems.empty()) + if (this->CellSet.IsValid()) { - return 0; + return this->CellSet.GetNumberOfPoints(); } - return this->CoordSystems[0].GetNumberOfPoints(); + + // If there is no cell set, then try to use a coordinate system to get the number + // of points. + if (this->GetNumberOfCoordinateSystems() > 0) + { + return this->GetCoordinateSystem().GetNumberOfPoints(); + } + + // If there is no coordinate system either, we can try to guess the number of + // points by finding a point field. + for (vtkm::IdComponent fieldIdx = 0; fieldIdx < this->Fields.GetNumberOfFields(); ++fieldIdx) + { + const vtkm::cont::Field& field = this->Fields.GetField(fieldIdx); + if (field.GetAssociation() == vtkm::cont::Field::Association::Points) + { + return field.GetData().GetNumberOfValues(); + } + } + + // There are no point fields either. + return 0; +} + +const std::string& DataSet::GetGhostCellFieldName() const +{ + if (this->GhostCellName) + { + return *this->GhostCellName; + } + else + { + return GetGlobalGhostCellFieldName(); + } +} + +bool DataSet::HasGhostCellField() const +{ + return this->HasCellField(this->GetGhostCellFieldName()); +} + +const vtkm::cont::Field& DataSet::GetGhostCellField() const +{ + if (this->HasGhostCellField()) + { + return this->GetCellField(this->GetGhostCellFieldName()); + } + else + { + throw vtkm::cont::ErrorBadValue("No Ghost Cell Field"); + } +} + +vtkm::IdComponent DataSet::AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs) +{ + this->AddField(cs); + return this->AddCoordinateSystem(cs.GetName()); +} + +vtkm::IdComponent DataSet::AddCoordinateSystem(const std::string& pointFieldName) +{ + // Check to see if we already have this coordinate system. + vtkm::IdComponent index = this->GetCoordinateSystemIndex(pointFieldName); + if (index >= 0) + { + return index; + } + + // Check to make sure this is a valid point field. + if (!this->HasPointField(pointFieldName)) + { + throw vtkm::cont::ErrorBadValue("Cannot set point field named `" + pointFieldName + + "` as a coordinate system because it does not exist."); + } + + // Add the field to the list of coordinates. + this->CoordSystemNames.push_back(pointFieldName); + return static_cast(this->CoordSystemNames.size() - 1); +} + +void DataSet::SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet) +{ + CheckFieldSizes(cellSet, this->Fields); + this->CellSet = cellSet; +} + +void DataSet::SetGhostCellFieldName(const std::string& name) +{ + this->GhostCellName.reset(new std::string(name)); +} + +void DataSet::SetGhostCellField(const std::string& name) +{ + if (this->HasCellField(name)) + { + this->SetGhostCellFieldName(name); + } + else + { + throw vtkm::cont::ErrorBadValue("No such cell field " + name); + } +} + +void DataSet::SetGhostCellField(const vtkm::cont::Field& field) +{ + if (field.GetAssociation() == vtkm::cont::Field::Association::Cells) + { + this->SetGhostCellField(field.GetName(), field.GetData()); + } + else + { + throw vtkm::cont::ErrorBadValue("A ghost cell field must be a cell field."); + } +} + +void DataSet::SetGhostCellField(const std::string& fieldName, + const vtkm::cont::UnknownArrayHandle& field) +{ + this->AddCellField(fieldName, field); + this->SetGhostCellField(fieldName); +} + +void DataSet::SetGhostCellField(const vtkm::cont::UnknownArrayHandle& field) +{ + this->SetGhostCellField(GetGlobalGhostCellFieldName(), field); } void DataSet::CopyStructure(const vtkm::cont::DataSet& source) { - this->CoordSystems = source.CoordSystems; + // Copy the cells. this->CellSet = source.CellSet; + + // Copy the coordinate systems. + this->CoordSystemNames.clear(); + vtkm::IdComponent numCoords = source.GetNumberOfCoordinateSystems(); + for (vtkm::IdComponent coordIndex = 0; coordIndex < numCoords; ++coordIndex) + { + this->AddCoordinateSystem(source.GetCoordinateSystem(coordIndex)); + } + + // Copy the ghost cells. + // Note that we copy the GhostCellName separately from the field it points to + // to preserve (or remove) the case where the ghost cell name follows the + // global ghost cell name. this->GhostCellName = source.GhostCellName; -} - -const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index) const -{ - VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems())); - return this->CoordSystems[static_cast(index)]; -} - -vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index) -{ - VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems())); - return this->CoordSystems[static_cast(index)]; -} - -vtkm::Id DataSet::GetCoordinateSystemIndex(const std::string& name) const -{ - vtkm::Id index = -1; - for (auto i = this->CoordSystems.begin(); i != this->CoordSystems.end(); ++i) + if (source.HasGhostCellField()) { - if (i->GetName() == name) - { - index = static_cast(std::distance(this->CoordSystems.begin(), i)); - break; - } + this->AddField(source.GetGhostCellField()); } - return index; + + CheckFieldSizes(this->CellSet, this->Fields); } -const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name) const +vtkm::cont::CoordinateSystem DataSet::GetCoordinateSystem(vtkm::Id index) const +{ + VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems())); + return this->GetPointField(this->CoordSystemNames[static_cast(index)]); +} + +vtkm::IdComponent DataSet::GetCoordinateSystemIndex(const std::string& name) const +{ + auto nameIter = std::find(this->CoordSystemNames.begin(), this->CoordSystemNames.end(), name); + if (nameIter != this->CoordSystemNames.end()) + { + return static_cast(std::distance(this->CoordSystemNames.begin(), nameIter)); + } + else + { + return -1; + } +} + +const std::string& DataSet::GetCoordinateSystemName(vtkm::Id index) const +{ + VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems())); + return this->CoordSystemNames[static_cast(index)]; +} + +vtkm::cont::CoordinateSystem DataSet::GetCoordinateSystem(const std::string& name) const { vtkm::Id index = this->GetCoordinateSystemIndex(name); if (index < 0) { std::string error_message("No coordinate system with the name " + name + " valid names are: \n"); - for (const auto& cs : this->CoordSystems) + for (const auto& csn : this->CoordSystemNames) { - error_message += cs.GetName() + "\n"; - } - throw vtkm::cont::ErrorBadValue(error_message); - } - return this->GetCoordinateSystem(index); -} - -vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name) -{ - vtkm::Id index = this->GetCoordinateSystemIndex(name); - if (index < 0) - { - std::string error_message("No coordinate system with the name " + name + - " valid names are: \n"); - for (const auto& cs : this->CoordSystems) - { - error_message += cs.GetName() + "\n"; + error_message += csn + "\n"; } throw vtkm::cont::ErrorBadValue(error_message); } @@ -120,11 +305,13 @@ vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& na void DataSet::PrintSummary(std::ostream& out) const { out << "DataSet:\n"; - out << " CoordSystems[" << this->CoordSystems.size() << "]\n"; - for (std::size_t index = 0; index < this->CoordSystems.size(); index++) + out << " CoordSystems[" << this->CoordSystemNames.size() << "]\n"; + out << " "; + for (const auto& csn : this->CoordSystemNames) { - this->CoordSystems[index].PrintSummary(out); + out << " " << csn; } + out << "\n"; out << " CellSet \n"; this->GetCellSet().PrintSummary(out); diff --git a/vtkm/cont/DataSet.h b/vtkm/cont/DataSet.h index 8dfe542b6..8e4f8e30b 100644 --- a/vtkm/cont/DataSet.h +++ b/vtkm/cont/DataSet.h @@ -55,7 +55,7 @@ public: /// to have the same number of points. VTKM_CONT vtkm::Id GetNumberOfPoints() const; - VTKM_CONT void AddField(const Field& field) { this->Fields.AddField(field); } + VTKM_CONT void AddField(const Field& field); VTKM_CONT const vtkm::cont::Field& GetField(vtkm::Id index) const { return this->Fields.GetField(index); } @@ -77,30 +77,10 @@ public: } VTKM_CONT - bool HasGhostCellField() const - { - if (this->GhostCellName) - { - return this->HasCellField(*this->GhostCellName); - } - else - { - return false; - } - } + bool HasGhostCellField() const; VTKM_CONT - const std::string& GetGhostCellFieldName() const - { - if (this->HasGhostCellField()) - { - return *this->GhostCellName; - } - else - { - throw vtkm::cont::ErrorBadValue("No Ghost Cell Field Name"); - } - } + const std::string& GetGhostCellFieldName() const; VTKM_CONT bool HasPointField(const std::string& name) const @@ -156,21 +136,11 @@ public: } ///@} - /// Returns the first cell field that matches the provided name. + /// Returns the cell field that matches the ghost cell field name. /// Will throw an exception if no match is found ///@{ VTKM_CONT - const vtkm::cont::Field& GetGhostCellField() const - { - if (this->HasGhostCellField()) - { - return this->GetCellField(*(this->GhostCellName)); - } - else - { - throw vtkm::cont::ErrorBadValue("No Ghost Cell Field"); - } - } + const vtkm::cont::Field& GetGhostCellField() const; ///@} /// Returns the first point field that matches the provided name. @@ -223,24 +193,49 @@ public: this->AddField(make_FieldCell(fieldName, field)); } + /// \brief Sets the name of the field to use for cell ghost levels. + /// + /// This value can be set regardless of whether such a cell field actually exists. + VTKM_CONT void SetGhostCellFieldName(const std::string& name); + + /// \brief Sets the cell field of the given name as the cell ghost levels. + /// + /// If a cell field of the given name does not exist, an exception is thrown. + VTKM_CONT void SetGhostCellField(const std::string& name); + + ///@{ + /// \brief Sets the ghost cell levels. + /// + /// A field of the given name is added to the `DataSet`, and that field is set as the cell + /// ghost levels. + VTKM_CONT void SetGhostCellField(const vtkm::cont::Field& field); + VTKM_CONT void SetGhostCellField(const std::string& fieldName, + const vtkm::cont::UnknownArrayHandle& field); + ///@} + + /// \brief Sets the ghost cell levels to the given array. + /// + /// A field with the global ghost cell field name (see `GlobalGhostCellFieldName`) is added + /// to the `DataSet` and made to be the cell ghost levels. + VTKM_CONT void SetGhostCellField(const vtkm::cont::UnknownArrayHandle& field); + + VTKM_DEPRECATED(2.0, "Use SetGhostCellField.") VTKM_CONT void AddGhostCellField(const std::string& fieldName, const vtkm::cont::UnknownArrayHandle& field) { - this->GhostCellName.reset(new std::string(fieldName)); - this->AddField(make_FieldCell(fieldName, field)); + this->SetGhostCellField(fieldName, field); } + VTKM_DEPRECATED(2.0, "Use SetGhostCellField.") VTKM_CONT void AddGhostCellField(const vtkm::cont::UnknownArrayHandle& field) { - this->AddGhostCellField(GetGlobalGhostCellFieldName(), field); + this->SetGhostCellField(field); } + VTKM_DEPRECATED(2.0, "Use SetGhostCellField.") VTKM_CONT - void AddGhostCellField(const vtkm::cont::Field& field) - { - this->AddGhostCellField(field.GetName(), field.GetData()); - } + void AddGhostCellField(const vtkm::cont::Field& field) { this->SetGhostCellField(field); } template VTKM_CONT void AddCellField(const std::string& fieldName, @@ -264,11 +259,21 @@ public: } + /// \brief Adds the given `CoordinateSystem` to the `DataSet`. + /// + /// The coordinate system will also be added as a point field of the same name. + /// + /// \returns the index assigned to the added coordinate system. VTKM_CONT - void AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs) - { - this->CoordSystems.push_back(cs); - } + vtkm::IdComponent AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs); + + /// \brief Marks the point field with the given name as a coordinate system. + /// + /// If no such point field exists or the point field is of the wrong format, an exception + /// will be throw. + /// + /// \returns the index assigned to the added coordinate system. + VTKM_CONT vtkm::IdComponent AddCoordinateSystem(const std::string& pointFieldName); VTKM_CONT bool HasCoordinateSystem(const std::string& name) const @@ -277,40 +282,26 @@ public: } VTKM_CONT - const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const; + vtkm::cont::CoordinateSystem GetCoordinateSystem(vtkm::Id index = 0) const; - VTKM_CONT - vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0); - - /// Returns the index for the first CoordinateSystem whose + /// Returns the index for the CoordinateSystem whose /// name matches the provided string. /// Will return -1 if no match is found VTKM_CONT - vtkm::Id GetCoordinateSystemIndex(const std::string& name) const; + vtkm::IdComponent GetCoordinateSystemIndex(const std::string& name) const; - /// Returns the first CoordinateSystem that matches the provided name. + VTKM_CONT const std::string& GetCoordinateSystemName(vtkm::Id index = 0) const; + + /// Returns the CoordinateSystem that matches the provided name. /// Will throw an exception if no match is found - ///@{ VTKM_CONT - const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const; - - VTKM_CONT - vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name); - ///@} - - /// Returns an `std::vector` of `CoordinateSystem`s held in this `DataSet`. - /// - VTKM_CONT - std::vector GetCoordinateSystems() const - { - return this->CoordSystems; - } + vtkm::cont::CoordinateSystem GetCoordinateSystem(const std::string& name) const; template VTKM_CONT void SetCellSet(const CellSetType& cellSet) { VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(CellSetType); - this->CellSet = vtkm::cont::UnknownCellSet(cellSet); + this->SetCellSetImpl(cellSet); } VTKM_CONT @@ -325,11 +316,12 @@ public: VTKM_CONT vtkm::IdComponent GetNumberOfCoordinateSystems() const { - return static_cast(this->CoordSystems.size()); + return static_cast(this->CoordSystemNames.size()); } - /// Copies the structure i.e. coordinates systems and cellset from the source - /// dataset. The fields are left unchanged. + /// Copies the structure from the source dataset. The structure includes the cellset, + /// the coordinate systems, and any ghost layer information. The fields that are not + /// part of a coordinate system or ghost layers are left unchanged. VTKM_CONT void CopyStructure(const vtkm::cont::DataSet& source); @@ -352,13 +344,15 @@ public: void PrintSummary(std::ostream& out) const; private: - std::vector CoordSystems; + std::vector CoordSystemNames; vtkm::cont::internal::FieldCollection Fields{ vtkm::cont::Field::Association::WholeDataSet, vtkm::cont::Field::Association::Points, vtkm::cont::Field::Association::Cells }; vtkm::cont::UnknownCellSet CellSet; std::shared_ptr GhostCellName; + + VTKM_CONT void SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet); }; } // namespace cont @@ -402,13 +396,6 @@ public: { const auto& dataset = serializable.DataSet; - vtkm::IdComponent numberOfCoordinateSystems = dataset.GetNumberOfCoordinateSystems(); - vtkmdiy::save(bb, numberOfCoordinateSystems); - for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i) - { - vtkmdiy::save(bb, dataset.GetCoordinateSystem(i)); - } - vtkmdiy::save(bb, dataset.GetCellSet().ResetCellSetList(CellSetTypesList{})); vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields(); @@ -417,6 +404,13 @@ public: { vtkmdiy::save(bb, dataset.GetField(i)); } + + vtkm::IdComponent numberOfCoordinateSystems = dataset.GetNumberOfCoordinateSystems(); + vtkmdiy::save(bb, numberOfCoordinateSystems); + for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i) + { + vtkmdiy::save(bb, dataset.GetCoordinateSystemName(i)); + } } static VTKM_CONT void load(BinaryBuffer& bb, Type& serializable) @@ -424,15 +418,6 @@ public: auto& dataset = serializable.DataSet; dataset = {}; // clear - vtkm::IdComponent numberOfCoordinateSystems = 0; - vtkmdiy::load(bb, numberOfCoordinateSystems); - for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i) - { - vtkm::cont::CoordinateSystem coords; - vtkmdiy::load(bb, coords); - dataset.AddCoordinateSystem(coords); - } - vtkm::cont::UncertainCellSet cells; vtkmdiy::load(bb, cells); dataset.SetCellSet(cells); @@ -445,6 +430,15 @@ public: vtkmdiy::load(bb, field); dataset.AddField(field); } + + vtkm::IdComponent numberOfCoordinateSystems = 0; + vtkmdiy::load(bb, numberOfCoordinateSystems); + for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i) + { + std::string coordName; + vtkmdiy::load(bb, coordName); + dataset.AddCoordinateSystem(coordName); + } } }; diff --git a/vtkm/cont/DataSetBuilderExplicit.h b/vtkm/cont/DataSetBuilderExplicit.h index fa68f257c..a45c9eb46 100644 --- a/vtkm/cont/DataSetBuilderExplicit.h +++ b/vtkm/cont/DataSetBuilderExplicit.h @@ -68,32 +68,6 @@ public: const std::vector& connectivity, const std::string& coordsNm = "coords"); - template - VTKM_DEPRECATED(1.6, - "Combine point coordinate arrays using most appropriate array (e.g. " - "ArrayHandleCompositeVector, ArrayHandleSOA, ArrayHandleCartesianProduct") - VTKM_CONT static vtkm::cont::DataSet - Create(const vtkm::cont::ArrayHandle& xVals, - const vtkm::cont::ArrayHandle& yVals, - const vtkm::cont::ArrayHandle& zVals, - const vtkm::cont::ArrayHandle& shapes, - const vtkm::cont::ArrayHandle& numIndices, - const vtkm::cont::ArrayHandle& connectivity, - const std::string& coordsNm = "coords") - { - VTKM_ASSERT(xVals.GetNumberOfValues() == yVals.GetNumberOfValues()); - VTKM_ASSERT(xVals.GetNumberOfValues() == zVals.GetNumberOfValues()); - - auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices); - - return DataSetBuilderExplicit::BuildDataSet( - vtkm::cont::make_ArrayHandleCompositeVector(xVals, yVals, zVals), - shapes, - offsets, - connectivity, - coordsNm); - } - template VTKM_CONT static vtkm::cont::DataSet Create(const std::vector>& coords, const std::vector& shapes, diff --git a/vtkm/cont/DataSetFieldAdd.h b/vtkm/cont/DataSetFieldAdd.h deleted file mode 100644 index bbcdf90b6..000000000 --- a/vtkm/cont/DataSetFieldAdd.h +++ /dev/null @@ -1,105 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_DataSetFieldAdd_h -#define vtk_m_cont_DataSetFieldAdd_h - -#include -#include -#include - -namespace vtkm -{ -namespace cont -{ - -class VTKM_DEPRECATED(1.6, - "The AddPointField and AddCellField methods should now be called " - "directly on the vtkm::cont::DataSet object") DataSetFieldAdd -{ -public: - VTKM_CONT - DataSetFieldAdd() {} - - //Point centered fields. - VTKM_CONT - static void AddPointField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const vtkm::cont::UnknownArrayHandle& field) - { - dataSet.AddField(make_FieldPoint(fieldName, field)); - } - - template - VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const vtkm::cont::ArrayHandle& field) - { - dataSet.AddField(make_FieldPoint(fieldName, field)); - } - - template - VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const std::vector& field) - { - dataSet.AddField( - make_Field(fieldName, vtkm::cont::Field::Association::Points, field, vtkm::CopyFlag::On)); - } - - template - VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const T* field, - const vtkm::Id& n) - { - dataSet.AddField( - make_Field(fieldName, vtkm::cont::Field::Association::Points, field, n, vtkm::CopyFlag::On)); - } - - //Cell centered field - VTKM_CONT - static void AddCellField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const vtkm::cont::UnknownArrayHandle& field) - { - dataSet.AddField(make_FieldCell(fieldName, field)); - } - - template - VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const vtkm::cont::ArrayHandle& field) - { - dataSet.AddField(make_FieldCell(fieldName, field)); - } - - template - VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const std::vector& field) - { - dataSet.AddField( - make_Field(fieldName, vtkm::cont::Field::Association::Cells, field, vtkm::CopyFlag::On)); - } - - template - VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, - const std::string& fieldName, - const T* field, - const vtkm::Id& n) - { - dataSet.AddField( - make_Field(fieldName, vtkm::cont::Field::Association::Cells, field, n, vtkm::CopyFlag::On)); - } -}; -} -} //namespace vtkm::cont - -#endif //vtk_m_cont_DataSetFieldAdd_h diff --git a/vtkm/cont/DeviceAdapterListTag.h b/vtkm/cont/DeviceAdapterListTag.h deleted file mode 100644 index d79b2019b..000000000 --- a/vtkm/cont/DeviceAdapterListTag.h +++ /dev/null @@ -1,54 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_DeviceAdapterListTag_h -#define vtk_m_cont_DeviceAdapterListTag_h - -// Everything in this header file is deprecated and movded to DeviceAdapterList.h. - -#ifndef VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG -#define VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG ::vtkm::cont::detail::DeviceAdapterListTagDefault -#endif - -#include - -#include - -namespace vtkm -{ -namespace cont -{ - -/// @cond NONE -struct VTKM_DEPRECATED(1.6, - "DeviceAdapterListTagCommon replaced by DeviceAdapterListCommon. " - "Note that the new DeviceAdapterListCommon cannot be subclassed.") - DeviceAdapterListTagCommon : vtkm::internal::ListAsListTag -{ -}; -/// @endcond - -namespace detail -{ - -/// @cond NONE -struct VTKM_DEPRECATED( - 1.6, - "VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG replaced by VTKM_DEFAULT_DEVICE_ADAPTER_LIST. " - "Note that the new VTKM_DEFAULT_DEVICE_ADAPTER_LIST cannot be subclassed.") - DeviceAdapterListTagDefault : vtkm::internal::ListAsListTag -{ -}; -/// @endcond - -} // namespace detail -} -} // namespace vtkm::cont - -#endif //vtk_m_cont_DeviceAdapterListTag_h diff --git a/vtkm/cont/DynamicCellSet.h b/vtkm/cont/DynamicCellSet.h deleted file mode 100644 index 01a57307b..000000000 --- a/vtkm/cont/DynamicCellSet.h +++ /dev/null @@ -1,27 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_DynamicCellSet_h -#define vtk_m_cont_DynamicCellSet_h - -#include - -struct VTKM_DEPRECATED(1.8, "Use UnknownCellSet.h or UncertainCellSet.h.") - DynamicCellSet_h_header_is_deprecated -{ - int x; -}; - -inline void EmitDynamicCellSetHDeprecationWarning() -{ - static DynamicCellSet_h_header_is_deprecated x; - ++x.x; -} - -#endif //vtk_m_cont_DynamicCellSet_h diff --git a/vtkm/cont/ExecutionAndControlObjectBase.h b/vtkm/cont/ExecutionAndControlObjectBase.h index a8b473a52..8337f9188 100644 --- a/vtkm/cont/ExecutionAndControlObjectBase.h +++ b/vtkm/cont/ExecutionAndControlObjectBase.h @@ -61,8 +61,7 @@ struct HasPrepareForControl #define VTKM_IS_EXECUTION_AND_CONTROL_OBJECT(execObject) \ static_assert(::vtkm::cont::internal::IsExecutionAndControlObjectBase::value, \ "Provided type is not a subclass of vtkm::cont::ExecutionAndControlObjectBase."); \ - static_assert(::vtkm::cont::internal::HasPrepareForExecution::value || \ - ::vtkm::cont::internal::HasPrepareForExecutionDeprecated::value, \ + static_assert(::vtkm::cont::internal::HasPrepareForExecution::value, \ "Provided type does not have requisite PrepareForExecution method."); \ static_assert(::vtkm::cont::internal::HasPrepareForControl::value, \ "Provided type does not have requisite PrepareForControl method.") diff --git a/vtkm/cont/ExecutionObjectBase.h b/vtkm/cont/ExecutionObjectBase.h index 52d248bc4..ddc7acb9b 100644 --- a/vtkm/cont/ExecutionObjectBase.h +++ b/vtkm/cont/ExecutionObjectBase.h @@ -10,7 +10,6 @@ #ifndef vtk_m_cont_ExecutionObjectBase_h #define vtk_m_cont_ExecutionObjectBase_h -#include #include #include @@ -50,18 +49,6 @@ struct CheckPrepareForExecution static auto check(...) -> std::false_type; }; -struct CheckPrepareForExecutionDeprecated -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - template - static auto check(T* p) - -> decltype(p->PrepareForExecution(vtkm::cont::DeviceAdapterTagSerial{}), std::true_type()); - VTKM_DEPRECATED_SUPPRESS_END - - template - static auto check(...) -> std::false_type; -}; - } // namespace detail template @@ -74,20 +61,12 @@ struct HasPrepareForExecution { }; -template -struct HasPrepareForExecutionDeprecated - : decltype( - detail::CheckPrepareForExecutionDeprecated::check::type>(nullptr)) -{ -}; - /// Checks that the argument is a proper execution object. /// -#define VTKM_IS_EXECUTION_OBJECT(execObject) \ - static_assert(::vtkm::cont::internal::IsExecutionObjectBase::value, \ - "Provided type is not a subclass of vtkm::cont::ExecutionObjectBase."); \ - static_assert(::vtkm::cont::internal::HasPrepareForExecution::value || \ - ::vtkm::cont::internal::HasPrepareForExecutionDeprecated::value, \ +#define VTKM_IS_EXECUTION_OBJECT(execObject) \ + static_assert(::vtkm::cont::internal::IsExecutionObjectBase::value, \ + "Provided type is not a subclass of vtkm::cont::ExecutionObjectBase."); \ + static_assert(::vtkm::cont::internal::HasPrepareForExecution::value, \ "Provided type does not have requisite PrepareForExecution method.") ///@{ @@ -120,30 +99,6 @@ VTKM_CONT auto CallPrepareForExecution(T&& execObject, } ///@} -// If you get a deprecation warning at this function, it means that an ExecutionObject is using the -// old style PrepareForExecution. Update its PrepareForExecution method to accept both a device and -// a token. -// -// Developer note: the third template argument, TokenType, is expected to be a vtkm::cont::Token -// (which is ignored). The reason why it is a template argument instead of just the type expected -// is so that ExecObjects that implement both versions of PrepareForExecution (for backward -// compatibility) will match the non-deprecated version instead of being ambiguous. -template -VTKM_CONT VTKM_DEPRECATED( - 1.6, - "ExecutionObjects now require a PrepareForExecution that takes a vtkm::cont::Token object. " - "PrepareForExecution(Device) is deprecated. Implement PrepareForExecution(Device, " - "Token).") auto CallPrepareForExecution(T&& execObject, Device device, TokenType&) - -> decltype(execObject.PrepareForExecution(device)) -{ - VTKM_IS_EXECUTION_OBJECT(T); - VTKM_IS_DEVICE_ADAPTER_TAG(Device); - VTKM_STATIC_ASSERT( - (std::is_same::type>::value)); - - return execObject.PrepareForExecution(device); -} - /// \brief Gets the type of the execution-side object for an ExecutionObject. /// /// An execution object (that is, an object inheriting from `vtkm::cont::ExecutionObjectBase`) is diff --git a/vtkm/cont/Field.h b/vtkm/cont/Field.h index c9a99dbf3..8ec7e1a25 100644 --- a/vtkm/cont/Field.h +++ b/vtkm/cont/Field.h @@ -39,13 +39,6 @@ public: Cells, Partitions, Global, - ANY VTKM_DEPRECATED(1.8, "Use vtkm::cont::Field::Association::Any.") = Any, - WHOLE_MESH VTKM_DEPRECATED(1.8, "Use vtkm::cont::Field::Association::WholeDataSet.") = - WholeDataSet, - POINTS VTKM_DEPRECATED(1.8, "Use vtkm::cont::Field::Association::Points.") = Points, - CELL_SET VTKM_DEPRECATED(1.8, "Use vtkm::cont::Field::Association::Cells.") = Cells, - WholeMesh VTKM_DEPRECATED(1.9, "Use vtkm::cont::Field::Association::WholeDataSet.") = - WholeDataSet }; VTKM_CONT @@ -82,16 +75,6 @@ public: } VTKM_CONT bool IsGlobalField() const { return this->FieldAssociation == Association::Global; } - VTKM_DEPRECATED(1.9, "Use IsCellField.") - VTKM_CONT bool IsFieldCell() const { return this->IsCellField(); } - VTKM_DEPRECATED(1.9, "Use IsPointField.") - VTKM_CONT bool IsFieldPoint() const { return this->IsPointField(); } - VTKM_DEPRECATED(1.9, "Use IsWholeDataSetField. Note that meaning of `Global` has changed!") - VTKM_CONT bool IsFieldGlobal() const - { - return this->FieldAssociation == Association::WholeDataSet; - } - /// Returns true if the array of the field has a value type that matches something in /// `VTKM_FIELD_TYPE_LIST` and a storage that matches something in `VTKM_FIELD_STORAGE_LIST`. VTKM_CONT bool IsSupportedType() const; @@ -157,20 +140,6 @@ public: /// VTKM_CONT void ConvertToExpected(); - template - VTKM_DEPRECATED(1.6, "TypeList no longer supported in Field::GetRange.") - VTKM_CONT void GetRange(vtkm::Range* range, TypeList) const - { - this->GetRange(range); - } - - template - VTKM_DEPRECATED(1.6, "TypeList no longer supported in Field::GetRange.") - VTKM_CONT const vtkm::cont::ArrayHandle& GetRange(TypeList) const - { - return this->GetRange(); - } - VTKM_CONT void SetData(const vtkm::cont::UnknownArrayHandle& newdata); template @@ -217,14 +186,6 @@ vtkm::cont::Field make_Field(std::string name, return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandle(data, size, copy)); } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_Field.") -vtkm::cont::Field - make_Field(std::string name, Field::Association association, const T* data, vtkm::Id size) -{ - return make_Field(name, association, data, size, vtkm::CopyFlag::Off); -} - template vtkm::cont::Field make_Field(std::string name, Field::Association association, @@ -234,20 +195,12 @@ vtkm::cont::Field make_Field(std::string name, return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandle(data, copy)); } -template -VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_Field.") -vtkm::cont::Field - make_Field(std::string name, Field::Association association, const std::vector& data) -{ - return make_Field(name, association, data, vtkm::CopyFlag::Off); -} - template vtkm::cont::Field make_FieldMove(std::string name, Field::Association association, std::vector&& data) { - return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandleMove(data)); + return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandleMove(std::move(data))); } template @@ -320,24 +273,6 @@ struct DynamicTransformTraits //============================================================================= // Specializations of serialization related classes /// @cond SERIALIZATION -namespace vtkm -{ -namespace cont -{ -template -struct VTKM_DEPRECATED(1.6, "You can now directly serialize Field.") SerializableField -{ - SerializableField() = default; - - explicit SerializableField(const vtkm::cont::Field& field) - : Field(field) - { - } - - vtkm::cont::Field Field; -}; -} // namespace cont -} // namespace vtkm namespace mangled_diy_namespace { @@ -349,27 +284,6 @@ struct VTKM_CONT_EXPORT Serialization static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::Field& field); }; -// Implement deprecated code -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -struct Serialization> -{ -private: - using Type = vtkm::cont::SerializableField; - -public: - static VTKM_CONT void save(BinaryBuffer& bb, const Type& serializable) - { - Serialization::save(bb, serializable.Field); - } - - static VTKM_CONT void load(BinaryBuffer& bb, Type& serializable) - { - Serialization::load(bb, serializable.Field); - } -}; -VTKM_DEPRECATED_SUPPRESS_END - } // diy /// @endcond SERIALIZATION diff --git a/vtkm/cont/FieldRangeCompute.h b/vtkm/cont/FieldRangeCompute.h index ff8223882..ba11dfb34 100644 --- a/vtkm/cont/FieldRangeCompute.h +++ b/vtkm/cont/FieldRangeCompute.h @@ -37,32 +37,6 @@ vtkm::cont::ArrayHandle FieldRangeCompute( const vtkm::cont::DataSet& dataset, const std::string& name, vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::Any); - -template -VTKM_DEPRECATED(1.6, "FieldRangeCompute no longer supports TypeList.") -VTKM_CONT vtkm::cont::ArrayHandle FieldRangeCompute( - const vtkm::cont::DataSet& dataset, - const std::string& name, - vtkm::cont::Field::Association assoc, - TypeList) -{ - VTKM_IS_LIST(TypeList); - vtkm::cont::Field field; - try - { - field = dataset.GetField(name, assoc); - } - catch (vtkm::cont::ErrorBadValue&) - { - // field missing, return empty range. - return vtkm::cont::ArrayHandle(); - } - - VTKM_DEPRECATED_SUPPRESS_BEGIN - return field.GetRange(TypeList()); - VTKM_DEPRECATED_SUPPRESS_END -} - //@} //{@ @@ -80,48 +54,8 @@ vtkm::cont::ArrayHandle FieldRangeCompute( const vtkm::cont::PartitionedDataSet& pds, const std::string& name, vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::Any); - -template -VTKM_DEPRECATED(1.6, "FieldRangeCompute no longer supports TypeList.") -VTKM_CONT vtkm::cont::ArrayHandle FieldRangeCompute( - const vtkm::cont::PartitionedDataSet& pds, - const std::string& name, - vtkm::cont::Field::Association assoc, - TypeList) -{ - VTKM_IS_LIST(TypeList); - VTKM_STATIC_ASSERT_MSG((!std::is_same::value), - "Cannot use vtkm::ListUniversal with FieldRangeCompute."); - std::vector result_vector = std::accumulate( - pds.begin(), - pds.end(), - std::vector(), - [&](const std::vector& accumulated_value, const vtkm::cont::DataSet& dataset) { - VTKM_DEPRECATED_SUPPRESS_BEGIN - vtkm::cont::ArrayHandle partition_range = - vtkm::cont::FieldRangeCompute(dataset, name, assoc, TypeList()); - VTKM_DEPRECATED_SUPPRESS_END - - std::vector result = accumulated_value; - - // if the current partition has more components than we have seen so far, - // resize the result to fit all components. - result.resize( - std::max(result.size(), static_cast(partition_range.GetNumberOfValues()))); - - auto portal = partition_range.ReadPortal(); - std::transform(vtkm::cont::ArrayPortalToIteratorBegin(portal), - vtkm::cont::ArrayPortalToIteratorEnd(portal), - result.begin(), - result.begin(), - std::plus()); - return result; - }); - - return vtkm::cont::make_ArrayHandleMove(std::move(result_vector)); -} - //@} + } } // namespace vtkm::cont diff --git a/vtkm/cont/FieldRangeGlobalCompute.h b/vtkm/cont/FieldRangeGlobalCompute.h index b527e42f3..26d755ce8 100644 --- a/vtkm/cont/FieldRangeGlobalCompute.h +++ b/vtkm/cont/FieldRangeGlobalCompute.h @@ -42,22 +42,6 @@ vtkm::cont::ArrayHandle FieldRangeGlobalCompute( const vtkm::cont::DataSet& dataset, const std::string& name, vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::Any); - -template -VTKM_DEPRECATED(1.6, "FieldRangeGlobalCompute no longer supports TypeList.") -VTKM_CONT vtkm::cont::ArrayHandle FieldRangeGlobalCompute( - const vtkm::cont::DataSet& dataset, - const std::string& name, - vtkm::cont::Field::Association assoc, - TypeList) -{ - VTKM_IS_LIST(TypeList); - VTKM_DEPRECATED_SUPPRESS_BEGIN - auto lrange = vtkm::cont::FieldRangeCompute(dataset, name, assoc, TypeList()); - VTKM_DEPRECATED_SUPPRESS_END - return vtkm::cont::detail::MergeRangesGlobal(lrange); -} - //@} //{@ @@ -74,22 +58,8 @@ vtkm::cont::ArrayHandle FieldRangeGlobalCompute( const vtkm::cont::PartitionedDataSet& pds, const std::string& name, vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::Any); - -template -VTKM_DEPRECATED(1.6, "FieldRangeGlobalCompute no longer supports TypeList.") -VTKM_CONT vtkm::cont::ArrayHandle FieldRangeGlobalCompute( - const vtkm::cont::PartitionedDataSet& pds, - const std::string& name, - vtkm::cont::Field::Association assoc, - TypeList) -{ - VTKM_IS_LIST(TypeList); - VTKM_DEPRECATED_SUPPRESS_BEGIN - auto lrange = vtkm::cont::FieldRangeCompute(pds, name, assoc, TypeList()); - VTKM_DEPRECATED_SUPPRESS_END - return vtkm::cont::detail::MergeRangesGlobal(lrange); -} //@} + } } // namespace vtkm::cont diff --git a/vtkm/cont/ImplicitFunctionHandle.h b/vtkm/cont/ImplicitFunctionHandle.h deleted file mode 100644 index d3284a735..000000000 --- a/vtkm/cont/ImplicitFunctionHandle.h +++ /dev/null @@ -1,264 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_ImplicitFunctionHandle_h -#define vtk_m_cont_ImplicitFunctionHandle_h - -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "ImplicitFunction with virtual methods is removed. Do not include ImplicitFunctionHeader.h" -#endif - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ - -namespace detail -{ - -// Wrong namespace, but it's only for deprecated code. -template -class VTKM_ALWAYS_EXPORT ImplicitFunctionBaseExecWrapper : public vtkm::ImplicitFunction -{ - FunctionType Function; - -public: - VTKM_CONT ImplicitFunctionBaseExecWrapper(const FunctionType& function) - : Function(function) - { - } - - VTKM_EXEC_CONT virtual ~ImplicitFunctionBaseExecWrapper() noexcept override - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC_CONT virtual Scalar Value(const Vector& point) const override - { - return this->Function.Value(point); - } - - VTKM_EXEC_CONT virtual Vector Gradient(const Vector& point) const override - { - return this->Function.Gradient(point); - } -}; - -} // vtkm::cont::detail - -class VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionX classes directly.") VTKM_ALWAYS_EXPORT - ImplicitFunctionHandle : public vtkm::cont::VirtualObjectHandle -{ -private: - using Superclass = vtkm::cont::VirtualObjectHandle; - -public: - ImplicitFunctionHandle() = default; - - template ::value>::type> - explicit ImplicitFunctionHandle(VirtualDerivedType* function, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - : Superclass(function, acquireOwnership, devices) - { - } - - template - explicit ImplicitFunctionHandle( - vtkm::internal::ImplicitFunctionBase* function, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - : Superclass(new detail::ImplicitFunctionBaseExecWrapper( - *reinterpret_cast(function)), - true, - devices) - { - if (acquireOwnership) - { - delete function; - } - } - - template - VTKM_CONT void Reset(vtkm::internal::ImplicitFunctionBase* function, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList{}) - { - this->Reset(new detail::ImplicitFunctionBaseExecWrapper( - *reinterpret_cast(function)), - true, - devices); - if (acquireOwnership) - { - delete function; - } - } - - template ::value>::type> - VTKM_CONT void Reset(VirtualDerivedType* derived, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - { - this->Superclass::Reset(derived, acquireOwnership, devices); - } -}; - -template -VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionX classes directly.") -VTKM_CONT ImplicitFunctionHandle - make_ImplicitFunctionHandle(ImplicitFunctionType&& func, - DeviceAdapterList devices = DeviceAdapterList()) -{ - using IFType = typename std::remove_reference::type; - return ImplicitFunctionHandle( - new IFType(std::forward(func)), true, devices); -} - -template -VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionX classes directly.") -VTKM_CONT ImplicitFunctionHandle make_ImplicitFunctionHandle(Args&&... args) -{ - return ImplicitFunctionHandle(new ImplicitFunctionType(std::forward(args)...), - true, - VTKM_DEFAULT_DEVICE_ADAPTER_LIST()); -} - -template -VTKM_CONT ImplicitFunctionHandle make_ImplicitFunctionHandle(Args&&... args) -{ - return ImplicitFunctionHandle( - new ImplicitFunctionType(std::forward(args)...), true, DeviceAdapterList()); -} - -//============================================================================ -/// A helpful wrapper that returns a functor that calls the (virtual) value method of a given -/// ImplicitFunction. Can be passed to things that expect a functor instead of an ImplictFunction -/// class (like an array transform). -/// -class VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionValueFunctor.") - VTKM_ALWAYS_EXPORT ImplicitFunctionValueHandle : public vtkm::cont::ExecutionAndControlObjectBase -{ - vtkm::cont::ImplicitFunctionHandle Handle; - -public: - ImplicitFunctionValueHandle() = default; - - ImplicitFunctionValueHandle(const ImplicitFunctionHandle& handle) - : Handle(handle) - { - } - - template - explicit ImplicitFunctionValueHandle(ImplicitFunctionType* function, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - : Handle(function, acquireOwnership, devices) - { - } - - VTKM_CONT const vtkm::cont::ImplicitFunctionHandle& GetHandle() const { return this->Handle; } - - VTKM_CONT - vtkm::ImplicitFunctionValue PrepareForExecution(vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const - { - return vtkm::ImplicitFunctionValue(this->Handle.PrepareForExecution(device, token)); - } - - VTKM_CONT vtkm::ImplicitFunctionValue PrepareForControl() const - { - return vtkm::ImplicitFunctionValue(this->Handle.PrepareForControl()); - } -}; - -template -VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionValueFunctor.") -VTKM_CONT ImplicitFunctionValueHandle - make_ImplicitFunctionValueHandle(ImplicitFunctionType&& func, - DeviceAdapterList devices = DeviceAdapterList()) -{ - using IFType = typename std::remove_reference::type; - return ImplicitFunctionValueHandle( - new IFType(std::forward(func)), true, devices); -} - -template -VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionValueFunctor.") -VTKM_CONT ImplicitFunctionValueHandle make_ImplicitFunctionValueHandle(Args&&... args) -{ - return ImplicitFunctionValueHandle(new ImplicitFunctionType(std::forward(args)...), - true, - VTKM_DEFAULT_DEVICE_ADAPTER_LIST()); -} - -template -VTKM_DEPRECATED(1.6, - "ImplicitFunctions with virtual methods are no longer supported. " - "Use vtkm::ImplicitFunctionValueFunctor.") -VTKM_CONT ImplicitFunctionValueHandle make_ImplicitFunctionValueHandle(Args&&... args) -{ - return ImplicitFunctionValueHandle( - new ImplicitFunctionType(std::forward(args)...), true, DeviceAdapterList()); -} -} -} // vtkm::cont - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -// Cuda seems to have a bug where it expects the template class VirtualObjectTransfer -// to be instantiated in a consistent order among all the translation units of an -// executable. Failing to do so results in random crashes and incorrect results. -// We workaroud this issue by explicitly instantiating VirtualObjectTransfer for -// all the implicit functions here. -#ifdef VTKM_CUDA -#include -VTKM_EXPLICITLY_INSTANTIATE_TRANSFER( - vtkm::cont::detail::ImplicitFunctionBaseExecWrapper); -VTKM_EXPLICITLY_INSTANTIATE_TRANSFER( - vtkm::cont::detail::ImplicitFunctionBaseExecWrapper); -VTKM_EXPLICITLY_INSTANTIATE_TRANSFER( - vtkm::cont::detail::ImplicitFunctionBaseExecWrapper); -VTKM_EXPLICITLY_INSTANTIATE_TRANSFER( - vtkm::cont::detail::ImplicitFunctionBaseExecWrapper); -VTKM_EXPLICITLY_INSTANTIATE_TRANSFER( - vtkm::cont::detail::ImplicitFunctionBaseExecWrapper); -#endif -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtk_m_cont_ImplicitFunctionHandle_h diff --git a/vtkm/cont/Initialize.cxx b/vtkm/cont/Initialize.cxx index 56483691c..bee25c5ec 100644 --- a/vtkm/cont/Initialize.cxx +++ b/vtkm/cont/Initialize.cxx @@ -143,18 +143,25 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts) std::vector usage; if ((opts & InitializeOptions::AddHelp) != InitializeOptions::None) { - usage.push_back({ opt::OptionIndex::UNKNOWN, - 0, - "", - "", - opt::VtkmArg::UnknownOption, - "Usage information:\n" }); + // Because we have the AddHelp option, we will add both --help and --vtkm-help to + // the list of arguments. Use the first entry for introduction on the usage. + usage.push_back( + { opt::OptionIndex::HELP, 0, "", "vtkm-help", opt::Arg::None, "Usage information:\n" }); usage.push_back({ opt::OptionIndex::HELP, 0, "h", + "help", + opt::Arg::None, + " --help, --vtkm-help, -h \tPrint usage information." }); + } + else + { + usage.push_back({ opt::OptionIndex::HELP, + 0, + "", "vtkm-help", opt::Arg::None, - " --vtkm-help, -h \tPrint usage information." }); + " --vtkm-help \tPrint usage information." }); } usage.push_back( { opt::OptionIndex::DEVICE, @@ -170,25 +177,10 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts) opt::VtkmArg::Required, loggingHelp.c_str() }); - // TODO: remove deprecated options on next vtk-m release - usage.push_back({ opt::OptionIndex::DEPRECATED_DEVICE, - 0, - "d", - "device", - VtkmDeviceArg::IsDevice, - " --device, -d \tDEPRECATED: use --vtkm-device to set the device" }); - usage.push_back({ opt::OptionIndex::DEPRECATED_LOGLEVEL, - 0, - "v", - "", - opt::VtkmArg::Required, - " -v <#|INFO|WARNING|ERROR|FATAL|OFF> \tDEPRECATED: use --vtkm-log-level to " - "set the log level" }); - // Bring in extra args used by the runtime device configuration options vtkm::cont::internal::RuntimeDeviceConfigurationOptions runtimeDeviceOptions(usage); - // Required to collect unknown arguments when help is off. + // Required to collect unknown arguments. usage.push_back({ opt::OptionIndex::UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" }); usage.push_back({ 0, 0, 0, 0, 0, 0 }); @@ -233,32 +225,9 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts) vtkm::cont::DeviceAdapterTagAny{}, runtimeDeviceOptions, argc, argv); } - if (options[opt::OptionIndex::DEPRECATED_LOGLEVEL]) + if (options[opt::OptionIndex::DEVICE]) { - VTKM_LOG_S(vtkm::cont::LogLevel::Error, - "Supplied Deprecated log level flag: " - << std::string{ options[opt::OptionIndex::DEPRECATED_LOGLEVEL].name } << ", use " - << loggingFlag << " instead."); -#ifdef VTKM_ENABLE_LOGGING - vtkm::cont::SetStderrLogLevel(options[opt::OptionIndex::DEPRECATED_LOGLEVEL].arg); -#endif // VTKM_ENABLE_LOGGING - } - - if (options[opt::OptionIndex::DEVICE] || options[opt::OptionIndex::DEPRECATED_DEVICE]) - { - const char* arg = nullptr; - if (options[opt::OptionIndex::DEPRECATED_DEVICE]) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Error, - "Supplied Deprecated device flag " - << std::string{ options[opt::OptionIndex::DEPRECATED_DEVICE].name } - << ", use --vtkm-device instead"); - arg = options[opt::OptionIndex::DEPRECATED_DEVICE].arg; - } - if (options[opt::OptionIndex::DEVICE]) - { - arg = options[opt::OptionIndex::DEVICE].arg; - } + const char* arg = options[opt::OptionIndex::DEVICE].arg; auto id = vtkm::cont::make_DeviceAdapterId(arg); if (id != vtkm::cont::DeviceAdapterTagAny{}) { diff --git a/vtkm/cont/Logging.cxx b/vtkm/cont/Logging.cxx index 02ada4e90..e4d8510ab 100644 --- a/vtkm/cont/Logging.cxx +++ b/vtkm/cont/Logging.cxx @@ -374,16 +374,6 @@ LogScope::~LogScope() = default; } // namespace detail -VTKM_CONT -void LogScope(LogLevel level, const char* file, unsigned line, const char* format...) -{ - // This does not scope right, but neither did the deprecated method this is replacing. - va_list args; - va_start(args, format); - detail::LogScope scopedVar{ level, file, line, format, args }; - va_end(args); -} - VTKM_CONT void LogCond(LogLevel level, bool cond, const char* file, unsigned line, const char* format...) { diff --git a/vtkm/cont/Logging.h b/vtkm/cont/Logging.h index 7ca807494..2f1f22746 100644 --- a/vtkm/cont/Logging.h +++ b/vtkm/cont/Logging.h @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -215,9 +214,6 @@ #define VTKM_LOG_SCOPE_FUNCTION(level) VTKM_LOG_SCOPE(level, __func__) #define VTKM_LOG_ALWAYS_S(level, ...) VTKM_LOG_S(level, __VA_ARGS__) -// VTKM_LOG_ERROR_CONTEXT is disabled as it is deprecated -#define VTKM_LOG_ERROR_CONTEXT(desc, data) - // Convenience macros: @@ -536,11 +532,6 @@ public: } // namespace detail -VTKM_DEPRECATED(1.9, "Use VTKM_LOG_SCOPE macro.") -VTKM_CONT_EXPORT -VTKM_CONT -void LogScope(LogLevel level, const char* file, unsigned line, const char* format...); - /** * \brief Conditionally logs a message with a stream-like interface. * diff --git a/vtkm/cont/ParticleArrayCopy.hxx b/vtkm/cont/ParticleArrayCopy.hxx index 8901d5104..33e7b0697 100644 --- a/vtkm/cont/ParticleArrayCopy.hxx +++ b/vtkm/cont/ParticleArrayCopy.hxx @@ -29,14 +29,14 @@ template struct ExtractPositionFunctor { VTKM_EXEC_CONT - vtkm::Vec3f operator()(const ParticleType& p) const { return p.Pos; } + vtkm::Vec3f operator()(const ParticleType& p) const { return p.GetPosition(); } }; template struct ExtractTerminatedFunctor { VTKM_EXEC_CONT - bool operator()(const ParticleType& p) const { return p.Status.CheckTerminate(); } + bool operator()(const ParticleType& p) const { return p.GetStatus().CheckTerminate(); } }; template @@ -56,11 +56,11 @@ struct CopyParticleAllWorklet : public vtkm::worklet::WorkletMapField vtkm::ParticleStatus& outStatus, vtkm::FloatDefault& outTime) const { - outPos = inParticle.Pos; - outID = inParticle.ID; - outSteps = inParticle.NumSteps; - outStatus = inParticle.Status; - outTime = inParticle.Time; + outPos = inParticle.GetPosition(); + outID = inParticle.GetID(); + outSteps = inParticle.GetNumberOfSteps(); + outStatus = inParticle.GetStatus(); + outTime = inParticle.GetTime(); } }; diff --git a/vtkm/cont/PartitionedDataSet.h b/vtkm/cont/PartitionedDataSet.h index 145b4749d..4a5917933 100644 --- a/vtkm/cont/PartitionedDataSet.h +++ b/vtkm/cont/PartitionedDataSet.h @@ -47,12 +47,6 @@ public: VTKM_CONT PartitionedDataSet() = default; - VTKM_DEPRECATED(1.9, "Renamed to GetFieldFromPartition.") - VTKM_CONT vtkm::cont::Field GetField(const std::string& field_name, int partition_index) const - { - return this->GetFieldFromPartition(field_name, partition_index); - } - /// Get the field @a field_name from partition @a partition_index. VTKM_CONT vtkm::cont::Field GetFieldFromPartition(const std::string& field_name, int partition_index) const; diff --git a/vtkm/cont/PointLocator.cxx b/vtkm/cont/PointLocator.cxx deleted file mode 100644 index 483dc25cd..000000000 --- a/vtkm/cont/PointLocator.cxx +++ /dev/null @@ -1,31 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -// -// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS). -// Copyright 2019 UT-Battelle, LLC. -// Copyright 2019 Los Alamos National Security. -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National -// Laboratory (LANL), the U.S. Government retains certain rights in -// this software. -//============================================================================ - -#include - -namespace vtkm -{ -namespace cont -{ -VTKM_DEPRECATED_SUPPRESS_BEGIN -PointLocator::~PointLocator() = default; -VTKM_DEPRECATED_SUPPRESS_BEGIN -} -} diff --git a/vtkm/cont/PointLocator.h b/vtkm/cont/PointLocator.h deleted file mode 100644 index e8d24fbe4..000000000 --- a/vtkm/cont/PointLocator.h +++ /dev/null @@ -1,88 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_PointLocator_h -#define vtk_m_cont_PointLocator_h - -#include -#include - -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "PointLocator with virtual methods is removed. Do not include PointLocator.h" -#endif - -namespace vtkm -{ -namespace cont -{ - -class VTKM_CONT_EXPORT VTKM_DEPRECATED(1.6, "PointLocator with virtual methods no longer supported") - PointLocator : public vtkm::cont::ExecutionObjectBase -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - -public: - virtual ~PointLocator(); - - PointLocator() - : Modified(true) - { - } - - vtkm::cont::CoordinateSystem GetCoordinates() const { return this->Coords; } - - void SetCoordinates(const vtkm::cont::CoordinateSystem& coords) - { - this->Coords = coords; - this->SetModified(); - } - - void Update() - { - if (this->Modified) - { - Build(); - this->Modified = false; - } - } - - VTKM_CONT virtual const vtkm::exec::PointLocator* PrepareForExecution( - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const = 0; - - VTKM_CONT - VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object") - const vtkm::exec::PointLocator* PrepareForExecution(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); - } - -protected: - void SetModified() { this->Modified = true; } - - bool GetModified() const { return this->Modified; } - - virtual void Build() = 0; - -private: - vtkm::cont::CoordinateSystem Coords; - bool Modified; -}; -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace vtkm::cont -} // namespace vtkm - -#endif // vtk_m_cont_PointLocator_h diff --git a/vtkm/cont/PointLocatorUniformGrid.h b/vtkm/cont/PointLocatorUniformGrid.h deleted file mode 100644 index 4e8fe8dcf..000000000 --- a/vtkm/cont/PointLocatorUniformGrid.h +++ /dev/null @@ -1,30 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_PointLocatorUniformGrid_h -#define vtk_m_cont_PointLocatorUniformGrid_h - -#include - -#include - -namespace vtkm -{ -namespace cont -{ - -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Replaced with PointLocatorSparseGrid.") - PointLocatorUniformGrid : vtkm::cont::PointLocatorSparseGrid -{ -}; - -} -} - -#endif //vtk_m_cont_PointLocatorUniformGrid_h diff --git a/vtkm/cont/StorageImplicit.h b/vtkm/cont/StorageImplicit.h deleted file mode 100644 index cd5f4e5be..000000000 --- a/vtkm/cont/StorageImplicit.h +++ /dev/null @@ -1,29 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_StorageImplicit_h -#define vtk_m_cont_StorageImplicit_h - -#include -#include - -namespace vtkm -{ - -VTKM_DEPRECATED(1.6, "Use ArrayHandleImplicit.h instead of StorageImplicit.h.") -inline void StorageImplicit_h_deprecated() {} - -inline void ActivateStorageImplicit_h_deprecated_warning() -{ - StorageImplicit_h_deprecated(); -} - -} // namespace vtkm - -#endif //vtk_m_cont_StorageImplicit_h diff --git a/vtkm/cont/StorageListTag.h b/vtkm/cont/StorageListTag.h deleted file mode 100644 index c13cf912a..000000000 --- a/vtkm/cont/StorageListTag.h +++ /dev/null @@ -1,80 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_StorageListTag_h -#define vtk_m_cont_StorageListTag_h - -// Everything in this header file is deprecated and moved to StorageList.h. -#include - -struct VTKM_DEPRECATED( - 1.6, - "TypeListTag.h is deprecated. Include TypeList.h and use vtkm::TypeList* instead.") - VTKmTypeListTagHeaderDeprecationWarning -{ -}; - -inline VTKmTypeListTagHeaderDeprecationWarning IssueVTKmTypeListTagHeaderDeprecationWarning() -{ - return {}; -} - -#ifndef VTKM_DEFAULT_STORAGE_LIST_TAG -#define VTKM_DEFAULT_STORAGE_LIST_TAG ::vtkm::cont::detail::StorageListTagDefault -#endif - -VTKM_DEPRECATED_SUPPRESS_BEGIN -#include -VTKM_DEPRECATED_SUPPRESS_END - -#include - -namespace vtkm -{ -namespace cont -{ - -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.6, - "StorageListTagBasic replaced by StorageListBasic. " - "Note that the new StorageListBasic cannot be subclassed.") StorageListTagBasic - : vtkm::internal::ListAsListTag -{ - /// @cond NONE -}; -/// @endcond - -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.6, - "StorageListTagSupported replaced by StorageListBasic. " - "Note that the new StorageListSupported cannot be subclassed.") StorageListTagSupported - : vtkm::internal::ListAsListTag -{ - /// @cond NONE -}; -/// @endcond - -namespace detail -{ - -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.6, - "VTKM_DEFAULT_STORAGE_LIST_TAG replaced by VTKM_DEFAULT_STORAGE_LIST. " - "Note that the new VTKM_DEFAULT_STORAGE_LIST cannot be subclassed.") StorageListTagDefault - : vtkm::internal::ListAsListTag -{ - /// @cond NONE -}; -/// @endcond - -} // namespace detail -} -} // namespace vtkm::cont - -#endif //vtk_m_cont_StorageListTag_h diff --git a/vtkm/cont/StorageVirtual.cxx b/vtkm/cont/StorageVirtual.cxx deleted file mode 100644 index d1174b5bc..000000000 --- a/vtkm/cont/StorageVirtual.cxx +++ /dev/null @@ -1,223 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#define vtk_m_cont_StorageVirtual_cxx -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ -namespace detail -{ - - -//-------------------------------------------------------------------- -StorageVirtual::StorageVirtual(const StorageVirtual& src) - : DeviceUpToDate(src.DeviceUpToDate) - , DeviceTransferState(src.DeviceTransferState) -{ -} - -//-------------------------------------------------------------------- -StorageVirtual::StorageVirtual(StorageVirtual&& src) noexcept - : DeviceUpToDate(src.DeviceUpToDate) - , DeviceTransferState(std::move(src.DeviceTransferState)) -{ -} - -//-------------------------------------------------------------------- -StorageVirtual& StorageVirtual::operator=(const StorageVirtual& src) -{ - this->DeviceUpToDate = src.DeviceUpToDate; - this->DeviceTransferState = src.DeviceTransferState; - return *this; -} - -//-------------------------------------------------------------------- -StorageVirtual& StorageVirtual::operator=(StorageVirtual&& src) noexcept -{ - this->DeviceUpToDate = src.DeviceUpToDate; - this->DeviceTransferState = std::move(src.DeviceTransferState); - return *this; -} - -//-------------------------------------------------------------------- -StorageVirtual::~StorageVirtual() {} - -//-------------------------------------------------------------------- -void StorageVirtual::DropExecutionPortal() -{ - this->DeviceTransferState->releaseDevice(); - this->DeviceUpToDate = false; -} - -//-------------------------------------------------------------------- -void StorageVirtual::DropAllPortals() -{ - this->DeviceTransferState->releaseAll(); - this->DeviceUpToDate = false; -} - -//-------------------------------------------------------------------- -std::unique_ptr StorageVirtual::NewInstance() const -{ - return this->MakeNewInstance(); -} - -//-------------------------------------------------------------------- -const vtkm::internal::PortalVirtualBase* StorageVirtual::PrepareForInput( - vtkm::cont::DeviceAdapterId devId) const -{ - if (devId == vtkm::cont::DeviceAdapterTagUndefined()) - { - throw vtkm::cont::ErrorBadValue("device should not be VTKM_DEVICE_ADAPTER_UNDEFINED"); - } - - const bool needsUpload = !(this->DeviceTransferState->valid(devId) && this->DeviceUpToDate); - - if (needsUpload) - { //Either transfer state is pointing to another device, or has - //had the execution resources released. Either way we - //need to re-transfer the execution information - auto* payload = this->DeviceTransferState.get(); - this->TransferPortalForInput(*payload, devId); - this->DeviceUpToDate = true; - } - return this->DeviceTransferState->devicePtr(); -} - -//-------------------------------------------------------------------- -const vtkm::internal::PortalVirtualBase* StorageVirtual::PrepareForOutput( - vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId devId) -{ - if (devId == vtkm::cont::DeviceAdapterTagUndefined()) - { - throw vtkm::cont::ErrorBadValue("device should not be VTKM_DEVICE_ADAPTER_UNDEFINED"); - } - - const bool needsUpload = !(this->DeviceTransferState->valid(devId) && this->DeviceUpToDate); - if (needsUpload) - { - this->TransferPortalForOutput( - *(this->DeviceTransferState), OutputMode::WRITE, numberOfValues, devId); - this->DeviceUpToDate = true; - } - return this->DeviceTransferState->devicePtr(); -} - -//-------------------------------------------------------------------- -const vtkm::internal::PortalVirtualBase* StorageVirtual::PrepareForInPlace( - vtkm::cont::DeviceAdapterId devId) -{ - if (devId == vtkm::cont::DeviceAdapterTagUndefined()) - { - throw vtkm::cont::ErrorBadValue("device should not be VTKM_DEVICE_ADAPTER_UNDEFINED"); - } - - const bool needsUpload = !(this->DeviceTransferState->valid(devId) && this->DeviceUpToDate); - if (needsUpload) - { - vtkm::Id numberOfValues = this->GetNumberOfValues(); - this->TransferPortalForOutput( - *(this->DeviceTransferState), OutputMode::READ_WRITE, numberOfValues, devId); - this->DeviceUpToDate = true; - } - return this->DeviceTransferState->devicePtr(); -} - -//-------------------------------------------------------------------- -const vtkm::internal::PortalVirtualBase* StorageVirtual::WritePortal() -{ - //we need to prepare for input and grab the host ptr - auto* payload = this->DeviceTransferState.get(); - this->ControlPortalForOutput(*payload); - - this->DeviceUpToDate = false; - return this->DeviceTransferState->hostPtr(); -} - -//-------------------------------------------------------------------- -const vtkm::internal::PortalVirtualBase* StorageVirtual::ReadPortal() const -{ - //we need to prepare for input and grab the host ptr - vtkm::cont::internal::TransferInfoArray* payload = this->DeviceTransferState.get(); - this->ControlPortalForInput(*payload); - - return this->DeviceTransferState->hostPtr(); -} - -//-------------------------------------------------------------------- -DeviceAdapterId StorageVirtual::GetDeviceAdapterId() const noexcept -{ - return this->DeviceTransferState->deviceId(); -} - -//-------------------------------------------------------------------- -void StorageVirtual::ControlPortalForOutput(vtkm::cont::internal::TransferInfoArray&) -{ - throw vtkm::cont::ErrorBadValue( - "StorageTagVirtual by default doesn't support control side writes."); -} - -//-------------------------------------------------------------------- -void StorageVirtual::TransferPortalForOutput(vtkm::cont::internal::TransferInfoArray&, - OutputMode, - vtkm::Id, - vtkm::cont::DeviceAdapterId) -{ - throw vtkm::cont::ErrorBadValue("StorageTagVirtual by default doesn't support exec side writes."); -} - -#define VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(T) \ - template class VTKM_CONT_EXPORT ArrayTransferVirtual; \ - template class VTKM_CONT_EXPORT ArrayTransferVirtual>; \ - template class VTKM_CONT_EXPORT ArrayTransferVirtual>; \ - template class VTKM_CONT_EXPORT ArrayTransferVirtual> - -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(char); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Int8); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::UInt8); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Int16); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::UInt16); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Int32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::UInt32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Int64); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::UInt64); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Float32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE(vtkm::Float64); - -#undef VTK_M_ARRAY_TRANSFER_VIRTUAL_INSTANTIATE - -#define VTK_M_STORAGE_VIRTUAL_INSTANTIATE(T) \ - template class VTKM_CONT_EXPORT StorageVirtualImpl; \ - template class VTKM_CONT_EXPORT StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG>; \ - template class VTKM_CONT_EXPORT StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG>; \ - template class VTKM_CONT_EXPORT StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG> - -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(char); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Int8); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::UInt8); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Int16); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::UInt16); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Int32); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::UInt32); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Int64); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::UInt64); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Float32); -VTK_M_STORAGE_VIRTUAL_INSTANTIATE(vtkm::Float64); - -#undef VTK_M_STORAGE_VIRTUAL_INSTANTIATE -} -} -} -} // namespace vtkm::cont::internal::detail diff --git a/vtkm/cont/StorageVirtual.h b/vtkm/cont/StorageVirtual.h deleted file mode 100644 index a2a609244..000000000 --- a/vtkm/cont/StorageVirtual.h +++ /dev/null @@ -1,302 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_StorageVirtual_h -#define vtk_m_cont_StorageVirtual_h - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "ArrayHandleVirtual is removed. Do not include StorageVirtual.h" -#endif - -namespace vtkm -{ -namespace cont -{ - -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6) StorageTagVirtual -{ -}; - -namespace internal -{ - -namespace detail -{ - -class VTKM_CONT_EXPORT StorageVirtual -{ -public: - /// \brief construct storage that VTK-m is responsible for - StorageVirtual() = default; - StorageVirtual(const StorageVirtual& src); - StorageVirtual(StorageVirtual&& src) noexcept; - StorageVirtual& operator=(const StorageVirtual& src); - StorageVirtual& operator=(StorageVirtual&& src) noexcept; - - virtual ~StorageVirtual(); - - /// Releases any resources being used in the execution environment (that are - /// not being shared by the control environment). - /// - /// Only needs to overridden by subclasses such as Zip that have member - /// variables that themselves have execution memory - virtual void ReleaseResourcesExecution() = 0; - - /// Releases all resources in both the control and execution environments. - /// - /// Only needs to overridden by subclasses such as Zip that have member - /// variables that themselves have execution memory - virtual void ReleaseResources() = 0; - - /// Returns the number of entries in the array. - /// - virtual vtkm::Id GetNumberOfValues() const = 0; - - /// \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 - /// ErrorBadAllocation if the array cannot be allocated or - /// ErrorBadValue if the allocation is not feasible (for example, the - /// array storage is read-only). - /// - virtual void Allocate(vtkm::Id numberOfValues) = 0; - - /// \brief Reduces the size of the array without changing its values. - /// - /// This method allows you to resize the array without reallocating it. The - /// number of entries in the array is changed to \c numberOfValues. The data - /// in the array (from indices 0 to \c numberOfValues - 1) are the same, but - /// \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. - virtual void Shrink(vtkm::Id numberOfValues) = 0; - - /// Determines if storage types matches the type passed in. - /// - template - bool IsType() const - { //needs optimizations based on platform. !OSX can use typeid - return nullptr != dynamic_cast(this); - } - - /// \brief Create a new storage of the same type as this storage. - /// - /// This method creates a new storage that is the same type as this one and - /// returns a unique_ptr for it. This method is convenient when - /// creating output arrays that should be the same type as some input array. - /// - std::unique_ptr NewInstance() const; - - template - const DerivedStorage* Cast() const - { - const DerivedStorage* derived = dynamic_cast(this); - if (!derived) - { - VTKM_LOG_CAST_FAIL(*this, DerivedStorage); - throwFailedDynamicCast("StorageVirtual", vtkm::cont::TypeToString()); - } - VTKM_LOG_CAST_SUCC(*this, derived); - return derived; - } - - const vtkm::internal::PortalVirtualBase* PrepareForInput(vtkm::cont::DeviceAdapterId devId) const; - - const vtkm::internal::PortalVirtualBase* PrepareForOutput(vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId devId); - - const vtkm::internal::PortalVirtualBase* PrepareForInPlace(vtkm::cont::DeviceAdapterId devId); - - //This needs to cause a host side sync! - //This needs to work before we execute on a device - const vtkm::internal::PortalVirtualBase* WritePortal(); - - //This needs to cause a host side sync! - //This needs to work before we execute on a device - const vtkm::internal::PortalVirtualBase* ReadPortal() const; - - /// Returns the DeviceAdapterId for the current device. If there is no device - /// with an up-to-date copy of the data, VTKM_DEVICE_ADAPTER_UNDEFINED is - /// returned. - DeviceAdapterId GetDeviceAdapterId() const noexcept; - - - enum struct OutputMode - { - WRITE, - READ_WRITE - }; - -protected: - /// Drop the reference to the execution portal. The underlying array handle might still be - /// managing data on the execution side, but our references might be out of date, so drop - /// them and refresh them later if necessary. - void DropExecutionPortal(); - - /// Drop the reference to all portals. The underlying array handle might still be managing data, - /// but our references might be out of date, so drop them and refresh them later if necessary. - void DropAllPortals(); - -private: - //Memory management routines - // virtual void DoAllocate(vtkm::Id numberOfValues) = 0; - // virtual void DoShrink(vtkm::Id numberOfValues) = 0; - - //RTTI routines - virtual std::unique_ptr MakeNewInstance() const = 0; - - //Portal routines - virtual void ControlPortalForInput(vtkm::cont::internal::TransferInfoArray& payload) const = 0; - virtual void ControlPortalForOutput(vtkm::cont::internal::TransferInfoArray& payload); - - - virtual void TransferPortalForInput(vtkm::cont::internal::TransferInfoArray& payload, - vtkm::cont::DeviceAdapterId devId) const = 0; - virtual void TransferPortalForOutput(vtkm::cont::internal::TransferInfoArray& payload, - OutputMode mode, - vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId devId); - - //This might need to exist in TransferInfoArray - mutable bool DeviceUpToDate = false; - std::shared_ptr DeviceTransferState = - std::make_shared(); -}; - -template -class VTKM_ALWAYS_EXPORT StorageVirtualImpl final - : public vtkm::cont::internal::detail::StorageVirtual -{ -public: - VTKM_CONT - explicit StorageVirtualImpl(const vtkm::cont::ArrayHandle& ah); - - explicit StorageVirtualImpl(vtkm::cont::ArrayHandle&& ah) noexcept; - - VTKM_CONT - ~StorageVirtualImpl() override = default; - - const vtkm::cont::ArrayHandle& GetHandle() const { return this->Handle; } - - vtkm::Id GetNumberOfValues() const override { return this->Handle.GetNumberOfValues(); } - - void ReleaseResourcesExecution() override; - void ReleaseResources() override; - - void Allocate(vtkm::Id numberOfValues) override; - void Shrink(vtkm::Id numberOfValues) override; - -private: - std::unique_ptr MakeNewInstance() const override - { - return std::unique_ptr( - new StorageVirtualImpl{ vtkm::cont::ArrayHandle{} }); - } - - - void ControlPortalForInput(vtkm::cont::internal::TransferInfoArray& payload) const override; - void ControlPortalForOutput(vtkm::cont::internal::TransferInfoArray& payload) override; - - void TransferPortalForInput(vtkm::cont::internal::TransferInfoArray& payload, - vtkm::cont::DeviceAdapterId devId) const override; - - void TransferPortalForOutput(vtkm::cont::internal::TransferInfoArray& payload, - OutputMode mode, - vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId devId) override; - - vtkm::cont::ArrayHandle Handle; -}; - -} // namespace detail - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -class VTKM_ALWAYS_EXPORT Storage -{ -public: - using ValueType = T; - - using PortalType = vtkm::ArrayPortalRef; - using PortalConstType = vtkm::ArrayPortalRef; - - Storage() = default; - - // Should never really be used, but just in case. - Storage(const Storage&) = default; - - template - Storage(const vtkm::cont::ArrayHandle& srcArray) - : VirtualStorage(std::make_shared>(srcArray)) - { - } - - ~Storage() = default; - - PortalType GetPortal() - { - return make_ArrayPortalRef( - reinterpret_cast*>(this->VirtualStorage->WritePortal()), - this->GetNumberOfValues()); - } - - PortalConstType GetPortalConst() const - { - return make_ArrayPortalRef( - reinterpret_cast*>(this->VirtualStorage->ReadPortal()), - this->GetNumberOfValues()); - } - - vtkm::Id GetNumberOfValues() const { return this->VirtualStorage->GetNumberOfValues(); } - - void Allocate(vtkm::Id numberOfValues); - - void Shrink(vtkm::Id numberOfValues); - - void ReleaseResources(); - - Storage NewInstance() const; - - const detail::StorageVirtual* GetStorageVirtual() const { return this->VirtualStorage.get(); } - detail::StorageVirtual* GetStorageVirtual() { return this->VirtualStorage.get(); } - -private: - std::shared_ptr VirtualStorage; - - Storage(std::shared_ptr virtualStorage) - : VirtualStorage(virtualStorage) - { - } - - VTKM_STORAGE_OLD_STYLE; -}; -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace internal -} -} // namespace vtkm::cont - -#ifndef vtk_m_cont_StorageVirtual_hxx -#include -#endif - -#endif diff --git a/vtkm/cont/StorageVirtual.hxx b/vtkm/cont/StorageVirtual.hxx deleted file mode 100644 index 9ac534818..000000000 --- a/vtkm/cont/StorageVirtual.hxx +++ /dev/null @@ -1,454 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_StorageVirtual_hxx -#define vtk_m_cont_StorageVirtual_hxx - -#include -#include -#include - -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ -namespace detail -{ -template -struct TransferToDevice -{ - template - inline bool operator()(DeviceAdapterTag devId, Payload&& payload, Args&&... args) const - { - using TransferType = cont::internal::VirtualObjectTransfer; - using shared_memory_transfer = - std::is_base_of, - TransferType>; - - return this->Transfer( - devId, shared_memory_transfer{}, std::forward(payload), std::forward(args)...); - } - - template - inline bool Transfer(DeviceAdapterTag devId, - std::true_type, - Payload&& payload, - Args&&... args) const - { //shared memory transfer so we just need - auto smp_ptr = new DerivedPortal(std::forward(args)...); - auto host = std::unique_ptr(smp_ptr); - payload.updateDevice(devId, std::move(host), smp_ptr, nullptr); - - return true; - } - - template - inline bool Transfer(DeviceAdapterTag devId, - std::false_type, - Payload&& payload, - Args&&... args) const - { //separate memory transfer - //construct all new transfer payload - using TransferType = cont::internal::VirtualObjectTransfer; - - auto host = std::unique_ptr(new DerivedPortal(std::forward(args)...)); - auto transfer = std::make_shared(host.get()); - auto device = transfer->PrepareForExecution(true); - - payload.updateDevice(devId, std::move(host), device, std::static_pointer_cast(transfer)); - - return true; - } -}; -} // namespace detail - -template -inline void make_transferToDevice(vtkm::cont::DeviceAdapterId devId, Args&&... args) -{ - vtkm::cont::TryExecuteOnDevice( - devId, detail::TransferToDevice{}, std::forward(args)...); -} - -template -inline void make_hostPortal(Payload&& payload, Args&&... args) -{ - auto host = std::unique_ptr(new DerivedPortal(std::forward(args)...)); - payload.updateHost(std::move(host)); -} - -namespace internal -{ -namespace detail -{ - -VTKM_CONT -template -StorageVirtualImpl::StorageVirtualImpl(const vtkm::cont::ArrayHandle& ah) - : vtkm::cont::internal::detail::StorageVirtual() - , Handle(ah) -{ -} - -VTKM_CONT -template -StorageVirtualImpl::StorageVirtualImpl(vtkm::cont::ArrayHandle&& ah) noexcept - : vtkm::cont::internal::detail::StorageVirtual() - , Handle(std::move(ah)) -{ -} - -/// release execution side resources -template -void StorageVirtualImpl::ReleaseResourcesExecution() -{ - this->DropExecutionPortal(); - this->Handle.ReleaseResourcesExecution(); -} - -/// release control side resources -template -void StorageVirtualImpl::ReleaseResources() -{ - this->DropAllPortals(); - this->Handle.ReleaseResources(); -} - -template -void StorageVirtualImpl::Allocate(vtkm::Id numberOfValues) -{ - this->DropAllPortals(); - this->Handle.Allocate(numberOfValues); -} - -template -void StorageVirtualImpl::Shrink(vtkm::Id numberOfValues) -{ - this->DropAllPortals(); - this->Handle.Allocate(numberOfValues, vtkm::CopyFlag::On); -} - -struct PortalWrapperToDevice -{ - template - inline bool operator()(DeviceAdapterTag device, - Handle&& handle, - vtkm::cont::internal::TransferInfoArray& payload) const - { - vtkm::cont::Token token; - auto portal = handle.PrepareForInput(device, token); - using DerivedPortal = vtkm::ArrayPortalWrapper; - vtkm::cont::detail::TransferToDevice transfer; - return transfer(device, payload, portal); - } - template - inline bool operator()(DeviceAdapterTag device, - Handle&& handle, - vtkm::Id numberOfValues, - vtkm::cont::internal::TransferInfoArray& payload, - vtkm::cont::internal::detail::StorageVirtual::OutputMode mode) const - { - using ACCESS_MODE = vtkm::cont::internal::detail::StorageVirtual::OutputMode; - if (mode == ACCESS_MODE::WRITE) - { - vtkm::cont::Token token; - auto portal = handle.PrepareForOutput(numberOfValues, device, token); - using DerivedPortal = vtkm::ArrayPortalWrapper; - vtkm::cont::detail::TransferToDevice transfer; - return transfer(device, payload, portal); - } - else - { - vtkm::cont::Token token; - auto portal = handle.PrepareForInPlace(device, token); - using DerivedPortal = vtkm::ArrayPortalWrapper; - vtkm::cont::detail::TransferToDevice transfer; - return transfer(device, payload, portal); - } - } -}; - -template -void StorageVirtualImpl::ControlPortalForInput( - vtkm::cont::internal::TransferInfoArray& payload) const -{ - auto portal = this->Handle.ReadPortal(); - using DerivedPortal = vtkm::ArrayPortalWrapper; - vtkm::cont::make_hostPortal(payload, portal); -} - -template -inline void make_writableHostPortal(std::true_type, - vtkm::cont::internal::TransferInfoArray& payload, - HandleType& handle) -{ - auto portal = handle.WritePortal(); - using DerivedPortal = vtkm::ArrayPortalWrapper; - vtkm::cont::make_hostPortal(payload, portal); -} -template -inline void make_writableHostPortal(std::false_type, - vtkm::cont::internal::TransferInfoArray& payload, - HandleType&) -{ - payload.updateHost(nullptr); - throw vtkm::cont::ErrorBadValue( - "ArrayHandleAny was bound to an ArrayHandle that doesn't support output."); -} - -template -void StorageVirtualImpl::ControlPortalForOutput( - vtkm::cont::internal::TransferInfoArray& payload) -{ - using HT = vtkm::cont::ArrayHandle; - constexpr auto isWritable = typename vtkm::cont::internal::IsWritableArrayHandle::type{}; - - detail::make_writableHostPortal(isWritable, payload, this->Handle); -} - -template -void StorageVirtualImpl::TransferPortalForInput( - vtkm::cont::internal::TransferInfoArray& payload, - vtkm::cont::DeviceAdapterId devId) const -{ - vtkm::cont::TryExecuteOnDevice(devId, detail::PortalWrapperToDevice(), this->Handle, payload); -} - - -template -void StorageVirtualImpl::TransferPortalForOutput( - vtkm::cont::internal::TransferInfoArray& payload, - vtkm::cont::internal::detail::StorageVirtual::OutputMode mode, - vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId devId) -{ - vtkm::cont::TryExecuteOnDevice( - devId, detail::PortalWrapperToDevice(), this->Handle, numberOfValues, payload, mode); -} -} // namespace detail - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -void Storage::Allocate(vtkm::Id numberOfValues) -{ - if (this->VirtualStorage) - { - this->VirtualStorage->Allocate(numberOfValues); - } - else if (numberOfValues != 0) - { - throw vtkm::cont::ErrorBadAllocation("Attempted to allocate memory in a virtual array that " - "does not have an underlying concrete array."); - } - else - { - // Allocating a non-existing array to 0 is OK. - } -} - -template -void Storage::Shrink(vtkm::Id numberOfValues) -{ - if (this->VirtualStorage) - { - this->VirtualStorage->Shrink(numberOfValues); - } - else if (numberOfValues != 0) - { - throw vtkm::cont::ErrorBadAllocation( - "Attempted to shrink a virtual array that does not have an underlying concrete array."); - } - else - { - // Shrinking a non-existing array to 0 is OK. - } -} - -template -void Storage::ReleaseResources() -{ - if (this->VirtualStorage) - { - this->VirtualStorage->ReleaseResources(); - } - else - { - // No concrete array, nothing allocated, nothing to do. - } -} - -template -Storage Storage::NewInstance() - const -{ - if (this->GetStorageVirtual()) - { - return Storage(this->GetStorageVirtual()->NewInstance()); - } - else - { - return Storage(); - } -} - -namespace detail -{ - -template -class VTKM_ALWAYS_EXPORT ArrayTransferVirtual -{ - using StorageType = vtkm::cont::internal::Storage; - vtkm::cont::internal::detail::StorageVirtual* Storage; - -public: - using ValueType = T; - - using PortalControl = typename StorageType::PortalType; - using PortalConstControl = typename StorageType::PortalConstType; - - using PortalExecution = vtkm::ArrayPortalRef; - using PortalConstExecution = vtkm::ArrayPortalRef; - - VTKM_CONT ArrayTransferVirtual(StorageType* storage) - : Storage(storage->GetStorageVirtual()) - { - } - - VTKM_CONT vtkm::Id GetNumberOfValues() const { return this->Storage->GetNumberOfValues(); } - - VTKM_CONT PortalConstExecution PrepareForInput(vtkm::cont::DeviceAdapterId device) - { - return vtkm::make_ArrayPortalRef(static_cast*>( - this->Storage->PrepareForInput(device)), - this->GetNumberOfValues()); - } - - VTKM_CONT PortalExecution PrepareForOutput(vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId device) - { - return make_ArrayPortalRef(static_cast*>( - this->Storage->PrepareForOutput(numberOfValues, device)), - numberOfValues); - } - - VTKM_CONT PortalExecution PrepareForInPlace(vtkm::cont::DeviceAdapterId device) - { - return vtkm::make_ArrayPortalRef(static_cast*>( - this->Storage->PrepareForInPlace(device)), - this->GetNumberOfValues()); - } - - VTKM_CONT - void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const - { - // Implementation of this method should be unnecessary. The internal array handles should - // automatically retrieve the output data as necessary. - } - - VTKM_CONT void Shrink(vtkm::Id numberOfValues) { this->Storage->Shrink(numberOfValues); } - - VTKM_CONT void ReleaseResources() { this->Storage->ReleaseResourcesExecution(); } -}; - -#ifndef vtk_m_cont_StorageVirtual_cxx - -#define VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(T) \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayTransferVirtual; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayTransferVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayTransferVirtual>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayTransferVirtual> - -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(char); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Int8); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::UInt8); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Int16); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::UInt16); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Int32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::UInt32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Int64); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::UInt64); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Float32); -VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT(vtkm::Float64); - -#undef VTK_M_ARRAY_TRANSFER_VIRTUAL_EXPORT - -#define VTK_M_STORAGE_VIRTUAL_EXPORT(T) \ - extern template class VTKM_CONT_TEMPLATE_EXPORT StorageVirtualImpl; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT \ - StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT \ - StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG>; \ - extern template class VTKM_CONT_TEMPLATE_EXPORT \ - StorageVirtualImpl, VTKM_DEFAULT_STORAGE_TAG> - -VTK_M_STORAGE_VIRTUAL_EXPORT(char); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Int8); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::UInt8); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Int16); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::UInt16); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Int32); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::UInt32); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Int64); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::UInt64); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Float32); -VTK_M_STORAGE_VIRTUAL_EXPORT(vtkm::Float64); - -#undef VTK_M_STORAGE_VIRTUAL_EXPORT - -#endif //!vtk_m_cont_StorageVirtual_cxx -} // namespace detail - -template -struct ArrayTransfer : detail::ArrayTransferVirtual -{ - using Superclass = detail::ArrayTransferVirtual; - - VTKM_CONT ArrayTransfer(vtkm::cont::internal::Storage* storage) - : Superclass(storage) - { - } - - VTKM_CONT typename Superclass::PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData), - vtkm::cont::Token&) - { - return this->Superclass::PrepareForInput(Device()); - } - - VTKM_CONT typename Superclass::PortalExecution PrepareForOutput(vtkm::Id numberOfValues, - vtkm::cont::Token&) - { - return this->Superclass::PrepareForOutput(numberOfValues, Device()); - } - - VTKM_CONT typename Superclass::PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData), - vtkm::cont::Token&) - { - return this->Superclass::PrepareForInPlace(Device()); - } -}; -VTKM_DEPRECATED_SUPPRESS_END -} -} -} // namespace vtkm::cont::internal - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtk_m_cont_StorageVirtual_hxx diff --git a/vtkm/cont/UncertainCellSet.h b/vtkm/cont/UncertainCellSet.h index 3709e52fc..329e94863 100644 --- a/vtkm/cont/UncertainCellSet.h +++ b/vtkm/cont/UncertainCellSet.h @@ -201,142 +201,4 @@ public: /// @endcond SERIALIZATION -// Implement the deprecated functionality of DynamicCellSetBase, which was replaced -// by UnknownCellSet/UncertainCellSet. Everything below this line (up to the #endif -// for the include guard) can be deleted once the deprecated functionality is removed. - -namespace vtkm -{ -namespace cont -{ - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -template -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.8, - "Use vtkm::cont::UncertainCellSet.") DynamicCellSetBase - : public vtkm::cont::UncertainCellSet -{ - using Superclass = vtkm::cont::UncertainCellSet; - -public: - using Superclass::Superclass; - - VTKM_CONT DynamicCellSetBase NewInstance() const - { - return DynamicCellSetBase(this->Superclass::NewInstance()); - } - - template - VTKM_CONT vtkm::cont::DynamicCellSetBase ResetCellSetList(NewCellSetList) const - { - return vtkm::cont::DynamicCellSetBase(*this); - } - template - VTKM_CONT vtkm::cont::DynamicCellSetBase ResetCellSetList() const - { - return vtkm::cont::DynamicCellSetBase(*this); - } -}; - -inline DynamicCellSet::operator vtkm::cont::DynamicCellSetBase() const -{ - return vtkm::cont::DynamicCellSetBase{ *this }; -} - -namespace internal -{ - -template -struct DynamicTransformTraits> -{ - using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; -}; - -} // namespace internal - -} -} // namespace vtkm::cont - -//============================================================================= -// Specializations of serialization related classes -/// @cond SERIALIZATION -namespace mangled_diy_namespace -{ - -namespace internal -{ - -struct DynamicCellSetSerializeFunctor -{ - template - void operator()(const CellSetType& cs, BinaryBuffer& bb) const - { - vtkmdiy::save(bb, vtkm::cont::SerializableTypeString::Get()); - vtkmdiy::save(bb, cs); - } -}; - -template -struct DynamicCellSetDeserializeFunctor -{ - template - void operator()(CellSetType, - vtkm::cont::DynamicCellSetBase& dh, - const std::string& typeString, - bool& success, - BinaryBuffer& bb) const - { - if (!success && (typeString == vtkm::cont::SerializableTypeString::Get())) - { - CellSetType cs; - vtkmdiy::load(bb, cs); - dh = vtkm::cont::DynamicCellSetBase(cs); - success = true; - } - } -}; - -} // internal - -template -struct Serialization> -{ -private: - using Type = vtkm::cont::DynamicCellSetBase; - -public: - static VTKM_CONT void save(BinaryBuffer& bb, const Type& obj) - { - obj.CastAndCall(internal::DynamicCellSetSerializeFunctor{}, bb); - } - - static VTKM_CONT void load(BinaryBuffer& bb, Type& obj) - { - std::string typeString; - vtkmdiy::load(bb, typeString); - - bool success = false; - vtkm::ListForEach(internal::DynamicCellSetDeserializeFunctor{}, - CellSetTypes{}, - obj, - typeString, - success, - bb); - - if (!success) - { - throw vtkm::cont::ErrorBadType("Error deserializing DynamicCellSet. Message TypeString: " + - typeString); - } - } -}; - -} // diy -/// @endcond SERIALIZATION - -VTKM_DEPRECATED_SUPPRESS_END - #endif //vtk_m_cont_UncertainCellSet_h diff --git a/vtkm/cont/UnknownArrayHandle.h b/vtkm/cont/UnknownArrayHandle.h index 14197442f..3adf055e6 100644 --- a/vtkm/cont/UnknownArrayHandle.h +++ b/vtkm/cont/UnknownArrayHandle.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -550,15 +551,6 @@ public: NewValueTypeList = NewValueTypeList{}, NewStorageTypeList = NewStorageTypeList{}) const; - template - VTKM_DEPRECATED(1.6, "Specify both value types and storage types.") - VTKM_CONT - vtkm::cont::UncertainArrayHandle ResetTypes( - NewValueTypeList = NewValueTypeList{}) const - { - return this->ResetTypes(); - } - /// \brief Returns the number of values in the array. /// VTKM_CONT vtkm::Id GetNumberOfValues() const; @@ -659,32 +651,6 @@ public: VTKM_DEPRECATED_SUPPRESS_END #endif - // For code still expecting a VariantArrayHandle - template - VTKM_DEPRECATED(1.6, "Use AsArrayHandle.") - VTKM_CONT ArrayHandleType Cast() const - { - return this->AsArrayHandle(); - } - template - VTKM_DEPRECATED(1.6, "Use AsArrayHandle.") - VTKM_CONT void CopyTo(ArrayHandleType& array) const - { - this->AsArrayHandle(array); - } - template - VTKM_DEPRECATED(1.6, "Use AsArrayHandle.") - VTKM_CONT MultiplexerType AsMultiplexer() const - { - return this->AsArrayHandle(); - } - template - VTKM_DEPRECATED(1.6, "Use AsArrayHandle.") - VTKM_CONT void AsMultiplexer(MultiplexerType& result) const - { - result = this->AsArrayHandle(); - } - /// \brief Deep copies data from another `UnknownArrayHandle`. /// /// This method takes an `UnknownArrayHandle` and deep copies data from it. @@ -884,16 +850,6 @@ public: template VTKM_CONT void CastAndCallWithExtractedArray(Functor&& functor, Args&&... args) const; - template - VTKM_CONT VTKM_DEPRECATED(1.6, "Use CastAndCallForTypes.") void CastAndCall( - FunctorOrStorageList&& functorOrStorageList, - Args&&... args) const - { - this->CastAndCallImpl(vtkm::internal::IsList{}, - std::forward(functorOrStorageList), - std::forward(args)...); - } - /// Releases any resources being used in the execution environment (that are /// not being shared by the control environment). /// @@ -904,20 +860,6 @@ public: VTKM_CONT void ReleaseResources() const; VTKM_CONT void PrintSummary(std::ostream& out, bool full = false) const; - -private: - // Remove this when deprecated CastAndCall is removed. - template - VTKM_CONT void CastAndCallImpl(std::false_type, Args&&... args) const - { - this->CastAndCallForTypes( - std::forward(args)...); - } - template - VTKM_CONT void CastAndCallImpl(std::true_type, StorageList, Args&&... args) const - { - this->CastAndCallForTypes(std::forward(args)...); - } }; //============================================================================= diff --git a/vtkm/cont/UnknownCellSet.h b/vtkm/cont/UnknownCellSet.h index 1a15e7749..b3f486dd6 100644 --- a/vtkm/cont/UnknownCellSet.h +++ b/vtkm/cont/UnknownCellSet.h @@ -14,8 +14,6 @@ #include #include -#include - #include #include @@ -223,47 +221,6 @@ public: /// template VTKM_CONT void CastAndCallForTypes(Functor&& functor, Args&&... args) const; - - // Support for deprecated DynamicCellSet features - - template - VTKM_DEPRECATED(1.8, "Use CanConvert() (or IsType).") - VTKM_CONT bool IsSameType(const CellSetType&) const - { - return this->IsType(); - } - - template - VTKM_DEPRECATED(1.8, "Use AsCellSet().") - VTKM_CONT CellSetType& Cast() const - { - VTKM_IS_CELL_SET(CellSetType); - CellSetType* cellSetPointer = dynamic_cast(this->Container.get()); - if (cellSetPointer == nullptr) - { - VTKM_LOG_CAST_FAIL(*this, CellSetType); - throwFailedDynamicCast(this->GetCellSetName(), vtkm::cont::TypeToString()); - } - VTKM_LOG_CAST_SUCC(*this, *cellSetPointer); - return *cellSetPointer; - } - - template - VTKM_DEPRECATED(1.8, "Use AsCellSet(cellSet).") - VTKM_CONT void CopyTo(CellSetType& cellSet) const - { - return this->AsCellSet(cellSet); - } - - template - VTKM_DEPRECATED(1.8, - "Use the vtkm::cont::CastAndCall free function4 or use CastAndCallForTypes or " - "use ResetCellList and then CastAndCall.") - VTKM_CONT void CastAndCall(Functor&& f, Args&&... args) const - { - this->CastAndCallForTypes(std::forward(f), - std::forward(args)...); - } }; //============================================================================= @@ -285,7 +242,7 @@ VTKM_CONT inline bool IsType(const vtkm::cont::UnknownCellSet& unknownCellSet) template VTKM_CONT inline CellSetType Cast(const vtkm::cont::UnknownCellSet& unknownCellSet) { - return unknownCellSet.Cast(); + return unknownCellSet.AsCellSet(); } namespace internal @@ -394,121 +351,6 @@ public: /// @endcond SERIALIZATION -// Implement the deprecated functionality of DynamicCellSet, which was replaced -// by UnknownCellSet/UncertainCellSet. Everything below this line (up to the #endif -// for the include guard) can be deleted once the deprecated functionality is removed. - -// Headers originally included from DynamicCellSet.h but not UnknownCellSet.h -#include -#include -#include - -namespace vtkm -{ -namespace cont -{ - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -// Forward declaration -template -class DynamicCellSetBase; - -/// \brief Holds a cell set without having to specify concrete type. -/// -/// \c DynamicCellSet holds a \c CellSet object using runtime polymorphism to -/// manage different subclass types and template parameters of the subclasses -/// rather than compile-time templates. This adds a programming convenience -/// that helps avoid a proliferation of templates. It also provides the -/// management necessary to interface VTK-m with data sources where types will -/// not be known until runtime. -/// -/// To interface between the runtime polymorphism and the templated algorithms -/// in VTK-m, \c DynamicCellSet contains a method named \c CastAndCall that -/// will determine the correct type from some known list of cell set types. -/// This mechanism is used internally by VTK-m's worklet invocation mechanism -/// to determine the type when running algorithms. -/// -/// By default, \c DynamicCellSet will assume that the value type in the array -/// matches one of the types specified by \c VTKM_DEFAULT_CELL_SET_LIST. -/// This list can be changed by using the \c ResetCellSetList method. It is -/// worthwhile to match these lists closely to the possible types that might be -/// used. If a type is missing you will get a runtime error. If there are more -/// types than necessary, then the template mechanism will create a lot of -/// object code that is never used, and keep in mind that the number of -/// combinations grows exponentially when using multiple \c Dynamic* objects. -/// -/// The actual implementation of \c DynamicCellSet is in a templated class -/// named \c DynamicCellSetBase, which is templated on the list of cell set -/// types. \c DynamicCellSet is really just a typedef of \c DynamicCellSetBase -/// with the default cell set list. -/// -struct VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.8, "Use vtkm::cont::UnknownCellSet.") DynamicCellSet - : public vtkm::cont::UnknownCellSet -{ - using UnknownCellSet::UnknownCellSet; - - DynamicCellSet() = default; - - DynamicCellSet(const vtkm::cont::UnknownCellSet& src) - : UnknownCellSet(src) - { - } - - operator vtkm::cont::DynamicCellSetBase() const; - - VTKM_CONT vtkm::cont::DynamicCellSet NewInstance() const - { - return vtkm::cont::DynamicCellSet(this->UnknownCellSet::NewInstance()); - } - - template - VTKM_CONT vtkm::cont::DynamicCellSetBase ResetCellSetList(NewCellSetList) const - { - return vtkm::cont::DynamicCellSetBase(*this); - } - template - VTKM_CONT vtkm::cont::DynamicCellSetBase ResetCellSetList() const - { - return vtkm::cont::DynamicCellSetBase(*this); - } -}; - -namespace internal -{ - -template <> -struct DynamicTransformTraits -{ - using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; -}; - -/// Checks to see if the given object is a dynamic cell set. It contains a -/// typedef named \c type that is either std::true_type or std::false_type. -/// Both of these have a typedef named value with the respective boolean value. -/// -template -struct DynamicCellSetCheck -{ - using type = vtkm::cont::internal::UnknownCellSetCheck; -}; - -#define VTKM_IS_DYNAMIC_CELL_SET(T) \ - VTKM_STATIC_ASSERT(::vtkm::cont::internal::DynamicCellSetCheck::type::value) - -#define VTKM_IS_DYNAMIC_OR_STATIC_CELL_SET(T) \ - VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck::type::value || \ - ::vtkm::cont::internal::DynamicCellSetCheck::type::value) - -} // namespace internal - -} -} // namespace vtkm::cont - -VTKM_DEPRECATED_SUPPRESS_END - // Include the implementation of UncertainCellSet. This should be included because there // are methods in UnknownCellSet that produce objects of this type. It has to be included // at the end to resolve the circular dependency. diff --git a/vtkm/cont/internal/Variant.h b/vtkm/cont/Variant.h similarity index 100% rename from vtkm/cont/internal/Variant.h rename to vtkm/cont/Variant.h diff --git a/vtkm/cont/VariantArrayHandle.h b/vtkm/cont/VariantArrayHandle.h deleted file mode 100644 index 6a583c26a..000000000 --- a/vtkm/cont/VariantArrayHandle.h +++ /dev/null @@ -1,503 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_VariantArrayHandle_h -#define vtk_m_cont_VariantArrayHandle_h - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -namespace vtkm -{ -namespace cont -{ - -struct VTKM_DEPRECATED(1.8, "Use UnknownCellSet.h or UncertainCellSet.h.") - VariantArrayHandle_h_header_is_deprecated -{ - int x; -}; - -inline void EmitVariantArrayHandleHDeprecationWarning() -{ - static VariantArrayHandle_h_header_is_deprecated x; - ++x.x; -} - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -namespace internal -{ -namespace variant -{ - -struct ForceCastToVirtual -{ - template - VTKM_CONT typename std::enable_if::value>::type - operator()(const vtkm::cont::ArrayHandle& input, - vtkm::cont::ArrayHandleVirtual& output) const - { // ValueTypes match - output = vtkm::cont::make_ArrayHandleVirtual(input); - } - - template - VTKM_CONT typename std::enable_if::value>::type - operator()(const vtkm::cont::ArrayHandle& input, - vtkm::cont::ArrayHandleVirtual& output) const - { // ValueTypes do not match - this->ValidateWidthAndCast(input, output); - } - -private: - template ::NUM_COMPONENTS, - vtkm::IdComponent DSize = vtkm::VecTraits::NUM_COMPONENTS> - VTKM_CONT typename std::enable_if::type ValidateWidthAndCast( - const InputType& input, - vtkm::cont::ArrayHandleVirtual& output) const - { // number of components match - auto casted = vtkm::cont::make_ArrayHandleCast(input); - output = vtkm::cont::make_ArrayHandleVirtual(casted); - } - - template ::NUM_COMPONENTS, - vtkm::IdComponent DSize = vtkm::VecTraits::NUM_COMPONENTS> - VTKM_CONT typename std::enable_if::type ValidateWidthAndCast( - const ArrayHandleBase&, - ArrayHandleBase&) const - { // number of components do not match - std::ostringstream str; - str << "VariantArrayHandle::AsVirtual: Cannot cast from " << vtkm::cont::TypeToString() - << " to " << vtkm::cont::TypeToString() - << "; " - "number of components must match exactly."; - throw vtkm::cont::ErrorBadType(str.str()); - } -}; - -template -struct NoCastStorageTransformImpl -{ - using type = S; -}; -template -struct NoCastStorageTransformImpl> -{ - using type = S; -}; -template -using NoCastStorageTransform = typename NoCastStorageTransformImpl::type; - -} -} // namespace internal::variant -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -/// \brief VariantArrayHandle superclass holding common operations. -/// -/// `VariantArrayHandleCommon` is a superclass to all `VariantArrayHandleBase` -/// and `VariantArrayHandle` classes. It contains all operations that are -/// independent of the type lists defined for these templated class or has -/// versions of methods that allow you to specify type lists. -/// -/// See the documentation of `VariantArrayHandleBase` for more information. -/// -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.7, - "VariantArrayHandle classes replaced with UnknownArrayHandle and UncertainArrayHandle.") - VariantArrayHandleCommon : public vtkm::cont::UnknownArrayHandle -{ - using Superclass = vtkm::cont::UnknownArrayHandle; - -public: - using Superclass::Superclass; - - VTKM_CONT VariantArrayHandleCommon() = default; - - VTKM_CONT VariantArrayHandleCommon(const vtkm::cont::UnknownArrayHandle& array) - : Superclass(array) - { - } - - /// Returns this array cast to the given \c ArrayHandle type. Throws \c - /// ErrorBadType if the cast does not work. Use \c IsType - /// to check if the cast can happen. - /// - template - VTKM_CONT ArrayHandleType Cast() const - { - return this->AsArrayHandle(); - } - - /// \brief Call a functor using the underlying array type. - /// - /// `CastAndCall` attempts to cast the held array to a specific value type, - /// and then calls the given functor with the cast array. You must specify - /// the `TypeList` and `StorageList` as template arguments. (Note that this - /// calling differs from that of the `CastAndCall` methods of subclasses.) - /// - template - VTKM_CONT void CastAndCall(Functor&& functor, Args&&... args) const - { - this->CastAndCallForTypes(std::forward(functor), - std::forward(args)...); - } - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - /// Returns this array cast to a `ArrayHandleVirtual` of the given type. - /// This will perform type conversions as necessary, and will log warnings - /// if the conversion is lossy. - /// - /// This method internally uses `CastAndCall`. A custom storage tag list may - /// be specified in the second template parameter, which will be passed to - /// the CastAndCall. You can also specify a list of types to try as the optional - /// third template argument. - /// - template > - VTKM_CONT VTKM_DEPRECATED(1.6, "ArrayHandleVirtual is no longer supported.") - vtkm::cont::ArrayHandleVirtual AsVirtual() const - { - VTKM_IS_LIST(StorageList); - VTKM_IS_LIST(TypeList); - // Remove cast storage from storage list because we take care of casting elsewhere - using CleanStorageList = - vtkm::ListTransform; - vtkm::cont::internal::variant::ForceCastToVirtual caster; - vtkm::cont::ArrayHandleVirtual output; - this->CastAndCall(caster, output); - return output; - } -#endif //VTKM_NO_DEPRECATED_VIRTUAL - - /// Returns this array cast to a `ArrayHandleMultiplexer` of the given type. - /// This will attempt to cast the internal array to each supported type of - /// the multiplexer. If none are supported, an invalid ArrayHandleMultiplexer - /// is returned. - /// - /// As a special case, if one of the arrays in the `ArrayHandleMultiplexer`'s - /// type list is an `ArrayHandleCast`, then the multiplexer will look for type - /// type of array being cast rather than an actual cast array. - /// - ///@{ - template - VTKM_CONT void AsMultiplexer(vtkm::cont::ArrayHandleMultiplexer& result) const - { - this->AsArrayHandle(result); - } - - template - VTKM_CONT ArrayHandleMultiplexerType AsMultiplexer() const - { - ArrayHandleMultiplexerType result; - this->AsMultiplexer(result); - return result; - } - ///@} - - /// Given a references to an ArrayHandle object, casts this array to the - /// ArrayHandle's type and sets the given ArrayHandle to this array. Throws - /// `ErrorBadType` if the cast does not work. Use `IsType` to check - /// if the cast can happen. - /// - /// Note that this is a shallow copy. The data are not copied and a change - /// in the data in one array will be reflected in the other. - /// - template - VTKM_CONT void CopyTo(ArrayHandleType& array) const - { - VTKM_IS_ARRAY_HANDLE(ArrayHandleType); - array = this->Cast(); - } - - /// \brief Create a new array of the same type as this array. - /// - /// This method creates a new array that is the same type as this one and - /// returns a new variant array handle for it. This method is convenient when - /// creating output arrays that should be the same type as some input array. - /// - VTKM_CONT VariantArrayHandleCommon NewInstance() const - { - return VariantArrayHandleCommon(this->Superclass::NewInstance()); - } -}; - -/// \brief Holds an array handle without having to specify template parameters. -/// -/// `VariantArrayHandle` holds an `ArrayHandle` -/// object using runtime polymorphism to manage different value types and -/// storage rather than compile-time templates. This adds a programming -/// convenience that helps avoid a proliferation of templates. It also provides -/// the management necessary to interface VTK-m with data sources where types -/// will not be known until runtime. -/// -/// To interface between the runtime polymorphism and the templated algorithms -/// in VTK-m, `VariantArrayHandle` contains a method named `CastAndCall` that -/// will determine the correct type from some known list of types. -/// This mechanism is used internally by VTK-m's worklet invocation -/// mechanism to determine the type when running algorithms. -/// -/// By default, `VariantArrayHandle` will assume that the value type in the -/// array matches one of the types specified by `VTKM_DEFAULT_TYPE_LIST` -/// This list can be changed by using the `ResetTypes`. It is -/// worthwhile to match these lists closely to the possible types that might be -/// used. If a type is missing you will get a runtime error. If there are more -/// types than necessary, then the template mechanism will create a lot of -/// object code that is never used, and keep in mind that the number of -/// combinations grows exponentially when using multiple `VariantArrayHandle` -/// objects. -/// -/// The actual implementation of `VariantArrayHandle` is in a templated class -/// named `VariantArrayHandleBase`, which is templated on the list of -/// component types. -/// -template -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.7, - "VariantArrayHandle classes replaced with UnknownArrayHandle and UncertainArrayHandle.") - VariantArrayHandleBase : public VariantArrayHandleCommon -{ - VTKM_STATIC_ASSERT_MSG((!std::is_same::value), - "Cannot use vtkm::ListUniversal with VariantArrayHandle."); - - using Superclass = VariantArrayHandleCommon; - -public: - VTKM_CONT - VariantArrayHandleBase() = default; - - template - VTKM_CONT VariantArrayHandleBase(const vtkm::cont::ArrayHandle& array) - : Superclass(array) - { - } - - VTKM_CONT explicit VariantArrayHandleBase(const VariantArrayHandleCommon& src) - : Superclass(src) - { - } - - VTKM_CONT VariantArrayHandleBase(const vtkm::cont::UnknownArrayHandle& src) - : Superclass(src) - { - } - - VTKM_CONT VariantArrayHandleBase(const VariantArrayHandleBase&) = default; - VTKM_CONT VariantArrayHandleBase(VariantArrayHandleBase&&) noexcept = default; - - VTKM_CONT - ~VariantArrayHandleBase() {} - - VTKM_CONT - VariantArrayHandleBase& operator=(const VariantArrayHandleBase&) = default; - - VTKM_CONT - VariantArrayHandleBase& operator=(VariantArrayHandleBase&&) noexcept = - default; - - VTKM_CONT operator vtkm::cont::UncertainArrayHandle() const - { - return vtkm::cont::UncertainArrayHandle(*this); - } - - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - /// Returns this array cast to a \c ArrayHandleVirtual of the given type. - /// This will perform type conversions as necessary, and will log warnings - /// if the conversion is lossy. - /// - /// This method internally uses CastAndCall. A custom storage tag list may - /// be specified in the second template parameter, which will be passed to - /// the CastAndCall. - /// - template - VTKM_CONT VTKM_DEPRECATED(1.6, "ArrayHandleVirtual is no longer suported.") - vtkm::cont::ArrayHandleVirtual AsVirtual() const - { - return this->Superclass::AsVirtual(); - } -#endif //VTKM_NO_DEPRECATED_VIRTUAL - - /// Changes the types to try casting to when resolving this variant array, - /// which is specified with a list tag like those in TypeList.h. Since C++ - /// does not allow you to actually change the template arguments, this method - /// returns a new variant array object. This method is particularly useful to - /// narrow down (or expand) the types when using an array of particular - /// constraints. - /// - template - VTKM_CONT VariantArrayHandleBase ResetTypes(NewTypeList = NewTypeList()) const - { - VTKM_IS_LIST(NewTypeList); - return VariantArrayHandleBase(*this); - } - - ///@{ - /// \brief Call a functor using the underlying array type. - /// - /// `CastAndCall` attempts to cast the held array to a specific value type, - /// then call the given functor with the cast array. The types - /// tried in the cast are those in the lists defined by the TypeList. - /// By default `VariantArrayHandle` set this to `VTKM_DEFAULT_TYPE_LIST`. - /// - /// In addition to the value type, an `ArrayHandle` also requires a storage tag. - /// By default, `CastAndCall` attempts to cast the array using the storage tags - /// listed in `VTKM_DEFAULT_STORAGE_LIST`. You can optionally give a custom - /// list of storage tags as the second argument. - /// - /// As previous stated, if a storage tag list is provided, it is given in the - /// first argument. The functor to call with the cast array is given as the next - /// argument (or the first argument if a storage tag list is not provided). - /// The remaning arguments, if any, are passed to the functor. - /// - /// The functor will be called with the cast array as its first argument. Any - /// remaining arguments are passed from the arguments to `CastAndCall`. - /// - template - VTKM_CONT void CastAndCall(FunctorOrStorageList&& functorOrStorageList, Args&&... args) const - { - this->CastAndCallImpl(vtkm::internal::IsList(), - std::forward(functorOrStorageList), - std::forward(args)...); - } - - template - VTKM_CONT void CastAndCall(Functor&& f) const - { - this->CastAndCallImpl(std::false_type(), std::forward(f)); - } - ///@} - - /// \brief Create a new array of the same type as this array. - /// - /// This method creates a new array that is the same type as this one and - /// returns a new variant array handle for it. This method is convenient when - /// creating output arrays that should be the same type as some input array. - /// - VTKM_CONT VariantArrayHandleBase NewInstance() const - { - return VariantArrayHandleBase(this->Superclass::NewInstance()); - } - -private: - template - VTKM_CONT void CastAndCallImpl(std::false_type, Functor&& f, Args&&... args) const - { - this->Superclass::CastAndCall(std::forward(f), - std::forward(args)...); - } - - template - VTKM_CONT void CastAndCallImpl(std::true_type, StorageList, Functor&& f, Args&&... args) const - { - this->Superclass::CastAndCall(std::forward(f), - std::forward(args)...); - } -}; - -using VariantArrayHandle VTKM_DEPRECATED( - 1.7, - "VariantArrayHandle classes replaced with UnknownArrayHandle and UncertainArrayHandle.") = - vtkm::cont::VariantArrayHandleBase; - - -//============================================================================= -// Free function casting helpers - -/// Returns true if \c variant matches the type of ArrayHandleType. -/// -template -VTKM_CONT inline bool IsType(const vtkm::cont::VariantArrayHandleBase& variant) -{ - return variant.template IsType(); -} - -/// Returns \c variant cast to the given \c ArrayHandle type. Throws \c -/// ErrorBadType if the cast does not work. Use \c IsType -/// to check if the cast can happen. -/// -template -VTKM_CONT inline ArrayHandleType Cast(const vtkm::cont::VariantArrayHandleBase& variant) -{ - return variant.template Cast(); -} - -namespace internal -{ - -template -struct DynamicTransformTraits> -{ - using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; -}; - -} // namespace internal -} // namespace cont -} // namespace vtkm - -//============================================================================= -// Specializations of serialization related classes -/// @cond SERIALIZATION -namespace mangled_diy_namespace -{ - -template -struct Serialization> -{ -private: - using Type = vtkm::cont::VariantArrayHandleBase; - using ImplObject = vtkm::cont::UncertainArrayHandle; - -public: - static VTKM_CONT void save(BinaryBuffer& bb, const Type& obj) - { - vtkmdiy::save(bb, ImplObject(obj)); - } - - static VTKM_CONT void load(BinaryBuffer& bb, Type& obj) - { - ImplObject implObj; - vtkmdiy::load(bb, implObj); - obj = implObj; - } -}; - -} // diy -/// @endcond SERIALIZATION - -VTKM_DEPRECATED_SUPPRESS_END - - -#endif //vtk_m_virts_VariantArrayHandle_h diff --git a/vtkm/cont/VirtualObjectHandle.h b/vtkm/cont/VirtualObjectHandle.h deleted file mode 100644 index 55a724b8d..000000000 --- a/vtkm/cont/VirtualObjectHandle.h +++ /dev/null @@ -1,183 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_VirtualObjectHandle_h -#define vtk_m_cont_VirtualObjectHandle_h - -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include -#include - -namespace vtkm -{ -namespace cont -{ - -namespace internal -{ -struct CreateTransferInterface -{ - template - VTKM_CONT inline void operator()(DeviceAdapter device, - internal::TransferState* transfers, - const VirtualDerivedType* virtualObject) const - { - using TransferImpl = TransferInterfaceImpl; - auto i = static_cast(device.GetValue()); - transfers->DeviceTransferState[i].reset(new TransferImpl(virtualObject)); - } -}; -} - -/// \brief Implements VTK-m's execution side Virtual Methods functionality. -/// -/// The template parameter \c VirtualBaseType is the base class that acts as the -/// interface. This base clase must inherit from \c vtkm::VirtualObjectBase. See the -/// documentation of that class to see the other requirements. -/// -/// A derived object can be bound to the handle either during construction or using the \c Reset -/// function on previously constructed handles. These function accept a control side pointer to -/// the derived class object, a boolean flag stating if the handle should acquire ownership of -/// the object (i.e. manage the lifetime), and a type-list of device adapter tags where the object -/// is expected to be used. -/// -/// To get an execution side pointer call the \c PrepareForExecution function. The device adapter -/// passed to this function should be one of the device in the list passed during the set up of -/// the handle. -/// -/// -/// \sa vtkm::VirtualObjectBase -/// -template -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED( - 1.7, - "Virtual methods are no longer supported in the execution environment.") VirtualObjectHandle - : public vtkm::cont::ExecutionAndControlObjectBase -{ - VTKM_STATIC_ASSERT_MSG((std::is_base_of::value), - "All virtual objects must be subclass of vtkm::VirtualObjectBase."); - -public: - VTKM_CONT VirtualObjectHandle() - : Internals(std::make_shared()) - { - } - - template - VTKM_CONT explicit VirtualObjectHandle(VirtualDerivedType* derived, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - : Internals(std::make_shared()) - { - this->Reset(derived, acquireOwnership, devices); - } - - /// Get if in a valid state (a target is bound) - VTKM_CONT bool GetValid() const { return this->Internals->HostPtr() != nullptr; } - - - /// Get if this handle owns the control side target object - VTKM_CONT bool OwnsObject() const { return this->Internals->WillReleaseHostPointer(); } - - /// Get the control side pointer to the virtual object - VTKM_CONT VirtualBaseType* Get() const - { - return static_cast(this->Internals->HostPtr()); - } - - /// Reset the underlying derived type object - template - VTKM_CONT void Reset(VirtualDerivedType* derived, - bool acquireOwnership = true, - DeviceAdapterList devices = DeviceAdapterList()) - { - VTKM_DEPRECATED_SUPPRESS_BEGIN - VTKM_STATIC_ASSERT_MSG((std::is_base_of::value), - "Tried to bind a type that is not a subclass of the base class."); - - if (acquireOwnership) - { - auto deleter = [](void* p) { delete static_cast(p); }; - this->Internals->UpdateHost(derived, deleter); - } - else - { - this->Internals->UpdateHost(derived, nullptr); - } - - if (derived) - { - vtkm::cont::internal::ForEachValidDevice( - devices, internal::CreateTransferInterface(), this->Internals.get(), derived); - } - VTKM_DEPRECATED_SUPPRESS_END - } - - /// Release all host and execution side resources - VTKM_CONT void ReleaseResources() { this->Internals->ReleaseResources(); } - - /// Release all the execution side resources - VTKM_CONT void ReleaseExecutionResources() { this->Internals->ReleaseExecutionResources(); } - - /// Get a valid \c VirtualBaseType* with the current control side state for \c deviceId. - /// VirtualObjectHandle and the returned pointer are analogous to ArrayHandle and Portal - /// The returned pointer will be invalidated if: - /// 1. A new pointer is requested for a different deviceId - /// 2. VirtualObjectHandle is destroyed - /// 3. Reset or ReleaseResources is called - /// - VTKM_CONT const VirtualBaseType* PrepareForExecution(vtkm::cont::DeviceAdapterId deviceId, - vtkm::cont::Token&) const - { - const bool validId = this->Internals->DeviceIdIsValid(deviceId); - if (!validId) - { //can't be reached since DeviceIdIsValid will through an exception - //if deviceId is not valid - return nullptr; - } - - return static_cast(this->Internals->PrepareForExecution(deviceId)); - } - - VTKM_CONT - VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object.") - const VirtualBaseType* PrepareForExecution(vtkm::cont::DeviceAdapterId deviceId) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(deviceId, token); - } - - /// Used as part of the \c ExecutionAndControlObjectBase interface. Returns the same pointer - /// as \c Get. - VTKM_CONT const VirtualBaseType* PrepareForControl() const { return this->Get(); } - -private: - std::shared_ptr Internals; -}; -} -} // vtkm::cont - -VTKM_DEPRECATED_SUPPRESS_END - - -#endif // vtk_m_cont_VirtualObjectHandle_h diff --git a/vtkm/cont/VirtualObjectHandle.hxx b/vtkm/cont/VirtualObjectHandle.hxx deleted file mode 100644 index a51999872..000000000 --- a/vtkm/cont/VirtualObjectHandle.hxx +++ /dev/null @@ -1,104 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_VirtualObjectHandle_hxx -#define vtk_m_cont_VirtualObjectHandle_hxx - -#include - -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace cont -{ - -template -VirtualObjectHandle::VirtualObjectHandle() - : Internals(std::make_shared()) -{ -} - -template -template -VirtualObjectHandle::VirtualObjectHandle(VirtualDerivedType* derived, - bool acquireOwnership, - DeviceAdapterList devices) - : Internals(std::make_shared()) -{ - this->Reset(derived, acquireOwnership, devices); -} - -template -bool VirtualObjectHandle::GetValid() const -{ - return this->Internals->HostPtr() != nullptr; -} - -template -bool VirtualObjectHandle::OwnsObject() const -{ - return this->Internals->WillReleaseHostPointer(); -} - -template -VirtualBaseType* VirtualObjectHandle::Get() -{ - return static_cast(this->Internals->HostPtr()); -} - -/// Reset the underlying derived type object -template -template -void VirtualObjectHandle::Reset(VirtualDerivedType* derived, - bool acquireOwnership, - DeviceAdapterList devices) -{ - VTKM_STATIC_ASSERT_MSG((std::is_base_of::value), - "Tried to bind a type that is not a subclass of the base class."); - - if (acquireOwnership) - { - // auto deleter = [](void* p) { delete static_cast(p); }; - this->Internals->UpdateHost(derived, nullptr); - } - else - { - this->Internals->UpdateHost(derived, nullptr); - } - - if (derived) - { - vtkm::cont::internal::ForEachValidDevice( - devices, internal::CreateTransferInterface(), this->Internals.get(), derived); - } -} - -template -const VirtualBaseType* VirtualObjectHandle::PrepareForExecution( - vtkm::cont::DeviceAdapterId deviceId) const -{ - const bool validId = this->Internals->DeviceIdIsValid(deviceId); - if (!validId) - { //can't be reached since DeviceIdIsValid will through an exception - //if deviceId is not valid - return nullptr; - } - - return static_cast(this->Internals->PrepareForExecution(deviceId)); -} -} -} // vtkm::cont - -#endif // vtk_m_cont_VirtualObjectHandle_h diff --git a/vtkm/cont/arg/CMakeLists.txt b/vtkm/cont/arg/CMakeLists.txt index e67d916bd..0e98daa12 100644 --- a/vtkm/cont/arg/CMakeLists.txt +++ b/vtkm/cont/arg/CMakeLists.txt @@ -39,9 +39,3 @@ set(headers ) vtkm_declare_headers(${headers}) - - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/cont/arg/TransportTagArrayIn.h b/vtkm/cont/arg/TransportTagArrayIn.h index f3d6e3c40..bebeb9e02 100644 --- a/vtkm/cont/arg/TransportTagArrayIn.h +++ b/vtkm/cont/arg/TransportTagArrayIn.h @@ -10,6 +10,7 @@ #ifndef vtk_m_cont_arg_TransportTagArrayIn_h #define vtk_m_cont_arg_TransportTagArrayIn_h +#include #include #include diff --git a/vtkm/cont/arg/TransportTagArrayInOut.h b/vtkm/cont/arg/TransportTagArrayInOut.h index 86c53a61b..d34d194ba 100644 --- a/vtkm/cont/arg/TransportTagArrayInOut.h +++ b/vtkm/cont/arg/TransportTagArrayInOut.h @@ -10,6 +10,7 @@ #ifndef vtk_m_cont_arg_TransportTagArrayInOut_h #define vtk_m_cont_arg_TransportTagArrayInOut_h +#include #include #include diff --git a/vtkm/cont/arg/TransportTagArrayOut.h b/vtkm/cont/arg/TransportTagArrayOut.h index d23426cd9..b3eb63116 100644 --- a/vtkm/cont/arg/TransportTagArrayOut.h +++ b/vtkm/cont/arg/TransportTagArrayOut.h @@ -10,6 +10,7 @@ #ifndef vtk_m_cont_arg_TransportTagArrayOut_h #define vtk_m_cont_arg_TransportTagArrayOut_h +#include #include #include diff --git a/vtkm/cont/arg/TransportTagAtomicArray.h b/vtkm/cont/arg/TransportTagAtomicArray.h index c17c5cba4..5ae6740cd 100644 --- a/vtkm/cont/arg/TransportTagAtomicArray.h +++ b/vtkm/cont/arg/TransportTagAtomicArray.h @@ -14,12 +14,6 @@ #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#include -#endif - - #include #include @@ -67,45 +61,6 @@ struct Transport -struct Transport, - Device> -{ - using ExecObjectType = vtkm::exec::AtomicArrayExecutionObject; - using ExecType = vtkm::cont::AtomicArray; - - template - VTKM_CONT ExecObjectType - operator()(vtkm::cont::ArrayHandle& array, - const InputDomainType&, - vtkm::Id, - vtkm::Id) const - { - using ArrayHandleType = vtkm::cont::ArrayHandle; - const bool is_type = vtkm::cont::IsType(array); - if (!is_type) - { -#if defined(VTKM_ENABLE_LOGGING) - VTKM_LOG_CAST_FAIL(array, ArrayHandleType); -#endif - throw vtkm::cont::ErrorBadValue("Arrays being used as atomic's must always have storage that " - "is of the type StorageTagBasic."); - } - - ArrayHandleType handle = vtkm::cont::Cast(array); - - // Note: we ignore the size of the domain because the randomly accessed - // array might not have the same size depending on how the user is using - // the array. - ExecType obj(handle); - return obj.PrepareForExecution(Device()); - } -}; -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL } } } // namespace vtkm::cont::arg diff --git a/vtkm/cont/arg/TransportTagWholeArrayIn.h b/vtkm/cont/arg/TransportTagWholeArrayIn.h index 86454234d..0d44d89fa 100644 --- a/vtkm/cont/arg/TransportTagWholeArrayIn.h +++ b/vtkm/cont/arg/TransportTagWholeArrayIn.h @@ -10,14 +10,13 @@ #ifndef vtk_m_cont_arg_TransportTagWholeArrayIn_h #define vtk_m_cont_arg_TransportTagWholeArrayIn_h +#include #include #include #include -#include - namespace vtkm { namespace cont @@ -56,7 +55,7 @@ struct Transport; + using ExecObjectType = typename ContObjectType::ReadPortalType; template VTKM_CONT ExecObjectType operator()(ContObjectType& array, @@ -69,7 +68,7 @@ struct Transport #include #include #include -#include - namespace vtkm { namespace cont @@ -58,7 +57,7 @@ struct Transport; + using ExecObjectType = typename ContObjectType::WritePortalType; template VTKM_CONT ExecObjectType operator()(ContObjectType& array, @@ -71,7 +70,7 @@ struct Transport #include #include #include -#include - namespace vtkm { namespace cont @@ -58,7 +57,7 @@ struct Transport; + using ExecObjectType = typename ContObjectType::WritePortalType; template VTKM_CONT ExecObjectType operator()(ContObjectType& array, @@ -71,7 +70,7 @@ struct Transport #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL - namespace vtkm { namespace cont @@ -46,15 +42,6 @@ struct TypeCheck::value; }; -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -struct TypeCheck> -{ - static constexpr bool value = vtkm::ListHas::value; -}; -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL } } } // namespace vtkm::cont::arg diff --git a/vtkm/cont/arg/testing/CMakeLists.txt b/vtkm/cont/arg/testing/CMakeLists.txt deleted file mode 100644 index 209736640..000000000 --- a/vtkm/cont/arg/testing/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(unit_tests - UnitTestControlSignatureTag.cxx - UnitTestTypeCheckArray.cxx - UnitTestTypeCheckCellSet.cxx - UnitTestTypeCheckExecObject.cxx - UnitTestTypeCheckKeys.cxx - ) - -set(unit_tests_device - UnitTestTransportArrayIn.cxx - UnitTestTransportArrayInOut.cxx - UnitTestTransportArrayOut.cxx - UnitTestTransportCellSetIn.cxx - UnitTestTransportExecObject.cxx - UnitTestTransportWholeArray.cxx - ) - -vtkm_unit_tests(SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device}) diff --git a/vtkm/cont/cuda/CMakeLists.txt b/vtkm/cont/cuda/CMakeLists.txt index c51cc3600..a57a2d5ba 100644 --- a/vtkm/cont/cuda/CMakeLists.txt +++ b/vtkm/cont/cuda/CMakeLists.txt @@ -17,9 +17,3 @@ set(headers #----------------------------------------------------------------------------- add_subdirectory(internal) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::cuda AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() - diff --git a/vtkm/cont/cuda/ChooseCudaDevice.h b/vtkm/cont/cuda/ChooseCudaDevice.h index 2928fe7a9..738bbcb03 100644 --- a/vtkm/cont/cuda/ChooseCudaDevice.h +++ b/vtkm/cont/cuda/ChooseCudaDevice.h @@ -126,22 +126,6 @@ static void SetFastestDeviceId() .SetDeviceInstance(deviceId); } -//choose a cuda compute device. This can't be used if you are setting -//up open gl interop -VTKM_DEPRECATED(1.7, - "Use " - "RuntimeInformation{}.GetRuntimeConfiguration(vtkm::cont::DeviceAdapterTagCuda)." - "SetDeviceInstance(id) instead") -static void SetCudaDevice(int id) -{ - cudaError_t cError = cudaSetDevice(id); - if (cError != cudaSuccess) - { - std::string cuda_error_msg("Unable to bind to the given cuda device. Error: "); - cuda_error_msg.append(cudaGetErrorString(cError)); - throw vtkm::cont::ErrorExecution(cuda_error_msg); - } -} } } } //namespace diff --git a/vtkm/cont/cuda/DeviceAdapterCuda.h b/vtkm/cont/cuda/DeviceAdapterCuda.h index 4a905cf5f..8c7298391 100644 --- a/vtkm/cont/cuda/DeviceAdapterCuda.h +++ b/vtkm/cont/cuda/DeviceAdapterCuda.h @@ -23,9 +23,6 @@ #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL #else // !VTKM_CUDA diff --git a/vtkm/cont/cuda/internal/CMakeLists.txt b/vtkm/cont/cuda/internal/CMakeLists.txt index 0c53cdc4a..c62b4924d 100644 --- a/vtkm/cont/cuda/internal/CMakeLists.txt +++ b/vtkm/cont/cuda/internal/CMakeLists.txt @@ -21,16 +21,10 @@ set(headers ThrustExceptionHandler.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - VirtualObjectTransferCuda.h - ) -endif() - vtkm_declare_headers(${headers}) -if (TARGET vtkm::cuda) +if (TARGET vtkm_cuda) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CudaAllocator.cu ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmCuda.cu diff --git a/vtkm/cont/cuda/internal/VirtualObjectTransferCuda.h b/vtkm/cont/cuda/internal/VirtualObjectTransferCuda.h deleted file mode 100644 index 1b84e7e2f..000000000 --- a/vtkm/cont/cuda/internal/VirtualObjectTransferCuda.h +++ /dev/null @@ -1,157 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_cuda_internal_VirtualObjectTransferCuda_h -#define vtk_m_cont_cuda_internal_VirtualObjectTransferCuda_h - -#include -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -namespace detail -{ - -#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -template -__global__ void ConstructVirtualObjectKernel(VirtualDerivedType* deviceObject, - const VirtualDerivedType* targetObject) -{ - // Use the "placement new" syntax to construct an object in pre-allocated memory - new (deviceObject) VirtualDerivedType(*targetObject); -} - -template -__global__ void UpdateVirtualObjectKernel(VirtualDerivedType* deviceObject, - const VirtualDerivedType* targetObject) -{ - *deviceObject = *targetObject; -} - -template -__global__ void DeleteVirtualObjectKernel(VirtualDerivedType* deviceObject) -{ - deviceObject->~VirtualDerivedType(); -} - -#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) -#pragma GCC diagnostic pop -#endif - -} // detail - -template -struct VirtualObjectTransfer -{ - VTKM_CONT VirtualObjectTransfer(const VirtualDerivedType* virtualObject) - : ControlObject(virtualObject) - , ExecutionObject(nullptr) - { - } - - VTKM_CONT ~VirtualObjectTransfer() { this->ReleaseResources(); } - - VirtualObjectTransfer(const VirtualObjectTransfer&) = delete; - void operator=(const VirtualObjectTransfer&) = delete; - - VTKM_CONT const VirtualDerivedType* PrepareForExecution(bool updateData) - { - if (this->ExecutionObject == nullptr) - { - // deviceTarget will hold a byte copy of the host object on the device. The virtual table - // will be wrong. - VirtualDerivedType* deviceTarget; - VTKM_CUDA_CALL(cudaMalloc(&deviceTarget, sizeof(VirtualDerivedType))); - VTKM_CUDA_CALL(cudaMemcpyAsync(deviceTarget, - this->ControlObject, - sizeof(VirtualDerivedType), - cudaMemcpyHostToDevice, - cudaStreamPerThread)); - - // Allocate memory for the object that will eventually be a correct copy on the device. - VTKM_CUDA_CALL(cudaMalloc(&this->ExecutionObject, sizeof(VirtualDerivedType))); - - // Initialize the device object - detail::ConstructVirtualObjectKernel<<<1, 1, 0, cudaStreamPerThread>>>(this->ExecutionObject, - deviceTarget); - VTKM_CUDA_CHECK_ASYNCHRONOUS_ERROR(); - - // Clean up intermediate copy - vtkm::cont::cuda::internal::CudaAllocator::FreeDeferred(deviceTarget, - sizeof(VirtualDerivedType)); - } - else if (updateData) - { - // deviceTarget will hold a byte copy of the host object on the device. The virtual table - // will be wrong. - VirtualDerivedType* deviceTarget; - VTKM_CUDA_CALL(cudaMalloc(&deviceTarget, sizeof(VirtualDerivedType))); - VTKM_CUDA_CALL(cudaMemcpyAsync(deviceTarget, - this->ControlObject, - sizeof(VirtualDerivedType), - cudaMemcpyHostToDevice, - cudaStreamPerThread)); - - // Initialize the device object - detail::UpdateVirtualObjectKernel<<<1, 1, 0, cudaStreamPerThread>>>(this->ExecutionObject, - deviceTarget); - VTKM_CUDA_CHECK_ASYNCHRONOUS_ERROR(); - - // Clean up intermediate copy - vtkm::cont::cuda::internal::CudaAllocator::FreeDeferred(deviceTarget, - sizeof(VirtualDerivedType)); - } - else - { - // Nothing to do. The device object is already up to date. - } - - return this->ExecutionObject; - } - - VTKM_CONT void ReleaseResources() - { - if (this->ExecutionObject != nullptr) - { - detail::DeleteVirtualObjectKernel<<<1, 1, 0, cudaStreamPerThread>>>(this->ExecutionObject); - vtkm::cont::cuda::internal::CudaAllocator::FreeDeferred(this->ExecutionObject, - sizeof(VirtualDerivedType)); - this->ExecutionObject = nullptr; - } - } - -private: - const VirtualDerivedType* ControlObject; - VirtualDerivedType* ExecutionObject; -}; -} -} -} // vtkm::cont::internal - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtk_m_cont_cuda_internal_VirtualObjectTransferCuda_h diff --git a/vtkm/cont/cuda/testing/UnitTestCudaMathEdgeCases.cu b/vtkm/cont/cuda/testing/UnitTestCudaMathEdgeCases.cu index a78e28c95..114778e52 100644 --- a/vtkm/cont/cuda/testing/UnitTestCudaMathEdgeCases.cu +++ b/vtkm/cont/cuda/testing/UnitTestCudaMathEdgeCases.cu @@ -139,8 +139,8 @@ void RunEdgeCases() sanevalues.push_back(range(rng)); } - auto bad = vtkm::cont::make_ArrayHandle(badvalues); - auto sane = vtkm::cont::make_ArrayHandle(sanevalues); + auto bad = vtkm::cont::make_ArrayHandle(badvalues, vtkm::CopyFlag::On); + auto sane = vtkm::cont::make_ArrayHandle(sanevalues, vtkm::CopyFlag::On); decltype(sane) result; vtkm::worklet::DispatcherMapField dispatcher; dispatcher.SetDevice(Device()); diff --git a/vtkm/cont/cuda/vtkm.module b/vtkm/cont/cuda/vtkm.module new file mode 100644 index 000000000..91722717b --- /dev/null +++ b/vtkm/cont/cuda/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_cont_cuda +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_worklet + vtkm_cuda diff --git a/vtkm/cont/internal/ArrayHandleDeprecated.h b/vtkm/cont/internal/ArrayHandleDeprecated.h deleted file mode 100644 index b321addfa..000000000 --- a/vtkm/cont/internal/ArrayHandleDeprecated.h +++ /dev/null @@ -1,1438 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_ArrayHandleDeprecated_h -#define vtk_m_cont_internal_ArrayHandleDeprecated_h - -#include - -#include -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -/// The `ArrayHandle` implementation was recently significantly changed. -/// Implementations still using the old style should use this version. -/// These implementations should be deprecated. -/// -template -class VTKM_ALWAYS_EXPORT ArrayHandleDeprecated : public internal::ArrayHandleBase -{ -private: - // Basic storage is specialized; this template should not be instantiated - // for it. Specialization is in ArrayHandleBasicImpl.h - static_assert(!std::is_same::value, - "StorageTagBasic should not use this implementation."); - - using ExecutionManagerType = - vtkm::cont::internal::ArrayHandleExecutionManagerBase; - - using MutexType = std::mutex; - using LockType = std::unique_lock; - - mutable vtkm::cont::internal::Buffer BufferAsStorageWrapper; - - struct PrepareForInputFunctor; - struct PrepareForOutputFunctor; - struct PrepareForInPlaceFunctor; - -public: - using StorageType = vtkm::cont::internal::Storage; - using ValueType = T; - using StorageTag = StorageTag_; - using WritePortalType = typename StorageType::PortalType; - using ReadPortalType = typename StorageType::PortalConstType; - template - struct ExecutionTypes - { - using Portal = typename ExecutionManagerType::template ExecutionTypes::Portal; - using PortalConst = - typename ExecutionManagerType::template ExecutionTypes::PortalConst; - }; - - using PortalControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::WritePortalType instead.") = - typename StorageType::PortalType; - using PortalConstControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::ReadPortalType instead.") = - typename StorageType::PortalConstType; - - // Handle the fact that the ArrayHandle design has changed. - VTKM_STATIC_ASSERT_MSG((std::is_same::value), - "ArrayHandle design has changed. To support old-style arrays, have the " - "Storage implementation declare VTKM_STORAGE_OLD_STYLE at the bottom " - "of its implementation."); - VTKM_CONT static constexpr vtkm::IdComponent GetNumberOfBuffers() { return 1; } - VTKM_CONT std::vector GetBuffers() const - { - this->BufferAsStorageWrapper.SetMetaData(*this); - return std::vector(1, this->BufferAsStorageWrapper); - } - - VTKM_CONT ArrayHandleDeprecated(const vtkm::cont::internal::Buffer* buffers) - { - VTKM_ASSERT(buffers[0].MetaDataIsType()); - *this = buffers[0].GetMetaData(); - } - - /// Constructs an empty ArrayHandleDeprecated. Typically used for output or - /// intermediate arrays that will be filled by a VTKm algorithm. - /// - VTKM_CONT ArrayHandleDeprecated(); - - /// Copy 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 copy constructor could be - /// created for all devices, and it would not be valid for all devices. - /// - ArrayHandleDeprecated(const ArrayHandleDeprecated& 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. - /// - ArrayHandleDeprecated(ArrayHandleDeprecated&& src) noexcept; - - /// 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. - /// - ArrayHandleDeprecated(const StorageType& storage); - - - /// 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. - /// - ArrayHandleDeprecated(StorageType&& storage) noexcept; - - /// Destructs an empty ArrayHandleDeprecated. - /// - /// 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 destructor could be - /// created for all devices, and it would not be valid for all devices. - /// - ~ArrayHandleDeprecated(); - - /// \brief Copies an ArrayHandleDeprecated - /// - VTKM_CONT - ArrayHandleDeprecated& operator=( - const ArrayHandleDeprecated& src); - - /// \brief Move and Assignment of an ArrayHandleDeprecated - /// - VTKM_CONT - ArrayHandleDeprecated& operator=( - ArrayHandleDeprecated&& src) noexcept; - - /// Like a pointer, two \c ArrayHandles are considered equal if they point - /// to the same location in memory. - /// - VTKM_CONT - bool operator==(const ArrayHandleDeprecated& rhs) const - { - return (this->Internals == rhs.Internals); - } - - VTKM_CONT - bool operator!=(const ArrayHandleDeprecated& rhs) const - { - return (this->Internals != rhs.Internals); - } - - VTKM_CONT bool operator==(const vtkm::cont::ArrayHandle& rhs) const - { - return *this == static_cast>(rhs); - } - - VTKM_CONT bool operator!=(const vtkm::cont::ArrayHandle& rhs) const - { - return *this != static_cast>(rhs); - } - - template - VTKM_CONT bool operator==(const ArrayHandleDeprecated&) const - { - return false; // different valuetype and/or storage - } - - template - VTKM_CONT bool operator!=(const ArrayHandleDeprecated&) const - { - return true; // different valuetype and/or storage - } - - template - VTKM_CONT bool operator==(const vtkm::cont::ArrayHandle&) const - { - return false; // different storage - } - - template - VTKM_CONT bool operator!=(const vtkm::cont::ArrayHandle&) const - { - return false; // different storage - } - - /// Get the storage. - /// - VTKM_CONT StorageType& GetStorage(); - - /// Get the storage. - /// - VTKM_CONT const StorageType& GetStorage() const; - - /// Get the array portal of the control array. - /// Since worklet invocations are asynchronous and this routine is a synchronization point, - /// exceptions maybe thrown for errors from previously executed worklets. - /// - /// \deprecated Use `WritePortal` instead. Note that the portal returned from `WritePortal` - /// will disallow any other reads or writes to the array while it is in scope. - /// - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use ArrayHandle::WritePortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - - /// \cond NOPE - typename StorageType::PortalType GetPortalControl(); - /// \endcond - - /// Get the array portal of the control array. - /// Since worklet invocations are asynchronous and this routine is a synchronization point, - /// exceptions maybe thrown for errors from previously executed worklets. - /// - /// \deprecated Use `ReadPortal` instead. Note that the portal returned from `ReadPortal` - /// will disallow any writes to the array while it is in scope. - /// - VTKM_CONT - VTKM_DEPRECATED(1.6, - "Use ArrayHandle::ReadPortal() instead. " - "Note that the returned portal will lock the array while it is in scope.") - /// \cond NOPE - typename StorageType::PortalConstType GetPortalConstControl() const; - /// \endcond - - /// \@{ - /// \brief Get an array portal that can be used in the control environment. - /// - /// The returned array can be used in the control environment to read values from the array. (It - /// is not possible to write to the returned portal. That is `Get` will work on the portal, but - /// `Set` will not.) - /// - /// **Note:** The returned portal cannot be used in the execution environment. This is because - /// the portal will not work on some devices like GPUs. To get a portal that will work in the - /// execution environment, use `PrepareForInput`. - /// - VTKM_CONT ReadPortalType ReadPortal() const; - /// \@} - - /// \@{ - /// \brief Get an array portal that can be used in the control environment. - /// - /// The returned array can be used in the control environment to reand and write values to the - /// array. - /// - /// - /// **Note:** The returned portal cannot be used in the execution environment. This is because - /// the portal will not work on some devices like GPUs. To get a portal that will work in the - /// execution environment, use `PrepareForInput`. - /// - VTKM_CONT WritePortalType WritePortal() const; - /// \@} - - /// Returns the number of entries in the array. - /// - VTKM_CONT vtkm::Id GetNumberOfValues() const - { - LockType lock = this->GetLock(); - - return this->GetNumberOfValues(lock); - } - - /// \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 - /// 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 - void Allocate(vtkm::Id numberOfValues) - { - vtkm::cont::Token token; - this->Allocate(numberOfValues, token); - } - VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::cont::Token& token) - { - LockType lock = this->GetLock(); - this->WaitToWrite(lock, token); - this->ReleaseResourcesExecutionInternal(lock, token); - this->Internals->GetControlArray(lock)->Allocate(numberOfValues); - // Set to false and then to true to ensure anything pointing to an array before the allocate - // is invalidated. - this->Internals->SetControlArrayValid(lock, false); - this->Internals->SetControlArrayValid(lock, true); - } - - /// \brief Reduces the size of the array without changing its values. - /// - /// This method allows you to resize the array without reallocating it. The - /// number of entries in the array is changed to \c numberOfValues. The data - /// in the array (from indices 0 to \c numberOfValues - 1) are the same, but - /// \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. - VTKM_CONT void Shrink(vtkm::Id numberOfValues) - { - vtkm::cont::Token token; - this->Shrink(numberOfValues, token); - } - VTKM_CONT void Shrink(vtkm::Id numberOfValues, vtkm::cont::Token& token); - - /// Releases any resources being used in the execution environment (that are - /// not being shared by the control environment). - /// - VTKM_CONT void ReleaseResourcesExecution() - { - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - this->WaitToWrite(lock, token); - - // Save any data in the execution environment by making sure it is synced - // with the control environment. - this->SyncControlArray(lock, token); - - this->ReleaseResourcesExecutionInternal(lock, token); - } - } - - /// Releases all resources in both the control and execution environments. - /// - VTKM_CONT void ReleaseResources() - { - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - - this->ReleaseResourcesExecutionInternal(lock, token); - - if (this->Internals->IsControlArrayValid(lock)) - { - this->Internals->GetControlArray(lock)->ReleaseResources(); - this->Internals->SetControlArrayValid(lock, false); - } - } - } - - /// Prepares this array to be used as an input to an operation in the - /// execution environment. If necessary, copies data to the execution - /// environment. Can throw an exception if this array does not yet contain - /// any data. Returns a portal that can be used in code running in the - /// execution environment. - /// - /// The `Token` object provided will be attached to this `ArrayHandle`. - /// The returned portal is guaranteed to be valid while the `Token` is - /// still attached and in scope. Other operations on this `ArrayHandle` - /// that would invalidate the returned portal will block until the `Token` - /// is released. Likewise, this method will block if another `Token` is - /// already attached. This can potentially lead to deadlocks. - /// - template - VTKM_CONT ReadPortalType PrepareForInput(DeviceAdapterTag, vtkm::cont::Token& token) const; - VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) 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 - /// have valid data in the execution array with the assumption that the array - /// will be filled soon (i.e. before any other methods of this object are - /// called). Returns a portal that can be used in code running in the - /// execution environment. - /// - /// The `Token` object provided will be attached to this `ArrayHandle`. - /// The returned portal is guaranteed to be valid while the `Token` is - /// still attached and in scope. Other operations on this `ArrayHandle` - /// that would invalidate the returned portal will block until the `Token` - /// is released. Likewise, this method will block if another `Token` is - /// already attached. This can potentially lead to deadlocks. - /// - template - VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, - DeviceAdapterTag, - vtkm::cont::Token& token); - VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token); - - /// 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 - /// the execution environment. Can throw an exception if this array does not - /// yet contain any data. Returns a portal that can be used in code running - /// in the execution environment. - /// - /// The `Token` object provided will be attached to this `ArrayHandle`. - /// The returned portal is guaranteed to be valid while the `Token` is - /// still attached and in scope. Other operations on this `ArrayHandle` - /// that would invalidate the returned portal will block until the `Token` - /// is released. Likewise, this method will block if another `Token` is - /// already attached. This can potentially lead to deadlocks. - /// - template - VTKM_CONT WritePortalType PrepareForInPlace(DeviceAdapterTag, vtkm::cont::Token& token); - VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token); - - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInput now requires a vtkm::cont::Token object.") - typename ExecutionTypes::PortalConst PrepareForInput(DeviceAdapterTag) const - { - vtkm::cont::Token token; - return this->PrepareForInput(DeviceAdapterTag{}, token); - } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForOutput now requires a vtkm::cont::Token object.") - typename ExecutionTypes::Portal - PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag) - { - vtkm::cont::Token token; - return this->PrepareForOutput(numberOfValues, DeviceAdapterTag{}, token); - } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInPlace now requires a vtkm::cont::Token object.") - typename ExecutionTypes::Portal PrepareForInPlace(DeviceAdapterTag) - { - vtkm::cont::Token token; - return this->PrepareForInPlace(DeviceAdapterTag{}, token); - } - - /// Returns the DeviceAdapterId for the current device. If there is no device - /// with an up-to-date copy of the data, VTKM_DEVICE_ADAPTER_UNDEFINED is - /// returned. - /// - /// Note that in a multithreaded environment the validity of this result can - /// change. - VTKM_CONT - DeviceAdapterId GetDeviceAdapterId() const - { - LockType lock = this->GetLock(); - return this->Internals->IsExecutionArrayValid(lock) - ? this->Internals->GetExecutionArray(lock)->GetDeviceAdapterId() - : DeviceAdapterTagUndefined{}; - } - - /// 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 - { - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - this->SyncControlArray(lock, token); - } - } - - /// \brief Enqueue a token for access to this ArrayHandle. - /// - /// This method places the given `Token` into the queue of `Token`s waiting for - /// access to this `ArrayHandle` and then returns immediately. When this token - /// is later used to get data from this `ArrayHandle` (for example, in a call to - /// `PrepareForInput`), it will use this place in the queue while waiting for - /// access. - /// - /// This method is to be used to ensure that a set of accesses to an `ArrayHandle` - /// that happen on multiple threads occur in a specified order. For example, if - /// you spawn of a job to modify data in an `ArrayHandle` and then spawn off a job - /// that reads that same data, you need to make sure that the first job gets - /// access to the `ArrayHandle` before the second. If they both just attempt to call - /// their respective `Prepare` methods, there is no guarantee which order they - /// will occur. Having the spawning thread first call this method will ensure the order. - /// - /// \warning After calling this method it is required to subsequently - /// call a method like one of the `Prepare` methods that attaches the token - /// to this `ArrayHandle`. Otherwise, the enqueued token will block any subsequent - /// access to the `ArrayHandle`, even if the `Token` is destroyed. - /// - VTKM_CONT void Enqueue(const vtkm::cont::Token& token) const; - -private: - /// Acquires a lock on the internals of this `ArrayHandle`. The calling - /// function should keep the returned lock and let it go out of scope - /// when the lock is no longer needed. - /// - LockType GetLock() const { return LockType(this->Internals->Mutex); } - - /// Returns true if read operations can currently be performed. - /// - VTKM_CONT bool CanRead(const LockType& lock, const vtkm::cont::Token& token) const; - - //// Returns true if write operations can currently be performed. - /// - VTKM_CONT bool CanWrite(const LockType& lock, const vtkm::cont::Token& token) const; - - //// Will block the current thread until a read can be performed. - /// - VTKM_CONT void WaitToRead(LockType& lock, vtkm::cont::Token& token) const; - - //// Will block the current thread until a write can be performed. - /// - VTKM_CONT void WaitToWrite(LockType& lock, vtkm::cont::Token& token, bool fakeRead = false) const; - - /// 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 - VTKM_CONT void PrepareForDevice(LockType& lock, vtkm::cont::Token& token, 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(LockType& lock, vtkm::cont::Token& token) const; - - vtkm::Id GetNumberOfValues(LockType& lock) const; - - VTKM_CONT - void ReleaseResourcesExecutionInternal(LockType& lock, vtkm::cont::Token& token) const - { - if (this->Internals->IsExecutionArrayValid(lock)) - { - this->WaitToWrite(lock, token); - // Note that it is possible that while waiting someone else deleted the execution array. - // That is why we check again. - } - if (this->Internals->IsExecutionArrayValid(lock)) - { - this->Internals->GetExecutionArray(lock)->ReleaseResources(); - this->Internals->SetExecutionArrayValid(lock, false); - } - } - - VTKM_CONT void Enqueue(const LockType& lock, const vtkm::cont::Token& token) const; - - class VTKM_ALWAYS_EXPORT InternalStruct - { - mutable StorageType ControlArray; - mutable std::shared_ptr ControlArrayValid; - - mutable std::unique_ptr ExecutionArray; - mutable bool ExecutionArrayValid = false; - - mutable vtkm::cont::Token::ReferenceCount ReadCount = 0; - mutable vtkm::cont::Token::ReferenceCount WriteCount = 0; - - mutable std::deque Queue; - - VTKM_CONT void CheckLock(const LockType& lock) const - { - VTKM_ASSERT((lock.mutex() == &this->Mutex) && (lock.owns_lock())); - } - - public: - MutexType Mutex; - std::condition_variable ConditionVariable; - - InternalStruct() = default; - InternalStruct(const StorageType& storage); - InternalStruct(StorageType&& storage); - - ~InternalStruct() - { - // It should not be possible to destroy this array if any tokens are still attached to it. - LockType lock(this->Mutex); - VTKM_ASSERT((*this->GetReadCount(lock) == 0) && (*this->GetWriteCount(lock) == 0)); - this->SetControlArrayValid(lock, false); - } - - // To access any feature in InternalStruct, you must have locked the mutex. You have - // to prove it by passing in a reference to a std::unique_lock. - VTKM_CONT bool IsControlArrayValid(const LockType& lock) const - { - this->CheckLock(lock); - if (!this->ControlArrayValid) - { - return false; - } - else - { - return *this->ControlArrayValid; - } - } - VTKM_CONT void SetControlArrayValid(const LockType& lock, bool value) - { - this->CheckLock(lock); - if (IsControlArrayValid(lock) == value) - { - return; - } - if (value) // ControlArrayValid == false or nullptr - { - // If we are changing the valid flag from false to true, then refresh the pointer. - // There may be array portals that already have a reference to the flag. Those portals - // will stay in an invalid state whereas new portals will go to a valid state. To - // handle both conditions, drop the old reference and create a new one. - this->ControlArrayValid.reset(new bool(true)); - } - else // value == false and ControlArrayValid == true - { - *this->ControlArrayValid = false; - } - } - VTKM_CONT std::shared_ptr GetControlArrayValidPointer(const LockType& lock) const - { - this->CheckLock(lock); - return this->ControlArrayValid; - } - VTKM_CONT StorageType* GetControlArray(const LockType& lock) const - { - this->CheckLock(lock); - return &this->ControlArray; - } - - VTKM_CONT bool IsExecutionArrayValid(const LockType& lock) const - { - this->CheckLock(lock); - return this->ExecutionArrayValid; - } - VTKM_CONT void SetExecutionArrayValid(const LockType& lock, bool value) - { - this->CheckLock(lock); - this->ExecutionArrayValid = value; - } - VTKM_CONT ExecutionManagerType* GetExecutionArray(const LockType& lock) const - { - this->CheckLock(lock); - return this->ExecutionArray.get(); - } - VTKM_CONT void DeleteExecutionArray(const LockType& lock) - { - this->CheckLock(lock); - this->ExecutionArray.reset(); - this->ExecutionArrayValid = false; - } - template - VTKM_CONT void NewExecutionArray(const LockType& lock, DeviceAdapterTag) - { - VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag); - this->CheckLock(lock); - VTKM_ASSERT(this->ExecutionArray == nullptr); - VTKM_ASSERT(!this->ExecutionArrayValid); - this->ExecutionArray.reset( - new vtkm::cont::internal::ArrayHandleExecutionManager( - &this->ControlArray)); - } - VTKM_CONT vtkm::cont::Token::ReferenceCount* GetReadCount(const LockType& lock) const - { - this->CheckLock(lock); - return &this->ReadCount; - } - VTKM_CONT vtkm::cont::Token::ReferenceCount* GetWriteCount(const LockType& lock) const - { - this->CheckLock(lock); - return &this->WriteCount; - } - VTKM_CONT std::deque& GetQueue(const LockType& lock) const - { - this->CheckLock(lock); - return this->Queue; - } - }; - - VTKM_CONT - ArrayHandleDeprecated(const std::shared_ptr& i) - : Internals(i) - { - } - - std::shared_ptr Internals; -}; - -template -ArrayHandleDeprecated::InternalStruct::InternalStruct( - const typename ArrayHandleDeprecated::StorageType& storage) - : ControlArray(storage) - , ControlArrayValid(new bool(true)) - , ExecutionArrayValid(false) -{ -} - -template -ArrayHandleDeprecated::InternalStruct::InternalStruct( - typename ArrayHandleDeprecated::StorageType&& storage) - : ControlArray(std::move(storage)) - , ControlArrayValid(new bool(true)) - , ExecutionArrayValid(false) -{ -} - -template -ArrayHandleDeprecated::ArrayHandleDeprecated() - : Internals(std::make_shared()) -{ -} - -template -ArrayHandleDeprecated::ArrayHandleDeprecated(const ArrayHandleDeprecated& src) - : Internals(src.Internals) -{ -} - -template -ArrayHandleDeprecated::ArrayHandleDeprecated(ArrayHandleDeprecated&& src) noexcept - : Internals(std::move(src.Internals)) -{ -} - -template -ArrayHandleDeprecated::ArrayHandleDeprecated( - const typename ArrayHandleDeprecated::StorageType& storage) - : Internals(std::make_shared(storage)) -{ -} - -template -ArrayHandleDeprecated::ArrayHandleDeprecated( - typename ArrayHandleDeprecated::StorageType&& storage) noexcept - : Internals(std::make_shared(std::move(storage))) -{ -} - -template -ArrayHandleDeprecated::~ArrayHandleDeprecated() -{ -} - -template -ArrayHandleDeprecated& ArrayHandleDeprecated::operator=( - const ArrayHandleDeprecated& src) -{ - this->Internals = src.Internals; - return *this; -} - -template -ArrayHandleDeprecated& ArrayHandleDeprecated::operator=( - ArrayHandleDeprecated&& src) noexcept -{ - this->Internals = std::move(src.Internals); - return *this; -} - -template -typename ArrayHandleDeprecated::StorageType& ArrayHandleDeprecated::GetStorage() -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - return *this->Internals->GetControlArray(lock); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -const typename ArrayHandleDeprecated::StorageType& ArrayHandleDeprecated::GetStorage() - const -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - return *this->Internals->GetControlArray(lock); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -typename ArrayHandleDeprecated::StorageType::PortalType -ArrayHandleDeprecated::GetPortalControl() -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - // 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(lock, token); - return this->Internals->GetControlArray(lock)->GetPortal(); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -typename ArrayHandleDeprecated::StorageType::PortalConstType -ArrayHandleDeprecated::GetPortalConstControl() const -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - return this->Internals->GetControlArray(lock)->GetPortalConst(); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -typename ArrayHandleDeprecated::ReadPortalType ArrayHandleDeprecated::ReadPortal() const -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - this->WaitToRead(lock, token); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - return ReadPortalType(this->Internals->GetControlArray(lock)->GetPortalConst()); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -typename ArrayHandleDeprecated::WritePortalType ArrayHandleDeprecated::WritePortal() - const -{ - // A Token should not be declared within the scope of a lock. when the token goes out of scope - // it will attempt to aquire the lock, which is undefined behavior of the thread already has - // the lock. - vtkm::cont::Token token; - { - LockType lock = this->GetLock(); - this->WaitToWrite(lock, token); - - this->SyncControlArray(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - // 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(lock, token); - return WritePortalType(this->Internals->GetControlArray(lock)->GetPortal()); - } - else - { - throw vtkm::cont::ErrorInternal( - "ArrayHandle::SyncControlArray did not make control array valid."); - } - } -} - -template -vtkm::Id ArrayHandleDeprecated::GetNumberOfValues(LockType& lock) const -{ - if (this->Internals->IsControlArrayValid(lock)) - { - return this->Internals->GetControlArray(lock)->GetNumberOfValues(); - } - else if (this->Internals->IsExecutionArrayValid(lock)) - { - return this->Internals->GetExecutionArray(lock)->GetNumberOfValues(); - } - else - { - return 0; - } -} - -template -void ArrayHandleDeprecated::Shrink(vtkm::Id numberOfValues, vtkm::cont::Token& token) -{ - VTKM_ASSERT(numberOfValues >= 0); - - if (numberOfValues > 0) - { - LockType lock = this->GetLock(); - - vtkm::Id originalNumberOfValues = this->GetNumberOfValues(lock); - - if (numberOfValues < originalNumberOfValues) - { - this->WaitToWrite(lock, token); - if (this->Internals->IsControlArrayValid(lock)) - { - this->Internals->GetControlArray(lock)->Shrink(numberOfValues); - } - if (this->Internals->IsExecutionArrayValid(lock)) - { - this->Internals->GetExecutionArray(lock)->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(lock) == 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, token); - } -} - -template -template -typename ArrayHandleDeprecated::ReadPortalType ArrayHandleDeprecated::PrepareForInput( - DeviceAdapterTag device, - vtkm::cont::Token& token) const -{ - VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag); - - LockType lock = this->GetLock(); - this->WaitToRead(lock, token); - - if (!this->Internals->IsControlArrayValid(lock) && !this->Internals->IsExecutionArrayValid(lock)) - { - // Want to use an empty array. - // Set up ArrayHandle state so this actually works. - this->Internals->GetControlArray(lock)->Allocate(0); - this->Internals->SetControlArrayValid(lock, true); - } - - this->PrepareForDevice(lock, token, device); - auto portal = this->Internals->GetExecutionArray(lock)->PrepareForInput( - !this->Internals->IsExecutionArrayValid(lock), device, token); - - this->Internals->SetExecutionArrayValid(lock, true); - - return portal; -} - -template -struct ArrayHandleDeprecated::PrepareForInputFunctor -{ - template - bool operator()(Device device, - const ArrayHandleDeprecated& self, - vtkm::cont::Token& token, - ReadPortalType& portal) const - { - portal = self.PrepareForInput(device, token); - return true; - } -}; - -template -typename ArrayHandleDeprecated::ReadPortalType ArrayHandleDeprecated::PrepareForInput( - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const -{ - ReadPortalType portal; - vtkm::cont::TryExecuteOnDevice(device, PrepareForInputFunctor{}, *this, token, portal); - return portal; -} - -template -template -typename ArrayHandleDeprecated::WritePortalType ArrayHandleDeprecated::PrepareForOutput( - vtkm::Id numberOfValues, - DeviceAdapterTag device, - vtkm::cont::Token& token) -{ - VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag); - - LockType lock = this->GetLock(); - this->WaitToWrite(lock, token); - - // Invalidate any control arrays. - // Should the control array resource be released? Probably not a good - // idea when shared with execution. - this->Internals->SetControlArrayValid(lock, false); - - this->PrepareForDevice(lock, token, device); - auto portal = - this->Internals->GetExecutionArray(lock)->PrepareForOutput(numberOfValues, device, token); - - // 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->SetExecutionArrayValid(lock, true); - - return portal; -} - -template -struct ArrayHandleDeprecated::PrepareForOutputFunctor -{ - template - bool operator()(Device device, - ArrayHandleDeprecated& self, - vtkm::Id numberOfValues, - vtkm::cont::Token& token, - WritePortalType& portal) const - { - portal = self.PrepareForOutput(numberOfValues, device, token); - return true; - } -}; - -template -typename ArrayHandleDeprecated::WritePortalType ArrayHandleDeprecated::PrepareForOutput( - vtkm::Id numberOfValues, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) -{ - WritePortalType portal; - vtkm::cont::TryExecuteOnDevice( - device, PrepareForOutputFunctor{}, *this, numberOfValues, token, portal); - return portal; -} - -template -template -typename ArrayHandleDeprecated::WritePortalType -ArrayHandleDeprecated::PrepareForInPlace(DeviceAdapterTag device, vtkm::cont::Token& token) -{ - VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag); - - LockType lock = this->GetLock(); - this->WaitToWrite(lock, token); - - if (!this->Internals->IsControlArrayValid(lock) && !this->Internals->IsExecutionArrayValid(lock)) - { - // Want to use an empty array. - // Set up ArrayHandle state so this actually works. - this->Internals->GetControlArray(lock)->Allocate(0); - this->Internals->SetControlArrayValid(lock, true); - } - - this->PrepareForDevice(lock, token, device); - auto portal = this->Internals->GetExecutionArray(lock)->PrepareForInPlace( - !this->Internals->IsExecutionArrayValid(lock), device, token); - - this->Internals->SetExecutionArrayValid(lock, 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->SetControlArrayValid(lock, false); - - return portal; -} - -template -struct ArrayHandleDeprecated::PrepareForInPlaceFunctor -{ - template - bool operator()(Device device, - ArrayHandleDeprecated& self, - vtkm::cont::Token& token, - ReadPortalType& portal) const - { - portal = self.PrepareForInPlace(device, token); - return true; - } -}; - -template -typename ArrayHandleDeprecated::WritePortalType -ArrayHandleDeprecated::PrepareForInPlace(vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) -{ - WritePortalType portal; - vtkm::cont::TryExecuteOnDevice(device, PrepareForInPlaceFunctor{}, *this, token, portal); - return portal; -} - -template -template -void ArrayHandleDeprecated::PrepareForDevice(LockType& lock, - vtkm::cont::Token& token, - DeviceAdapterTag device) const -{ - if (this->Internals->GetExecutionArray(lock) != nullptr) - { - if (this->Internals->GetExecutionArray(lock)->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. (TODO: it would be possible for the array handle - // to hold references to execution arrays on multiple devices. When data - // are written on one devices, all the other devices should get cleared.) - - // BUG: There is a non-zero chance that while waiting for the write lock, another thread - // could change the ExecutionInterface, which would cause problems. In the future we should - // support multiple devices, in which case we would not have to delete one execution array - // to load another. - // BUG: The current implementation does not allow the ArrayHandle to be on two devices - // at the same time. Thus, it is not possible for two simultaneously read from the same - // ArrayHandle on two different devices. This might cause unexpected deadlocks. - this->WaitToWrite(lock, token, true); // Make sure no one is reading device array - this->SyncControlArray(lock, token); - // Need to change some state that does not change the logical state from - // an external point of view. - this->Internals->DeleteExecutionArray(lock); - } - } - - // Need to change some state that does not change the logical state from - // an external point of view. - this->Internals->NewExecutionArray(lock, device); -} - -template -void ArrayHandleDeprecated::SyncControlArray(LockType& lock, vtkm::cont::Token& token) const -{ - if (!this->Internals->IsControlArrayValid(lock)) - { - // It may be the case that `SyncControlArray` is called from a method that has a `Token`. - // However, if we are here, that `Token` should not already be attached to this array. - // If it were, then there should be no reason to move data arround (unless the `Token` - // was used when preparing for multiple devices, which it should not be used like that). - this->WaitToRead(lock, token); - - // Need to change some state that does not change the logical state from - // an external point of view. - if (this->Internals->IsExecutionArrayValid(lock)) - { - this->Internals->GetExecutionArray(lock)->RetrieveOutputData( - this->Internals->GetControlArray(lock)); - this->Internals->SetControlArrayValid(lock, 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. - this->Internals->GetControlArray(lock)->Allocate(0); - this->Internals->SetControlArrayValid(lock, true); - } - } -} - -template -bool ArrayHandleDeprecated::CanRead(const LockType& lock, - const vtkm::cont::Token& token) const -{ - // If the token is already attached to this array, then we allow reading. - if (token.IsAttached(this->Internals->GetWriteCount(lock)) || - token.IsAttached(this->Internals->GetReadCount(lock))) - { - return true; - } - - // If there is anyone else waiting at the top of the queue, we cannot access this array. - auto& queue = this->Internals->GetQueue(lock); - if (!queue.empty() && (queue.front() != token)) - { - return false; - } - - // No one else is waiting, so we can read the array as long as no one else is writing. - return (*this->Internals->GetWriteCount(lock) < 1); -} - -template -bool ArrayHandleDeprecated::CanWrite(const LockType& lock, - const vtkm::cont::Token& token) const -{ - // If the token is already attached to this array, then we allow writing. - if (token.IsAttached(this->Internals->GetWriteCount(lock)) || - token.IsAttached(this->Internals->GetReadCount(lock))) - { - return true; - } - - // If there is anyone else waiting at the top of the queue, we cannot access this array. - auto& queue = this->Internals->GetQueue(lock); - if (!queue.empty() && (queue.front() != token)) - { - return false; - } - - // No one else is waiting, so we can write the array as long as no one else is reading or writing. - return ((*this->Internals->GetWriteCount(lock) < 1) && - (*this->Internals->GetReadCount(lock) < 1)); -} - -template -void ArrayHandleDeprecated::WaitToRead(LockType& lock, vtkm::cont::Token& token) const -{ - this->Enqueue(lock, token); - - // Note that if you deadlocked here, that means that you are trying to do a read operation on an - // array where an object is writing to it. - this->Internals->ConditionVariable.wait( - lock, [&lock, &token, this] { return this->CanRead(lock, token); }); - - token.Attach(this->Internals, - this->Internals->GetReadCount(lock), - lock, - &this->Internals->ConditionVariable); - - // We successfully attached the token. Pop it off the queue. - auto& queue = this->Internals->GetQueue(lock); - if (!queue.empty() && queue.front() == token) - { - queue.pop_front(); - } -} - -template -void ArrayHandleDeprecated::WaitToWrite(LockType& lock, - vtkm::cont::Token& token, - bool fakeRead) const -{ - this->Enqueue(lock, token); - - // Note that if you deadlocked here, that means that you are trying to do a write operation on an - // array where an object is reading or writing to it. - this->Internals->ConditionVariable.wait( - lock, [&lock, &token, this] { return this->CanWrite(lock, token); }); - - if (!fakeRead) - { - token.Attach(this->Internals, - this->Internals->GetWriteCount(lock), - lock, - &this->Internals->ConditionVariable); - } - else - { - // A current feature limitation of ArrayHandle is that it can only exist on one device at - // a time. Thus, if a read request comes in for a different device, the prepare has to - // get satisfy a write lock to boot the array off the existing device. However, we don't - // want to attach the Token as a write lock because the resulting state is for reading only - // and others might also want to read. So, we have to pretend that this is a read lock even - // though we have to make a change to the array. - // - // The main point is, this condition is a hack that should go away once ArrayHandle supports - // multiple devices at once. - token.Attach(this->Internals, - this->Internals->GetReadCount(lock), - lock, - &this->Internals->ConditionVariable); - } - - // We successfully attached the token. Pop it off the queue. - auto& queue = this->Internals->GetQueue(lock); - if (!queue.empty() && queue.front() == token) - { - queue.pop_front(); - } -} - -template -void ArrayHandleDeprecated::Enqueue(const vtkm::cont::Token& token) const -{ - LockType lock = this->GetLock(); - this->Enqueue(lock, token); -} - -template -void ArrayHandleDeprecated::Enqueue(const LockType& lock, - const vtkm::cont::Token& token) const -{ - if (token.IsAttached(this->Internals->GetWriteCount(lock)) || - token.IsAttached(this->Internals->GetReadCount(lock))) - { - // Do not need to enqueue if we are already attached. - return; - } - - auto& queue = this->Internals->GetQueue(lock); - if (std::find(queue.begin(), queue.end(), token.GetReference()) != queue.end()) - { - // This token is already in the queue. - return; - } - - this->Internals->GetQueue(lock).push_back(token.GetReference()); -} - -// This macro is used to declare an ArrayHandle that uses the old, deprecated style of Storage -// that leverages ArrayTransfer. This macro will go away once all deprecated ArrayHandles -// that use it are replaced with the new style. To use this macro, first have a declaration -// of the template and then put the macro like this: -// -// template -// VTKM_ARRAY_HANDLE_DEPRECATED(T, vtkm::cont::StorageTagFoo); -// -// Don't forget to use VTKM_PASS_COMMAS if one of the macro arguments contains -// a template with multiple parameters. -#define VTKM_ARRAY_HANDLE_DEPRECATED(ValueType_, StorageTag_) \ - class VTKM_ALWAYS_EXPORT ArrayHandle \ - : public internal::ArrayHandleDeprecated \ - { \ - using Superclass = internal::ArrayHandleDeprecated; \ - \ - public: \ - VTKM_CONT \ - ArrayHandle() \ - : Superclass() \ - { \ - } \ - \ - VTKM_CONT \ - ArrayHandle(const ArrayHandle& src) \ - : Superclass(src) \ - { \ - } \ - \ - VTKM_CONT \ - ArrayHandle(ArrayHandle&& src) noexcept \ - : Superclass(std::move(src)) \ - { \ - } \ - \ - VTKM_CONT \ - ArrayHandle(const internal::ArrayHandleDeprecated& src) \ - : Superclass(src) \ - { \ - } \ - \ - VTKM_CONT \ - ArrayHandle(internal::ArrayHandleDeprecated&& src) noexcept \ - : Superclass(std::move(src)) \ - { \ - } \ - \ - VTKM_CONT ArrayHandle(const internal::Storage& storage) \ - : Superclass(storage) \ - { \ - } \ - \ - VTKM_CONT ArrayHandle(internal::Storage&& storage) \ - : Superclass(std::move(storage)) \ - { \ - } \ - \ - VTKM_CONT ArrayHandle(const vtkm::cont::internal::Buffer* buffers) \ - : Superclass(buffers) \ - { \ - } \ - \ - VTKM_CONT ArrayHandle(const std::vector& buffers) \ - : Superclass(buffers.data()) \ - { \ - } \ - \ - VTKM_CONT \ - ArrayHandle& operator=( \ - const ArrayHandle& src) \ - { \ - this->Superclass::operator=(src); \ - return *this; \ - } \ - \ - VTKM_CONT \ - ArrayHandle& operator=( \ - ArrayHandle&& src) noexcept \ - { \ - this->Superclass::operator=(std::move(src)); \ - return *this; \ - } \ - \ - VTKM_CONT ~ArrayHandle() {} \ - } - -} -} -} // namespace vtkm::cont::internal - -#endif //vtk_m_cont_internal_ArrayHandleDeprecated_h diff --git a/vtkm/cont/internal/AtomicInterfaceControl.h b/vtkm/cont/internal/AtomicInterfaceControl.h deleted file mode 100644 index 42c2b4368..000000000 --- a/vtkm/cont/internal/AtomicInterfaceControl.h +++ /dev/null @@ -1,81 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_AtomicInterfaceControl_h -#define vtk_m_cont_internal_AtomicInterfaceControl_h - -#include -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -struct VTKM_DEPRECATED(1.6, "Use the functions in vtkm/Atomic.h.") AtomicInterfaceControl -{ - using WordTypes = vtkm::AtomicTypesSupported; - using WordTypePreferred = vtkm::AtomicTypePreferred; - - template - VTKM_EXEC_CONT static T Load(const T* addr) - { - return vtkm::AtomicLoad(addr); - } - - template - VTKM_EXEC_CONT static void Store(T* addr, T value) - { - vtkm::AtomicStore(addr, value); - } - - template - VTKM_EXEC_CONT static T Add(T* addr, T arg) - { - return vtkm::AtomicAdd(addr, arg); - } - - template - VTKM_EXEC_CONT static T Not(T* addr) - { - return vtkm::AtomicNot(addr); - } - - template - VTKM_EXEC_CONT static T And(T* addr, T mask) - { - return vtkm::AtomicAnd(addr, mask); - } - - template - VTKM_EXEC_CONT static T Or(T* addr, T mask) - { - return vtkm::AtomicOr(addr, mask); - } - - template - VTKM_EXEC_CONT static T Xor(T* addr, T mask) - { - return vtkm::AtomicXor(addr, mask); - } - - template - VTKM_EXEC_CONT static T CompareAndSwap(T* addr, T newWord, T expected) - { - vtkm::AtomicCompareExchange(addr, &expected, newWord); - return expected; - } -}; -} -} -} // end namespace vtkm::cont::internal - -#endif // vtk_m_cont_internal_AtomicInterfaceControl_h diff --git a/vtkm/cont/internal/AtomicInterfaceExecution.h b/vtkm/cont/internal/AtomicInterfaceExecution.h deleted file mode 100644 index c179522a2..000000000 --- a/vtkm/cont/internal/AtomicInterfaceExecution.h +++ /dev/null @@ -1,82 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_AtomicInterfaceExecution_h -#define vtk_m_cont_internal_AtomicInterfaceExecution_h - -#include -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -template -struct VTKM_DEPRECATED(1.6, "Use the functions in vtkm/Atomic.h.") AtomicInterfaceExecution -{ - using WordTypes = vtkm::AtomicTypesSupported; - using WordTypePreferred = vtkm::AtomicTypePreferred; - - template - VTKM_EXEC_CONT static T Load(const T* addr) - { - return vtkm::AtomicLoad(addr); - } - - template - VTKM_EXEC_CONT static void Store(T* addr, T value) - { - vtkm::AtomicStore(addr, value); - } - - template - VTKM_EXEC_CONT static T Add(T* addr, T arg) - { - return vtkm::AtomicAdd(addr, arg); - } - - template - VTKM_EXEC_CONT static T Not(T* addr) - { - return vtkm::AtomicNot(addr); - } - - template - VTKM_EXEC_CONT static T And(T* addr, T mask) - { - return vtkm::AtomicAnd(addr, mask); - } - - template - VTKM_EXEC_CONT static T Or(T* addr, T mask) - { - return vtkm::AtomicOr(addr, mask); - } - - template - VTKM_EXEC_CONT static T Xor(T* addr, T mask) - { - return vtkm::AtomicXor(addr, mask); - } - - template - VTKM_EXEC_CONT static T CompareAndSwap(T* addr, T newWord, T expected) - { - vtkm::AtomicCompareExchange(addr, &expected, newWord); - return expected; - } -}; -} -} -} // end namespace vtkm::cont::internal - -#endif // vtk_m_cont_internal_AtomicInterfaceExecution_h diff --git a/vtkm/cont/internal/CMakeLists.txt b/vtkm/cont/internal/CMakeLists.txt index cb9223b99..55a05b82a 100644 --- a/vtkm/cont/internal/CMakeLists.txt +++ b/vtkm/cont/internal/CMakeLists.txt @@ -10,12 +10,9 @@ set(headers ArrayCopyUnknown.h - ArrayHandleDeprecated.h ArrayHandleExecutionManager.h ArrayPortalFromIterators.h ArrayTransfer.h - AtomicInterfaceControl.h - AtomicInterfaceExecution.h Buffer.h CastInvalidValue.h CellLocatorBase.h @@ -39,27 +36,12 @@ set(headers RuntimeDeviceConfiguration.h RuntimeDeviceConfigurationOptions.h RuntimeDeviceOption.h - StorageDeprecated.h StorageError.h - Variant.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - TransferInfo.h - VirtualObjectTransfer.h - VirtualObjectTransferInstantiate.h - VirtualObjectTransferShareWithControl.h - ) -endif() - vtkm_declare_headers(${headers}) # These source files are actually compiled in the parent directory. # They are in a separate directory to highlight which objects are # internal and which are part of the external interface. #add_custom_target(vtkmContInternal ALL DEPENDS vtkmCont) - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/cont/internal/CellLocatorBase.h b/vtkm/cont/internal/CellLocatorBase.h index 5f0f9b0f8..8b9a72545 100644 --- a/vtkm/cont/internal/CellLocatorBase.h +++ b/vtkm/cont/internal/CellLocatorBase.h @@ -17,13 +17,6 @@ #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -// To support deprecated implementation -#include -#include -#include -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - namespace vtkm { namespace cont @@ -31,102 +24,6 @@ namespace cont namespace internal { -namespace detail -{ - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN - -// Wrong namespace, but it's only for deprecated code. -template -class VTKM_ALWAYS_EXPORT CellLocatorBaseExecWrapper : public vtkm::exec::CellLocator -{ - LocatorType Locator; - -public: - VTKM_CONT CellLocatorBaseExecWrapper(const LocatorType& locator) - : Locator(locator) - { - } - - VTKM_EXEC_CONT virtual ~CellLocatorBaseExecWrapper() noexcept override - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, - vtkm::Id& cellId, - vtkm::Vec3f& parametric) const override - { - return this->Locator.FindCell(point, cellId, parametric); - } -}; - -template -struct CellLocatorBaseWrapperPrepareForExecutionFunctor -{ - template - VTKM_CONT bool operator()(Device device, - vtkm::cont::VirtualObjectHandle& execHandle, - const LocatorType& locator, - vtkm::cont::Token& token) - { - auto execObject = locator.PrepareForExecution(device, token); - using WrapType = CellLocatorBaseExecWrapper; - execHandle.Reset(new WrapType(execObject)); - return true; - } -}; - -template -class VTKM_ALWAYS_EXPORT CellLocatorBaseWrapper : public vtkm::cont::CellLocator -{ - Derived Locator; - mutable vtkm::cont::VirtualObjectHandle ExecutionObjectHandle; - -public: - CellLocatorBaseWrapper() = default; - - CellLocatorBaseWrapper(const Derived& locator) - : Locator(locator) - { - this->SetCellSet(locator.GetCellSet()); - this->SetCoordinates(locator.GetCoordinates()); - } - - VTKM_CONT const vtkm::exec::CellLocator* PrepareForExecution( - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const override - { - bool success = - vtkm::cont::TryExecuteOnDevice(device, - CellLocatorBaseWrapperPrepareForExecutionFunctor{}, - this->ExecutionObjectHandle, - this->Locator, - token); - if (!success) - { - throwFailedRuntimeDeviceTransfer("CellLocatorUniformGrid", device); - } - return this->ExecutionObjectHandle.PrepareForExecution(device, token); - } - -private: - void Build() override - { - this->Locator.SetCellSet(this->GetCellSet()); - this->Locator.SetCoordinates(this->GetCoordinates()); - this->Locator.Update(); - } -}; - -VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - - -} // namespace detail - /// \brief Base class for all `CellLocator` classes. /// /// `CellLocatorBase` uses the curiously recurring template pattern (CRTP). Subclasses @@ -141,16 +38,6 @@ class VTKM_ALWAYS_EXPORT CellLocatorBase : public vtkm::cont::ExecutionObjectBas mutable bool Modified = true; public: -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - // Support deprecated classes - operator detail::CellLocatorBaseWrapper() const - { - return detail::CellLocatorBaseWrapper(reinterpret_cast(*this)); - } - VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - const vtkm::cont::UnknownCellSet& GetCellSet() const { return this->CellSet; } void SetCellSet(const vtkm::cont::UnknownCellSet& cellSet) @@ -176,15 +63,6 @@ public: } } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object.") - vtkm::cont::internal::ExecutionObjectType PrepareForExecution( - Device device) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); - } - protected: void SetModified() { this->Modified = true; } bool GetModified() const { return this->Modified; } diff --git a/vtkm/cont/internal/OptionParserArguments.h b/vtkm/cont/internal/OptionParserArguments.h index 582264ffe..81212b8f6 100644 --- a/vtkm/cont/internal/OptionParserArguments.h +++ b/vtkm/cont/internal/OptionParserArguments.h @@ -33,10 +33,6 @@ enum OptionIndex DEVICE, LOGLEVEL, // not parsed by this parser, but by loguru - // TODO: remove deprecated arguments on next vtk-m release - DEPRECATED_DEVICE, - DEPRECATED_LOGLEVEL, - // All RuntimeDeviceConfiguration specific options NUM_THREADS, NUMA_REGIONS, diff --git a/vtkm/cont/internal/PointLocatorBase.h b/vtkm/cont/internal/PointLocatorBase.h index 2330f35cb..3d5376011 100644 --- a/vtkm/cont/internal/PointLocatorBase.h +++ b/vtkm/cont/internal/PointLocatorBase.h @@ -16,12 +16,6 @@ #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#include -#include -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - namespace vtkm { namespace cont @@ -29,100 +23,6 @@ namespace cont namespace internal { -namespace detail -{ - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN - -// Wrong namespace, but it's only for deprecated code. -template -class VTKM_ALWAYS_EXPORT PointLocatorBaseExecWrapper : public vtkm::exec::PointLocator -{ - LocatorType Locator; - -public: - VTKM_CONT PointLocatorBaseExecWrapper(const LocatorType& locator) - : Locator(locator) - { - } - - VTKM_EXEC_CONT virtual ~PointLocatorBaseExecWrapper() noexcept override - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC void FindNearestNeighbor(const vtkm::Vec3f& queryPoint, - vtkm::Id& pointId, - vtkm::FloatDefault& distanceSquared) const override - { - return this->Locator.FindNearestNeighbor(queryPoint, pointId, distanceSquared); - } -}; - -template -struct PointLocatorBaseWrapperPrepareForExecutionFunctor -{ - template - VTKM_CONT bool operator()(Device device, - vtkm::cont::VirtualObjectHandle& execHandle, - const LocatorType& locator, - vtkm::cont::Token& token) - { - auto execObject = locator.PrepareForExecution(device, token); - using WrapType = PointLocatorBaseExecWrapper; - execHandle.Reset(new WrapType(execObject)); - return true; - } -}; - -template -class VTKM_ALWAYS_EXPORT PointLocatorBaseWrapper : public vtkm::cont::PointLocator -{ - Derived Locator; - mutable vtkm::cont::VirtualObjectHandle ExecutionObjectHandle; - -public: - PointLocatorBaseWrapper() = default; - - PointLocatorBaseWrapper(const Derived& locator) - : Locator(locator) - { - this->SetCoordinates(locator.GetCoordinates()); - } - - VTKM_CONT const vtkm::exec::PointLocator* PrepareForExecution( - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) const override - { - const bool success = - vtkm::cont::TryExecuteOnDevice(device, - PointLocatorBaseWrapperPrepareForExecutionFunctor{}, - this->ExecutionObjectHandle, - this->Locator, - token); - if (!success) - { - throwFailedRuntimeDeviceTransfer("PointLocatorWrapper", device); - } - return this->ExecutionObjectHandle.PrepareForExecution(device, token); - } - -private: - void Build() override - { - this->Locator.SetCoordinates(this->GetCoordinates()); - this->Locator.Update(); - } -}; - -VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - - -} // namespace detail - /// \brief Base class for all `PointLocator` classes. /// /// `PointLocatorBase` uses the curiously recurring template pattern (CRTP). Subclasses @@ -133,16 +33,6 @@ template class VTKM_ALWAYS_EXPORT PointLocatorBase : public vtkm::cont::ExecutionObjectBase { public: -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - // Support deprecated classes - operator detail::PointLocatorBaseWrapper() const - { - return detail::PointLocatorBaseWrapper(reinterpret_cast(*this)); - } - VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - vtkm::cont::CoordinateSystem GetCoordinates() const { return this->Coords; } void SetCoordinates(const vtkm::cont::CoordinateSystem& coords) { @@ -159,15 +49,6 @@ public: } } - template - VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForExecution now requires a vtkm::cont::Token object") - const vtkm::cont::internal::ExecutionObjectType PrepareForExecution( - Device device) const - { - vtkm::cont::Token token; - return this->PrepareForExecution(device, token); - } - protected: void SetModified() { this->Modified = true; } bool GetModified() const { return this->Modified; } diff --git a/vtkm/cont/internal/StorageDeprecated.h b/vtkm/cont/internal/StorageDeprecated.h deleted file mode 100644 index 96bf16a8a..000000000 --- a/vtkm/cont/internal/StorageDeprecated.h +++ /dev/null @@ -1,226 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_StorageDeprecated_h -#define vtk_m_cont_internal_StorageDeprecated_h - -#include -#include -#include -#include -#include - -#include - -#include - -namespace vtkm -{ -namespace cont -{ - -namespace internal -{ - -template -class ArrayHandleDeprecated; - -namespace detail -{ - -struct TryPrepareInput -{ - template - VTKM_CONT bool operator()(Device device, - ArrayType&& array, - vtkm::cont::Token& token, - typename ArrayType::ReadPortalType& portal, - bool& created) const - { - if (!created) - { - portal = array.PrepareForInput(device, token); - created = true; - } - return true; - } -}; - -struct TryPrepareInPlace -{ - template - VTKM_CONT bool operator()(Device device, - ArrayType&& array, - vtkm::cont::Token& token, - typename ArrayType::WritePortalType& portal, - bool& created) const - { - if (!created) - { - portal = array.PrepareForInPlace(device, token); - created = true; - } - return true; - } -}; - -template -struct StorageTemplateParams; - -template -struct StorageTemplateParams> -{ - using ValueType = T; - using StorageTag = S; -}; - -} // namespace detail - -/// \brief `Storage` handler for `ArrayHandle` types still using old `ArrayHandle` style. -/// -/// A recent change to `ArrayHandle` moved from using the `ArrayTransfer` method for -/// moving data from control to execution environments to using `Buffer` objects. One -/// feature of the `Buffer` objects is that if you have a new style `ArrayHandle` that -/// deprecates other `ArrayHandle`s, they both have to use `Buffer`. -/// -/// All old-style `ArrayHandle`s that still use `ArrayTransfer` should have a -/// `VTKM_STORAGE_OLD_STYLE;` declaration at the bottom of the `Storage` class. -/// -template -class StorageDeprecated -{ - using T = typename detail::StorageTemplateParams::ValueType; - using StorageTag = typename detail::StorageTemplateParams::StorageTag; - - using ArrayType = vtkm::cont::internal::ArrayHandleDeprecated; - - VTKM_CONT static ArrayType GetArray(const std::vector& buffers) - { - return buffers[0].GetMetaData(); - } - -public: - VTKM_CONT static vtkm::Id GetNumberOfValues( - const std::vector& buffers) - { - return GetArray(buffers).GetNumberOfValues(); - } - - VTKM_CONT static void ResizeBuffers(vtkm::Id numValues, - const std::vector& buffers, - vtkm::CopyFlag preserve, - vtkm::cont::Token& token) - { - switch (preserve) - { - case vtkm::CopyFlag::Off: - GetArray(buffers).Allocate(numValues, token); - break; - case vtkm::CopyFlag::On: - GetArray(buffers).Shrink(numValues, token); - break; - } - } - - VTKM_CONT static ReadPortalType CreateReadPortal( - const std::vector& buffers, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) - { - if (device == vtkm::cont::DeviceAdapterTagUndefined{}) - { - return GetArray(buffers).ReadPortal(); - } - else - { - ReadPortalType portal; - bool created = false; - vtkm::cont::TryExecuteOnDevice( - device, detail::TryPrepareInput{}, GetArray(buffers), token, portal, created); - if (!created) - { - throw vtkm::cont::ErrorBadDevice("Failed to create input portal for device " + - device.GetName()); - } - return portal; - } - } - -private: - VTKM_CONT static WritePortalType CreateWritePortalImpl( - const std::vector& buffers, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token, - std::true_type) - { - if (device == vtkm::cont::DeviceAdapterTagUndefined{}) - { - return GetArray(buffers).WritePortal(); - } - else - { - WritePortalType portal; - bool created = false; - vtkm::cont::TryExecuteOnDevice( - device, detail::TryPrepareInPlace{}, GetArray(buffers), token, portal, created); - if (!created) - { - throw vtkm::cont::ErrorBadDevice("Failed to create in place portal for device " + - device.GetName()); - } - return portal; - } - } - - VTKM_CONT static WritePortalType CreateWritePortalImpl( - const std::vector&, - vtkm::cont::DeviceAdapterId, - vtkm::cont::Token&, - std::false_type) - { - throw vtkm::cont::ErrorBadType("Attempted to get a writable portal to a read-only array."); - } - - using SupportsWrite = vtkm::internal::PortalSupportsSets; - -public: - VTKM_CONT static WritePortalType CreateWritePortal( - const std::vector& buffers, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) - { - return CreateWritePortalImpl(buffers, device, token, SupportsWrite{}); - } -}; - -#define VTKM_STORAGE_OLD_STYLE \ -public: \ - using HasOldBridge = std::true_type; \ - using ReadPortalType = PortalConstType; \ - using WritePortalType = PortalType; \ - \ -private: \ - using StorageDeprecated = \ - vtkm::cont::internal::StorageDeprecated; \ - \ -public: \ - VTKM_CONT static vtkm::Id GetNumberOfValues( \ - const std::vector& buffers) \ - { \ - return StorageDeprecated::GetNumberOfValues(buffers); \ - } \ - static constexpr auto& ResizeBuffers = StorageDeprecated::ResizeBuffers; \ - static constexpr auto& CreateReadPortal = StorageDeprecated::CreateReadPortal; \ - static constexpr auto& CreateWritePortal = StorageDeprecated::CreateWritePortal - -} -} -} // namespace vtkm::cont::internal - -#endif //vtk_m_cont_internal_StorageDeprecated_h diff --git a/vtkm/cont/internal/TransferInfo.cxx b/vtkm/cont/internal/TransferInfo.cxx deleted file mode 100644 index 4eeab9e74..000000000 --- a/vtkm/cont/internal/TransferInfo.cxx +++ /dev/null @@ -1,69 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#include - -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -bool TransferInfoArray::valid(vtkm::cont::DeviceAdapterId devId) const noexcept -{ - return this->DeviceId == devId; -} - -void TransferInfoArray::updateHost( - std::unique_ptr&& host) noexcept -{ - this->Host = std::move(host); -} - -void TransferInfoArray::updateDevice(vtkm::cont::DeviceAdapterId devId, - std::unique_ptr&& hostCopy, - const vtkm::internal::PortalVirtualBase* device, - const std::shared_ptr& deviceState) noexcept -{ - this->HostCopyOfDevice = std::move(hostCopy); - this->DeviceId = devId; - this->Device = device; - this->DeviceTransferState = deviceState; -} - -void TransferInfoArray::releaseDevice() -{ - this->DeviceId = vtkm::cont::DeviceAdapterTagUndefined{}; - this->Device = nullptr; //The device transfer state own this pointer - if (this->DeviceTransferState == nullptr) - { //When the DeviceTransferState is a nullptr it means that - //that the device and host share memory. In that case we need to free - //the host copy - this->HostCopyOfDevice.reset(nullptr); - } - else - { - //The DeviceTransferState holds ownership of HostCopyOfDevice so we only - //need to delete DeviceTransferState, as it will do the rest - this->DeviceTransferState = nullptr; //release the device transfer state - this->HostCopyOfDevice.release(); - } -} - -void TransferInfoArray::releaseAll() -{ - this->Host.release(); //we own this pointer so release it - this->releaseDevice(); -} -} -} -} diff --git a/vtkm/cont/internal/TransferInfo.h b/vtkm/cont/internal/TransferInfo.h deleted file mode 100644 index 4d4b22f7b..000000000 --- a/vtkm/cont/internal/TransferInfo.h +++ /dev/null @@ -1,75 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_TransferInfo_h -#define vtk_m_cont_internal_TransferInfo_h - -#include - -#include -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -#include -#include -#include - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -namespace vtkm -{ - -namespace internal -{ -class PortalVirtualBase; -} - -namespace cont -{ -namespace internal -{ - -struct VTKM_CONT_EXPORT TransferInfoArray -{ - bool valid(vtkm::cont::DeviceAdapterId tagValue) const noexcept; - - void updateHost(std::unique_ptr&& host) noexcept; - void updateDevice( - vtkm::cont::DeviceAdapterId id, - std::unique_ptr&& host_copy, //NOT the same as host version - const vtkm::internal::PortalVirtualBase* device, - const std::shared_ptr& state) noexcept; - void releaseDevice(); - void releaseAll(); - - const vtkm::internal::PortalVirtualBase* hostPtr() noexcept { return this->Host.get(); } - const vtkm::internal::PortalVirtualBase* devicePtr() const noexcept { return this->Device; } - vtkm::cont::DeviceAdapterId deviceId() const noexcept { return this->DeviceId; } - - std::shared_ptr& state() noexcept { return this->DeviceTransferState; } - -private: - vtkm::cont::DeviceAdapterId DeviceId = vtkm::cont::DeviceAdapterTagUndefined{}; - std::unique_ptr Host = nullptr; - std::unique_ptr HostCopyOfDevice = nullptr; - const vtkm::internal::PortalVirtualBase* Device = nullptr; - std::shared_ptr DeviceTransferState = nullptr; -}; -} -} -} - -VTKM_DEPRECATED_SUPPRESS_END - -#endif diff --git a/vtkm/cont/internal/VirtualObjectTransfer.cxx b/vtkm/cont/internal/VirtualObjectTransfer.cxx deleted file mode 100644 index 6d784c0c2..000000000 --- a/vtkm/cont/internal/VirtualObjectTransfer.cxx +++ /dev/null @@ -1,63 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include - -#include -#include - -#include -#include - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -VTKM_CONT TransferInterface::~TransferInterface() = default; - -bool TransferState::DeviceIdIsValid(vtkm::cont::DeviceAdapterId deviceId) const -{ - auto index = static_cast(deviceId.GetValue()); - auto size = this->DeviceTransferState.size(); - - if (!this->HostPointer) - { - throw vtkm::cont::ErrorBadValue( - "No virtual object was bound before being asked to be executed"); - } - if (index >= size) - { - std::string msg = "An invalid DeviceAdapter[id=" + std::to_string(deviceId.GetValue()) + - ", name=" + deviceId.GetName() + "] was used when trying to construct a virtual object."; - throw vtkm::cont::ErrorBadType(msg); - } - - if (!this->DeviceTransferState[index]) - { - const std::string msg = - "VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter[id=" + - std::to_string(deviceId.GetValue()) + ", name=" + deviceId.GetName() + - "]. It can't as this VirtualObjectHandle was not constructed/bound with this " - "DeviceAdapter in the list of valid DeviceAdapters."; - throw vtkm::cont::ErrorBadType(msg); - } - - return true; -} -} -} -} - -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/cont/internal/VirtualObjectTransfer.h b/vtkm/cont/internal/VirtualObjectTransfer.h deleted file mode 100644 index 90a27a6e7..000000000 --- a/vtkm/cont/internal/VirtualObjectTransfer.h +++ /dev/null @@ -1,180 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_VirtualObjectTransfer_h -#define vtk_m_cont_internal_VirtualObjectTransfer_h - -#include - -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -// This is a deprecated class. Don't warn about deprecation while implementing -// deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -struct CreateTransferInterface; //forward declare for friendship - -template -struct VTKM_DEPRECATED(1.7, "Virtual methods are no longer supported in the execution environment.") - VirtualObjectTransfer -#ifdef VTKM_DOXYGEN_ONLY -{ - /// A VirtualObjectTransfer is constructed with a pointer to the derived type that (eventually) - /// gets transferred to the execution environment of the given DeviceAdapter. - /// - VTKM_CONT VirtualObjectTransfer(const VirtualDerivedType* virtualObject); - - /// \brief Transfers the virtual object to the execution environment. - /// - /// This method transfers the virtual object to the execution environment and returns a pointer - /// to the object that can be used in the execution environment (but not necessarily the control - /// environment). If the \c updateData flag is true, then the data is always copied to the - /// execution environment (such as if the data were updated since the last call to \c - /// PrepareForExecution). If the \c updateData flag is false and the object was already - /// transferred previously, the previously created object is returned. - /// - VTKM_CONT const VirtualDerivedType* PrepareForExecution(bool updateData); - - /// \brief Frees up any resources in the execution environment. - /// - /// Any previously returned virtual object from \c PrepareForExecution becomes invalid. - /// - VTKM_CONT void ReleaseResources(); -} -#endif -; - -class VTKM_CONT_EXPORT VTKM_DEPRECATED( - 1.7, - "Virtual methods are no longer supported in the execution environment.") TransferInterface -{ -public: - VTKM_CONT virtual ~TransferInterface(); - - VTKM_CONT virtual const vtkm::VirtualObjectBase* PrepareForExecution( - vtkm::Id hostModifiedCount) = 0; - VTKM_CONT virtual void ReleaseResources() = 0; -}; - -template -class TransferInterfaceImpl final : public TransferInterface -{ -public: - VTKM_CONT TransferInterfaceImpl(const VirtualDerivedType* virtualObject) - : LastModifiedCount(-1) - , Transfer(virtualObject) - { - } - - VTKM_CONT const vtkm::VirtualObjectBase* PrepareForExecution(vtkm::Id hostModifiedCount) override - { - bool updateData = (this->LastModifiedCount != hostModifiedCount); - const vtkm::VirtualObjectBase* executionObject = this->Transfer.PrepareForExecution(updateData); - this->LastModifiedCount = hostModifiedCount; - return executionObject; - } - - VTKM_CONT void ReleaseResources() override { this->Transfer.ReleaseResources(); } - -private: - vtkm::Id LastModifiedCount; - vtkm::cont::internal::VirtualObjectTransfer Transfer; -}; - - -struct VTKM_CONT_EXPORT VTKM_DEPRECATED( - 1.7, - "Virtual methods are no longer supported in the execution environment.") TransferState -{ - TransferState() = default; - - ~TransferState() { this->ReleaseResources(); } - - bool DeviceIdIsValid(vtkm::cont::DeviceAdapterId deviceId) const; - - bool WillReleaseHostPointer() const { return this->DeleteFunction != nullptr; } - - - void UpdateHost(vtkm::VirtualObjectBase* host, void (*deleteFunction)(void*)) - { - if (this->HostPointer != host) - { - this->ReleaseResources(); - this->HostPointer = host; - this->DeleteFunction = deleteFunction; - } - } - - void ReleaseResources() - { - this->ReleaseExecutionResources(); - - //This needs to be updated to release all execution information - - if (this->DeleteFunction) - { - this->DeleteFunction(this->HostPointer); - } - this->HostPointer = nullptr; - this->DeleteFunction = nullptr; - } - - void ReleaseExecutionResources() - { - //This needs to be updated to only release the active execution part - for (auto& state : this->DeviceTransferState) - { - if (state) - { - state->ReleaseResources(); - } - } - } - - const vtkm::VirtualObjectBase* PrepareForExecution(vtkm::cont::DeviceAdapterId deviceId) const - { - //make sure the device is up to date - auto index = static_cast(deviceId.GetValue()); - vtkm::Id count = this->HostPointer->GetModifiedCount(); - return this->DeviceTransferState[index]->PrepareForExecution(count); - } - - vtkm::VirtualObjectBase* HostPtr() const { return this->HostPointer; } - -private: - friend struct CreateTransferInterface; - - vtkm::VirtualObjectBase* HostPointer = nullptr; - void (*DeleteFunction)(void*) = nullptr; - - std::array, 8> DeviceTransferState; -}; -} -} -} // vtkm::cont::internal - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtkm_cont_internal_VirtualObjectTransfer_h diff --git a/vtkm/cont/internal/VirtualObjectTransferInstantiate.h b/vtkm/cont/internal/VirtualObjectTransferInstantiate.h deleted file mode 100644 index f52f52e4b..000000000 --- a/vtkm/cont/internal/VirtualObjectTransferInstantiate.h +++ /dev/null @@ -1,42 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_VirtualObjectTransferInstantiate_h -#define vtk_m_cont_internal_VirtualObjectTransferInstantiate_h - -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_FOR_DEVICE(DerivedType, DeviceDapterTagType) \ - template class vtkm::cont::internal::VirtualObjectTransfer - -#if defined(VTKM_ENABLE_CUDA) -#include -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_CUDA(DerivedType) \ - VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_FOR_DEVICE(DerivedType, vtkm::cont::DeviceAdapterTagCuda) -#else // defined(VTKM_ENABLE_CUDA) -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_CUDA(DerivedType) -#endif // defined(VTKM_ENABLE_CUDA) - -#if defined(VTKM_ENABLE_KOKKOS) -#include -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_KOKKOS(DerivedType) \ - VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_FOR_DEVICE(DerivedType, vtkm::cont::DeviceAdapterTagKokkos) -#else // defined(VTKM_ENABLE_KOKKOS) -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_KOKKOS(DerivedType) -#endif // defined(VTKM_ENABLE_KOKKOS) - -#define VTKM_EXPLICITLY_INSTANTIATE_TRANSFER(DerivedType) \ - VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_CUDA(DerivedType) \ - VTKM_EXPLICITLY_INSTANTIATE_TRANSFER_KOKKOS(DerivedType) - -#endif // vtk_m_cont_internal_VirtualObjectTransferInstantiate_h diff --git a/vtkm/cont/internal/VirtualObjectTransferShareWithControl.h b/vtkm/cont/internal/VirtualObjectTransferShareWithControl.h deleted file mode 100644 index d00b7d7f1..000000000 --- a/vtkm/cont/internal/VirtualObjectTransferShareWithControl.h +++ /dev/null @@ -1,49 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_VirtualObjectTransferShareWithControl_h -#define vtk_m_cont_internal_VirtualObjectTransferShareWithControl_h - -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -template -struct VirtualObjectTransferShareWithControl -{ - VTKM_CONT VirtualObjectTransferShareWithControl(const VirtualDerivedType* virtualObject) - : VirtualObject(virtualObject) - { - } - - VTKM_CONT const VirtualDerivedType* PrepareForExecution(bool vtkmNotUsed(updateData)) - { - return this->VirtualObject; - } - - VTKM_CONT void ReleaseResources() {} - -private: - const VirtualDerivedType* VirtualObject; -}; -} -} -} // vtkm::cont::internal - -#endif // vtk_m_cont_internal_VirtualObjectTransferShareWithControl_h diff --git a/vtkm/cont/internal/testing/CMakeLists.txt b/vtkm/cont/internal/testing/CMakeLists.txt deleted file mode 100644 index b9620a763..000000000 --- a/vtkm/cont/internal/testing/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - - -set(unit_tests - UnitTestArrayPortalFromIterators.cxx - UnitTestBuffer.cxx - UnitTestRuntimeConfigurationOptions.cxx - UnitTestIteratorFromArrayPortal.cxx - ) -vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG) diff --git a/vtkm/cont/kokkos/CMakeLists.txt b/vtkm/cont/kokkos/CMakeLists.txt index 2f2e23fdf..c4d18a857 100644 --- a/vtkm/cont/kokkos/CMakeLists.txt +++ b/vtkm/cont/kokkos/CMakeLists.txt @@ -15,8 +15,3 @@ set(headers #----------------------------------------------------------------------------- add_subdirectory(internal) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::kokkos AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/cont/kokkos/DeviceAdapterKokkos.h b/vtkm/cont/kokkos/DeviceAdapterKokkos.h index 76b921839..eb9f12384 100644 --- a/vtkm/cont/kokkos/DeviceAdapterKokkos.h +++ b/vtkm/cont/kokkos/DeviceAdapterKokkos.h @@ -20,9 +20,6 @@ #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL #else // !defined(VTKM_KOKKOS_CUDA) || defined(VTKM_CUDA) diff --git a/vtkm/cont/kokkos/internal/CMakeLists.txt b/vtkm/cont/kokkos/internal/CMakeLists.txt index f003cf2e1..c00a8851d 100644 --- a/vtkm/cont/kokkos/internal/CMakeLists.txt +++ b/vtkm/cont/kokkos/internal/CMakeLists.txt @@ -18,12 +18,6 @@ set(headers RuntimeDeviceConfigurationKokkos.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - VirtualObjectTransferKokkos.h - ) -endif() - vtkm_declare_headers(${headers}) if (TARGET vtkm::kokkos) diff --git a/vtkm/cont/kokkos/internal/VirtualObjectTransferKokkos.h b/vtkm/cont/kokkos/internal/VirtualObjectTransferKokkos.h deleted file mode 100644 index 702846a05..000000000 --- a/vtkm/cont/kokkos/internal/VirtualObjectTransferKokkos.h +++ /dev/null @@ -1,122 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_kokkos_internal_VirtualObjectTransferKokkos_h -#define vtk_m_cont_kokkos_internal_VirtualObjectTransferKokkos_h - -#include -#include - -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -template -struct VirtualObjectTransfer -{ - VTKM_CONT VirtualObjectTransfer(const VirtualDerivedType* virtualObject) - : ControlObject(virtualObject) - , ExecutionObject(nullptr) - { - } - - VTKM_CONT ~VirtualObjectTransfer() { this->ReleaseResources(); } - - VirtualObjectTransfer(const VirtualObjectTransfer&) = delete; - void operator=(const VirtualObjectTransfer&) = delete; - - VTKM_CONT const VirtualDerivedType* PrepareForExecution(bool updateData) - { - if (this->ExecutionObject == nullptr || updateData) - { - // deviceTarget will hold a byte copy of the host object on the device. The virtual table - // will be wrong. - vtkm::cont::kokkos::internal::KokkosViewConstCont hbuffer( - reinterpret_cast(this->ControlObject), sizeof(VirtualDerivedType)); - - auto deviceTarget = static_cast( - vtkm::cont::kokkos::internal::Allocate(sizeof(VirtualDerivedType))); - vtkm::cont::kokkos::internal::KokkosViewExec dbuffer( - reinterpret_cast(deviceTarget), sizeof(VirtualDerivedType)); - Kokkos::deep_copy( - vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), dbuffer, hbuffer); - - if (this->ExecutionObject == nullptr) - { - // Allocate memory for the object that will eventually be a correct copy on the device. - auto executionObjectPtr = this->ExecutionObject = static_cast( - vtkm::cont::kokkos::internal::Allocate(sizeof(VirtualDerivedType))); - // Initialize the device object - Kokkos::RangePolicy policy( - vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, 1); - Kokkos::parallel_for( - "ConstructVirtualObject", policy, KOKKOS_LAMBDA(const int&) { - new (executionObjectPtr) VirtualDerivedType(*deviceTarget); - }); - } - else if (updateData) - { - auto executionObjectPtr = this->ExecutionObject; - // Initialize the device object - Kokkos::RangePolicy policy( - vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, 1); - Kokkos::parallel_for( - "UpdateVirtualObject", policy, KOKKOS_LAMBDA(const int&) { - *executionObjectPtr = *deviceTarget; - }); - } - - vtkm::cont::kokkos::internal::Free(deviceTarget); - } - - return this->ExecutionObject; - } - - VTKM_CONT void ReleaseResources() - { - if (this->ExecutionObject != nullptr) - { - auto executionObjectPtr = this->ExecutionObject; - this->ExecutionObject = nullptr; - - Kokkos::RangePolicy policy( - vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, 1); - Kokkos::parallel_for( - "DeleteVirtualObject", policy, KOKKOS_LAMBDA(const int&) { - executionObjectPtr->~VirtualDerivedType(); - }); - vtkm::cont::kokkos::internal::Free(executionObjectPtr); - } - } - -private: - const VirtualDerivedType* ControlObject; - VirtualDerivedType* ExecutionObject; -}; - -VTKM_DEPRECATED_SUPPRESS_END - -} -} -} // vtkm::cont::internal - -#endif // vtk_m_cont_kokkos_internal_VirtualObjectTransferKokkos_h diff --git a/vtkm/cont/kokkos/vtkm.module b/vtkm/cont/kokkos/vtkm.module new file mode 100644 index 000000000..195c97d17 --- /dev/null +++ b/vtkm/cont/kokkos/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_cont_kokkos +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_worklet + vtkm::kokkos diff --git a/vtkm/cont/openmp/CMakeLists.txt b/vtkm/cont/openmp/CMakeLists.txt index cd89a429a..e0e063ffc 100644 --- a/vtkm/cont/openmp/CMakeLists.txt +++ b/vtkm/cont/openmp/CMakeLists.txt @@ -15,8 +15,3 @@ set(headers add_subdirectory(internal) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::openmp AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/cont/openmp/DeviceAdapterOpenMP.h b/vtkm/cont/openmp/DeviceAdapterOpenMP.h index 235bc0f21..2f7517183 100644 --- a/vtkm/cont/openmp/DeviceAdapterOpenMP.h +++ b/vtkm/cont/openmp/DeviceAdapterOpenMP.h @@ -18,9 +18,6 @@ #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL #endif #endif //vtk_m_cont_openmp_DeviceAdapterOpenMP_h diff --git a/vtkm/cont/openmp/internal/CMakeLists.txt b/vtkm/cont/openmp/internal/CMakeLists.txt index 16c7f06df..0774f6bb6 100644 --- a/vtkm/cont/openmp/internal/CMakeLists.txt +++ b/vtkm/cont/openmp/internal/CMakeLists.txt @@ -21,12 +21,6 @@ set(headers RuntimeDeviceConfigurationOpenMP.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - VirtualObjectTransferOpenMP.h - ) -endif() - vtkm_declare_headers(${headers}) #These sources need to always be built @@ -35,7 +29,7 @@ target_sources(vtkm_cont PRIVATE ) #----------------------------------------------------------------------------- -if (TARGET vtkm::openmp) +if (TARGET vtkm_openmp) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmOpenMP.cxx ${CMAKE_CURRENT_SOURCE_DIR}/ParallelRadixSortOpenMP.cxx diff --git a/vtkm/cont/openmp/internal/VirtualObjectTransferOpenMP.h b/vtkm/cont/openmp/internal/VirtualObjectTransferOpenMP.h deleted file mode 100644 index 97c5a6445..000000000 --- a/vtkm/cont/openmp/internal/VirtualObjectTransferOpenMP.h +++ /dev/null @@ -1,47 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_cont_openmp_internal_VirtualObjectTransferOpenMP_h -#define vtk_m_cont_openmp_internal_VirtualObjectTransferOpenMP_h - -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -template -struct VirtualObjectTransfer final - : VirtualObjectTransferShareWithControl -{ - using VirtualObjectTransferShareWithControl< - VirtualDerivedType>::VirtualObjectTransferShareWithControl; -}; - -VTKM_DEPRECATED_SUPPRESS_END - -} -} -} // vtkm::cont::internal - - - -#endif // vtk_m_cont_openmp_internal_VirtualObjectTransferOpenMP_h diff --git a/vtkm/cont/openmp/vtkm.module b/vtkm/cont/openmp/vtkm.module new file mode 100644 index 000000000..7d8ffdacc --- /dev/null +++ b/vtkm/cont/openmp/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_cont_openmp +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_worklet + vtkm_openmp diff --git a/vtkm/cont/serial/CMakeLists.txt b/vtkm/cont/serial/CMakeLists.txt index 653c4214f..134087ef6 100644 --- a/vtkm/cont/serial/CMakeLists.txt +++ b/vtkm/cont/serial/CMakeLists.txt @@ -15,8 +15,3 @@ set(headers add_subdirectory(internal) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/cont/serial/DeviceAdapterSerial.h b/vtkm/cont/serial/DeviceAdapterSerial.h index d10ff7af5..4c20b8577 100644 --- a/vtkm/cont/serial/DeviceAdapterSerial.h +++ b/vtkm/cont/serial/DeviceAdapterSerial.h @@ -17,9 +17,6 @@ #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL // clang-format on #endif //vtk_m_cont_serial_DeviceAdapterSerial_h diff --git a/vtkm/cont/serial/internal/CMakeLists.txt b/vtkm/cont/serial/internal/CMakeLists.txt index ed935b464..7ec8db7f1 100644 --- a/vtkm/cont/serial/internal/CMakeLists.txt +++ b/vtkm/cont/serial/internal/CMakeLists.txt @@ -16,12 +16,6 @@ set(headers RuntimeDeviceConfigurationSerial.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - VirtualObjectTransferSerial.h - ) -endif() - vtkm_declare_headers(${headers}) target_sources(vtkm_cont PRIVATE diff --git a/vtkm/cont/serial/internal/VirtualObjectTransferSerial.h b/vtkm/cont/serial/internal/VirtualObjectTransferSerial.h deleted file mode 100644 index 5a1b2a941..000000000 --- a/vtkm/cont/serial/internal/VirtualObjectTransferSerial.h +++ /dev/null @@ -1,42 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_serial_internal_VirtualObjectTransferSerial_h -#define vtk_m_cont_serial_internal_VirtualObjectTransferSerial_h - -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -struct VirtualObjectTransfer final - : VirtualObjectTransferShareWithControl -{ - using VirtualObjectTransferShareWithControl< - VirtualDerivedType>::VirtualObjectTransferShareWithControl; -}; -VTKM_DEPRECATED_SUPPRESS_END - -} -} -} // vtkm::cont::internal - -#endif // vtk_m_cont_serial_internal_VirtualObjectTransferSerial_h diff --git a/vtkm/cont/serial/vtkm.module b/vtkm/cont/serial/vtkm.module new file mode 100644 index 000000000..79cfd7a55 --- /dev/null +++ b/vtkm/cont/serial/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_cont_serial +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_worklet diff --git a/vtkm/cont/tbb/CMakeLists.txt b/vtkm/cont/tbb/CMakeLists.txt index 105f33d16..1a703be15 100644 --- a/vtkm/cont/tbb/CMakeLists.txt +++ b/vtkm/cont/tbb/CMakeLists.txt @@ -15,8 +15,3 @@ set(headers add_subdirectory(internal) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::tbb AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/cont/tbb/DeviceAdapterTBB.h b/vtkm/cont/tbb/DeviceAdapterTBB.h index 18a9e46fd..f403ea059 100644 --- a/vtkm/cont/tbb/DeviceAdapterTBB.h +++ b/vtkm/cont/tbb/DeviceAdapterTBB.h @@ -17,9 +17,6 @@ #include #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL #endif #endif //vtk_m_cont_tbb_DeviceAdapterTBB_h diff --git a/vtkm/cont/tbb/internal/CMakeLists.txt b/vtkm/cont/tbb/internal/CMakeLists.txt index 6de7248a8..16a605431 100644 --- a/vtkm/cont/tbb/internal/CMakeLists.txt +++ b/vtkm/cont/tbb/internal/CMakeLists.txt @@ -18,12 +18,6 @@ set(headers RuntimeDeviceConfigurationTBB.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - VirtualObjectTransferTBB.h - ) -endif() - vtkm_declare_headers(${headers} ParallelSortTBB.hxx ) @@ -34,7 +28,7 @@ target_sources(vtkm_cont PRIVATE ) #----------------------------------------------------------------------------- -if (TARGET vtkm::tbb) +if (TARGET vtkm_tbb) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmTBB.cxx ${CMAKE_CURRENT_SOURCE_DIR}/ParallelSortTBB.cxx diff --git a/vtkm/cont/tbb/internal/VirtualObjectTransferTBB.h b/vtkm/cont/tbb/internal/VirtualObjectTransferTBB.h deleted file mode 100644 index cbac0db3a..000000000 --- a/vtkm/cont/tbb/internal/VirtualObjectTransferTBB.h +++ /dev/null @@ -1,44 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_tbb_internal_VirtualObjectTransferTBB_h -#define vtk_m_cont_tbb_internal_VirtualObjectTransferTBB_h - -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -template -struct VirtualObjectTransfer final - : VirtualObjectTransferShareWithControl -{ - using VirtualObjectTransferShareWithControl< - VirtualDerivedType>::VirtualObjectTransferShareWithControl; -}; - -VTKM_DEPRECATED_SUPPRESS_END - -} -} -} // vtkm::cont::internal - -#endif // vtk_m_cont_tbb_internal_VirtualObjectTransferTBB_h diff --git a/vtkm/cont/tbb/vtkm.module b/vtkm/cont/tbb/vtkm.module new file mode 100644 index 000000000..d1aedaafc --- /dev/null +++ b/vtkm/cont/tbb/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_cont_tbb +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_worklet + vtkm_tbb diff --git a/vtkm/cont/testing/CMakeLists.txt b/vtkm/cont/testing/CMakeLists.txt index e74582787..e5711e5ea 100644 --- a/vtkm/cont/testing/CMakeLists.txt +++ b/vtkm/cont/testing/CMakeLists.txt @@ -9,9 +9,6 @@ ##============================================================================ set(headers - ExplicitTestData.h - MakeTestDataSet.h - Testing.h TestingDeviceAdapter.h TestingRuntimeDeviceConfiguration.h TestingSerialization.h @@ -30,9 +27,11 @@ set(unit_tests UnitTestArrayHandleReverse.cxx UnitTestArrayHandleThreadSafety.cxx UnitTestArrayHandleUniformPointCoordinates.cxx - UnitTestArrayHandleVirtual.cxx + UnitTestArrayPortalFromIterators.cxx UnitTestArrayPortalToIterators.cxx + UnitTestBuffer.cxx UnitTestComputeRange.cxx + UnitTestControlSignatureTag.cxx UnitTestContTesting.cxx UnitTestDataSetBuilderCurvilinear.cxx UnitTestDataSetBuilderExplicit.cxx @@ -44,26 +43,29 @@ set(unit_tests UnitTestDataSetUniform.cxx UnitTestDeviceAdapterAlgorithmGeneral.cxx UnitTestDeviceSelectOnThreads.cxx - UnitTestDynamicCellSet.cxx UnitTestError.cxx UnitTestFieldRangeCompute.cxx UnitTestInitialize.cxx + UnitTestIteratorFromArrayPortal.cxx UnitTestLateDeallocate.cxx UnitTestLogging.cxx UnitTestMergePartitionedDataSet.cxx UnitTestMoveConstructors.cxx UnitTestPartitionedDataSet.cxx + UnitTestRuntimeConfigurationOptions.cxx UnitTestRuntimeDeviceInformation.cxx UnitTestRuntimeDeviceNames.cxx UnitTestScopedRuntimeDeviceTracker.cxx UnitTestStorageList.cxx - UnitTestStorageListTag.cxx UnitTestTimer.cxx UnitTestToken.cxx UnitTestTryExecute.cxx + UnitTestTypeCheckArray.cxx + UnitTestTypeCheckCellSet.cxx + UnitTestTypeCheckExecObject.cxx + UnitTestTypeCheckKeys.cxx UnitTestUnknownArrayHandle.cxx UnitTestUnknownCellSet.cxx - UnitTestVariantArrayHandle.cxx ) set(unit_tests_device @@ -93,12 +95,12 @@ set(unit_tests_device UnitTestBitField.cxx UnitTestCellLocatorChooser.cxx UnitTestCellLocatorGeneral.cxx + UnitTestCellLocatorPartitioned.cxx UnitTestCellLocatorRectilinearGrid.cxx - UnitTestCellLocatorTwoLevel.cxx UnitTestCellLocatorUniformGrid.cxx + UnitTestCellLocatorUnstructured.cxx UnitTestCellSet.cxx UnitTestCellSetExplicit.cxx - UnitTestCellSetExtrude.cxx UnitTestCellSetPermutation.cxx UnitTestColorTable.cxx UnitTestDataSetPermutation.cxx @@ -107,39 +109,26 @@ set(unit_tests_device UnitTestImplicitFunction.cxx UnitTestParticleArrayCopy.cxx UnitTestPointLocatorSparseGrid.cxx + UnitTestTransportArrayIn.cxx + UnitTestTransportArrayInOut.cxx + UnitTestTransportArrayOut.cxx + UnitTestTransportCellSetIn.cxx + UnitTestTransportExecObject.cxx + UnitTestTransportWholeArray.cxx ) - -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) +if(TARGET vtkm_filter_field_conversion) list(APPEND unit_tests_device - UnitTestVirtualObjectHandle.cxx + UnitTestCellSetExtrude.cxx ) endif() -set(library_sources - TestEqualArrayHandles.cxx - Testing.cxx - ) - -set(library_sources_device - ) - -vtkm_library( - NAME vtkm_cont_testing - SOURCES ${library_sources} - DEVICE_SOURCES ${library_sources_device} - HEADERS ${headers} - ) -target_link_libraries(vtkm_cont_testing PUBLIC vtkm_cont vtkm_worklet) - -if(VTKm_ENABLE_TESTING) - vtkm_unit_tests(SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device}) +vtkm_unit_tests(SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device}) #add distributed tests i.e.test to run with MPI #if MPI is enabled. - set(mpi_unit_tests - UnitTestFieldRangeGlobalCompute.cxx - UnitTestSerializationArrayHandle.cxx - UnitTestSerializationDataSet.cxx - ) - vtkm_unit_tests(MPI SOURCES ${mpi_unit_tests}) -endif() +set(mpi_unit_tests + UnitTestFieldRangeGlobalCompute.cxx + UnitTestSerializationArrayHandle.cxx + UnitTestSerializationDataSet.cxx + ) +vtkm_unit_tests(MPI SOURCES ${mpi_unit_tests}) diff --git a/vtkm/cont/testing/MakeTestDataSet.h b/vtkm/cont/testing/MakeTestDataSet.h index 9f5952ea5..0cc41d1ad 100644 --- a/vtkm/cont/testing/MakeTestDataSet.h +++ b/vtkm/cont/testing/MakeTestDataSet.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include @@ -25,7 +25,7 @@ namespace cont namespace testing { -class VTKM_CONT_EXPORT MakeTestDataSet +class VTKM_CONT_TESTING_EXPORT MakeTestDataSet { public: // 1D uniform datasets. diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 0c0ec6ff4..cef170d1b 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -24,7 +24,11 @@ #include #include -#include +// Because the testing directory is reserved for test executables and not +// libraries, the vtkm_cont_testing module has to put this file in +// vtkm/cont/testlib instead of vtkm/cont/testing where you normally would +// expect it. +#include #include #include diff --git a/vtkm/cont/testing/TestingDeviceAdapter.h b/vtkm/cont/testing/TestingDeviceAdapter.h index 944930e7a..02bf1668a 100644 --- a/vtkm/cont/testing/TestingDeviceAdapter.h +++ b/vtkm/cont/testing/TestingDeviceAdapter.h @@ -31,10 +31,6 @@ #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL - #include #include @@ -340,45 +336,6 @@ public: vtkm::exec::AtomicArrayExecutionObject AArray; }; -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - - class VirtualObjectTransferKernel - { - public: - struct Interface : public vtkm::VirtualObjectBase - { - VTKM_EXEC virtual vtkm::Id Foo() const = 0; - }; - - struct Concrete : public Interface - { - VTKM_EXEC vtkm::Id Foo() const override { return this->Value; } - - vtkm::Id Value = 0; - }; - - VirtualObjectTransferKernel(const Interface* vo, - IdArrayHandle& result, - vtkm::cont::Token& token) - : Virtual(vo) - , Result(result.PrepareForInPlace(DeviceAdapterTag(), token)) - { - } - - VTKM_EXEC - void operator()(vtkm::Id) const { this->Result.Set(0, this->Virtual->Foo()); } - - VTKM_CONT void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer&) {} - - private: - const Interface* Virtual; - IdPortalType Result; - }; - - VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - struct CustomPairOp { using ValueType = vtkm::Pair; @@ -612,49 +569,6 @@ private: } } -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - - VTKM_CONT - static void TestVirtualObjectTransfer() - { - std::cout << "-------------------------------------------" << std::endl; - std::cout << "Testing VirtualObjectTransfer" << std::endl; - - using BaseType = typename VirtualObjectTransferKernel::Interface; - using TargetType = typename VirtualObjectTransferKernel::Concrete; - using Transfer = vtkm::cont::internal::VirtualObjectTransfer; - - IdArrayHandle result; - result.Allocate(1); - result.WritePortal().Set(0, 0); - - TargetType target; - target.Value = 5; - - Transfer transfer(&target); - const BaseType* base = static_cast(transfer.PrepareForExecution(false)); - - { - vtkm::cont::Token token; - Algorithm::Schedule(VirtualObjectTransferKernel(base, result, token), 1); - } - VTKM_TEST_ASSERT(result.ReadPortal().Get(0) == 5, "Did not get expected result"); - - { - vtkm::cont::Token token; - target.Value = 10; - base = static_cast(transfer.PrepareForExecution(true)); - Algorithm::Schedule(VirtualObjectTransferKernel(base, result, token), 1); - } - VTKM_TEST_ASSERT(result.ReadPortal().Get(0) == 10, "Did not get expected result"); - - transfer.ReleaseResources(); - } - - VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - static VTKM_CONT void TestAlgorithmSchedule() { std::cout << "-------------------------------------------" << std::endl; @@ -3027,10 +2941,6 @@ private: TestOutOfMemory(); TestTimer(); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - TestVirtualObjectTransfer(); -#endif //VTKM_NO_DEPRECATED_VIRTUAL - TestAlgorithmSchedule(); TestErrorExecution(); diff --git a/vtkm/cont/testing/UnitTestArrayCopy.cxx b/vtkm/cont/testing/UnitTestArrayCopy.cxx index b913d3328..4526f638b 100644 --- a/vtkm/cont/testing/UnitTestArrayCopy.cxx +++ b/vtkm/cont/testing/UnitTestArrayCopy.cxx @@ -147,7 +147,7 @@ void TryCopy() { std::cout << "view -> basic" << std::endl; vtkm::cont::ArrayHandle input = MakeInputArray(); - auto viewInput = vtkm::cont::make_ArrayHandleView(input, 1, ARRAY_SIZE / 2); + vtkm::cont::make_ArrayHandleView(input, 1, ARRAY_SIZE / 2); vtkm::cont::ArrayHandle output; vtkm::cont::ArrayCopy(input, output); TestValues(input, output); diff --git a/vtkm/cont/testing/UnitTestArrayHandleVirtual.cxx b/vtkm/cont/testing/UnitTestArrayHandleVirtual.cxx deleted file mode 100644 index 7876f088f..000000000 --- a/vtkm/cont/testing/UnitTestArrayHandleVirtual.cxx +++ /dev/null @@ -1,267 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#include -#endif - -#include - -#include -#include - -#include - -#include - -#include - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace UnitTestArrayHandleVirtualDetail -{ - -template -struct Test -{ - static constexpr vtkm::Id ARRAY_SIZE = 100; - static constexpr vtkm::Id NUM_KEYS = 3; - - using ArrayHandle = vtkm::cont::ArrayHandle; - using VirtHandle = vtkm::cont::ArrayHandleVirtual; - using DeviceTag = vtkm::cont::DeviceAdapterTagSerial; - using Algorithm = vtkm::cont::DeviceAdapterAlgorithm; - - void TestConstructors() - { - std::cout << "Constructors" << std::endl; - - VirtHandle nullStorage; - VTKM_TEST_ASSERT(nullStorage.GetStorage().GetStorageVirtual() == nullptr, - "storage should be empty when using ArrayHandleVirtual()."); - - VirtHandle fromArrayHandle{ ArrayHandle{} }; - VTKM_TEST_ASSERT(fromArrayHandle.GetStorage().GetStorageVirtual() != nullptr, - "storage should be empty when using ArrayHandleVirtual()."); - VTKM_TEST_ASSERT(vtkm::cont::IsType(fromArrayHandle), - "ArrayHandleVirtual should contain a ArrayHandle."); - - VirtHandle fromVirtHandle(fromArrayHandle); - VTKM_TEST_ASSERT(fromVirtHandle.GetStorage().GetStorageVirtual() != nullptr, - "storage should be empty when using ArrayHandleVirtual()."); - VTKM_TEST_ASSERT(vtkm::cont::IsType(fromVirtHandle), - "ArrayHandleVirtual should contain a ArrayHandle."); - - VirtHandle fromNullPtrHandle(nullStorage); - VTKM_TEST_ASSERT(fromNullPtrHandle.GetStorage().GetStorageVirtual() == nullptr, - "storage should be empty when constructing from a ArrayHandleVirtual that has " - "nullptr storage."); - VTKM_TEST_ASSERT((vtkm::cont::IsType(fromNullPtrHandle) == false), - "ArrayHandleVirtual shouldn't match any type with nullptr storage."); - } - - - void TestMoveConstructors() - { - std::cout << "Move constructors" << std::endl; - - //test ArrayHandle move constructor - { - ArrayHandle handle; - VirtHandle virt(std::move(handle)); - VTKM_TEST_ASSERT( - vtkm::cont::IsType(virt), - "ArrayHandleVirtual should be valid after move constructor ArrayHandle."); - } - - //test ArrayHandleVirtual move constructor - { - ArrayHandle handle; - VirtHandle virt(std::move(handle)); - VirtHandle virt2(std::move(virt)); - VTKM_TEST_ASSERT( - vtkm::cont::IsType(virt2), - "ArrayHandleVirtual should be valid after move constructor ArrayHandleVirtual."); - } - } - - void TestAssignmentOps() - { - std::cout << "Assignment operators" << std::endl; - - //test assignment operator from ArrayHandleVirtual - { - VirtHandle virt; - virt = VirtHandle{ ArrayHandle{} }; - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "ArrayHandleVirtual should be valid after assignment op from AHV."); - } - - //test assignment operator from ArrayHandle - { - VirtHandle virt = vtkm::cont::ArrayHandleCounting{}; - virt = ArrayHandle{}; - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "ArrayHandleVirtual should be valid after assignment op from AH."); - } - - //test move assignment operator from ArrayHandleVirtual - { - VirtHandle temp{ ArrayHandle{} }; - VirtHandle virt; - virt = std::move(temp); - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "ArrayHandleVirtual should be valid after move assignment op from AHV."); - } - - //test move assignment operator from ArrayHandle - { - vtkm::cont::ArrayHandleCounting temp; - VirtHandle virt; - virt = std::move(temp); - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "ArrayHandleVirtual should be valid after move assignment op from AH."); - } - } - - void TestPrepareForExecution() - { - std::cout << "Prepare for execution" << std::endl; - - vtkm::cont::ArrayHandle handle; - handle.Allocate(ARRAY_SIZE); - - VirtHandle virt(std::move(handle)); - - try - { - vtkm::cont::Token token; - virt.PrepareForInput(DeviceTag(), token); - virt.PrepareForInPlace(DeviceTag(), token); - virt.PrepareForOutput(ARRAY_SIZE, DeviceTag(), token); - } - catch (vtkm::cont::ErrorBadValue&) - { - // un-expected failure. - VTKM_TEST_FAIL( - "Unexpected error when using Prepare* on an ArrayHandleVirtual with StorageAny."); - } - } - - - void TestIsType() - { - std::cout << "IsType" << std::endl; - - vtkm::cont::ArrayHandle handle; - VirtHandle virt(std::move(handle)); - - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "virt should by same type as decltype(virt)"); - VTKM_TEST_ASSERT(vtkm::cont::IsType(virt), - "virt should by same type as decltype(handle)"); - - vtkm::cont::ArrayHandle> vecHandle; - VTKM_TEST_ASSERT(!vtkm::cont::IsType(virt), - "virt shouldn't by same type as decltype(vecHandle)"); - } - - void TestCast() - { - std::cout << "Cast" << std::endl; - - vtkm::cont::ArrayHandle handle; - VirtHandle virt(handle); - - auto c1 = vtkm::cont::Cast(virt); - VTKM_TEST_ASSERT(c1 == virt, "virt should cast to VirtHandle"); - - auto c2 = vtkm::cont::Cast(virt); - VTKM_TEST_ASSERT(c2 == handle, "virt should cast to HandleType"); - - using VecHandle = vtkm::cont::ArrayHandle>; - try - { - auto c3 = vtkm::cont::Cast(virt); - VTKM_TEST_FAIL("Cast of T to Vec should have failed"); - } - catch (vtkm::cont::ErrorBadType&) - { - } - } - - void TestControlPortalLocking() - { - std::cout << "Control portal locking" << std::endl; - - // There was a bug where a control portal was not relinquished and it locked the - // ArrayHandle from further use. - - ArrayHandle concreteArray; - concreteArray.Allocate(ARRAY_SIZE); - - VirtHandle virtualArray(concreteArray); - - // Make sure you can write to the virtualArray and then read the data from the concreteArray - // without the concreteArray getting locked up. - SetPortal(virtualArray.WritePortal()); - CheckPortal(concreteArray.ReadPortal()); - - // Make sure you can read from the virtualArray and the write to the concreteArray without - // the concreteArray getting locked up. - CheckPortal(virtualArray.ReadPortal()); - SetPortal(concreteArray.WritePortal()); - } - - void operator()() - { - std::cout << std::endl; - std::cout << "### Testing for " << vtkm::cont::TypeToString() << std::endl; - TestConstructors(); - TestMoveConstructors(); - TestAssignmentOps(); - TestPrepareForExecution(); - TestIsType(); - TestCast(); - TestControlPortalLocking(); - } -}; - -void TestArrayHandleVirtual() -{ - Test()(); - Test()(); - Test()(); - Test()(); - Test()(); - Test()(); -} - -} // end namespace UnitTestArrayHandleVirtualDetail - -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -int UnitTestArrayHandleVirtual(int argc, char* argv[]) -{ -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - using namespace UnitTestArrayHandleVirtualDetail; - return vtkm::cont::testing::Testing::Run(TestArrayHandleVirtual, argc, argv); -#else - (void)argc; - (void)argv; - return 0; -#endif -} diff --git a/vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx b/vtkm/cont/testing/UnitTestArrayPortalFromIterators.cxx similarity index 100% rename from vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx rename to vtkm/cont/testing/UnitTestArrayPortalFromIterators.cxx diff --git a/vtkm/cont/internal/testing/UnitTestBuffer.cxx b/vtkm/cont/testing/UnitTestBuffer.cxx similarity index 100% rename from vtkm/cont/internal/testing/UnitTestBuffer.cxx rename to vtkm/cont/testing/UnitTestBuffer.cxx diff --git a/vtkm/cont/testing/UnitTestCellLocatorPartitioned.cxx b/vtkm/cont/testing/UnitTestCellLocatorPartitioned.cxx new file mode 100644 index 000000000..8d6b4db10 --- /dev/null +++ b/vtkm/cont/testing/UnitTestCellLocatorPartitioned.cxx @@ -0,0 +1,94 @@ + +//============================================================================ +// 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. +//============================================================================ + +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include + +namespace +{ +struct QueryCellsWorklet : public vtkm::worklet::WorkletMapField +{ + using ControlSignature = void(FieldIn, ExecObject, FieldOut, FieldOut); + using ExecutionSignature = void(_1, _2, _3, _4); + + template + VTKM_EXEC void operator()(const PointType& point, + const CellLocatorExecObjectType& cellLocator, + vtkm::Id& cellId, + vtkm::Id& partitionId) const + { + vtkm::Vec3f parametric; + vtkm::ErrorCode status = cellLocator.FindCell(point, partitionId, cellId, parametric); + if (status != vtkm::ErrorCode::Success) + { + this->RaiseError(vtkm ::ErrorString(status)); + partitionId = -1; + cellId = -1; + } + } +}; + +void Test() +{ + int dim = 3; + int numberOfLevels = 3; + int cellsPerDimension = 8; + + // Generate AMR + vtkm::source::Amr source; + source.SetDimension(dim); + source.SetNumberOfLevels(numberOfLevels); + source.SetCellsPerDimension(cellsPerDimension); + vtkm::cont::PartitionedDataSet amrDataSet = source.Execute(); + + // one point for each partition + vtkm::cont::ArrayHandle queryPoints; + queryPoints.Allocate(7); + queryPoints.WritePortal().Set(0, vtkm::Vec3f(0.1f, 0.9f, 0.1f)); + queryPoints.WritePortal().Set(1, vtkm::Vec3f(0.1f, 0.4f, 0.4f)); + queryPoints.WritePortal().Set(2, vtkm::Vec3f(0.8f, 0.5f, 0.5f)); + queryPoints.WritePortal().Set(3, vtkm::Vec3f(0.0f)); + queryPoints.WritePortal().Set(4, vtkm::Vec3f(0.4999999f)); + queryPoints.WritePortal().Set(5, vtkm::Vec3f(0.5000001f)); + queryPoints.WritePortal().Set(6, vtkm::Vec3f(1.0f)); + + // generate cellLocator on cont side + vtkm::cont::CellLocatorPartitioned cellLocator; + cellLocator.SetPartitions(amrDataSet); + cellLocator.Update(); + vtkm::cont::ArrayHandle cellIds; + vtkm::cont::ArrayHandle partitionIds; + vtkm::cont::Invoker invoke; + invoke(QueryCellsWorklet{}, queryPoints, &cellLocator, cellIds, partitionIds); + + for (vtkm::Id index = 0; index < queryPoints.GetNumberOfValues(); ++index) + { + VTKM_TEST_ASSERT(partitionIds.ReadPortal().Get(index) == index, "Incorrect partitionId"); + } +} + +} // anonymous namespace + +int UnitTestCellLocatorPartitioned(int argc, char* argv[]) +{ + return vtkm::cont::testing::Testing::Run(Test, argc, argv); +} diff --git a/vtkm/cont/testing/UnitTestCellLocatorRectilinearGrid.cxx b/vtkm/cont/testing/UnitTestCellLocatorRectilinearGrid.cxx index 041327347..463dc98ce 100644 --- a/vtkm/cont/testing/UnitTestCellLocatorRectilinearGrid.cxx +++ b/vtkm/cont/testing/UnitTestCellLocatorRectilinearGrid.cxx @@ -103,7 +103,7 @@ public: { // Note that CoordPortalType is actually a RectilinearPortalType wrapped in an // ExecutionWholeArrayConst. We need to get out the actual portal. - vtkm::Id calculated = CalculateCellId(pointIn, coordsPortal.GetPortal()); + vtkm::Id calculated = CalculateCellId(pointIn, coordsPortal); vtkm::ErrorCode status = locator.FindCell(pointIn, cellId, parametric); if (status != vtkm::ErrorCode::Success) { diff --git a/vtkm/cont/testing/UnitTestCellLocatorTwoLevel.cxx b/vtkm/cont/testing/UnitTestCellLocatorUnstructured.cxx similarity index 86% rename from vtkm/cont/testing/UnitTestCellLocatorTwoLevel.cxx rename to vtkm/cont/testing/UnitTestCellLocatorUnstructured.cxx index 8b8089567..7009aa446 100644 --- a/vtkm/cont/testing/UnitTestCellLocatorTwoLevel.cxx +++ b/vtkm/cont/testing/UnitTestCellLocatorUnstructured.cxx @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -204,9 +205,10 @@ public: } }; -void TestLastCell(vtkm::cont::CellLocatorTwoLevel& locator, +template +void TestLastCell(LocatorType& locator, vtkm::Id numPoints, - vtkm::cont::ArrayHandle& lastCell, + vtkm::cont::ArrayHandle& lastCell, const vtkm::cont::ArrayHandle& points, const vtkm::cont::ArrayHandle& expCellIds, const vtkm::cont::ArrayHandle& expPCoords) @@ -231,16 +233,15 @@ void TestLastCell(vtkm::cont::CellLocatorTwoLevel& locator, } } -template -void TestCellLocator(const vtkm::Vec& dim, vtkm::Id numberOfPoints) +template +void TestCellLocator(LocatorType& locator, + const vtkm::Vec& dim, + vtkm::Id numberOfPoints) { auto ds = MakeTestDataSet(dim); std::cout << "Testing " << DIMENSIONS << "D dataset with " << ds.GetNumberOfCells() << " cells\n"; - vtkm::cont::CellLocatorTwoLevel locator; - locator.SetDensityL1(64.0f); - locator.SetDensityL2(1.0f); locator.SetCellSet(ds.GetCellSet()); locator.SetCoordinates(ds.GetCoordinateSystem()); locator.Update(); @@ -271,15 +272,15 @@ void TestCellLocator(const vtkm::Vec& dim, vtkm::Id number //Test locator using lastCell //Test it with initialized. - vtkm::cont::ArrayHandle lastCell; - lastCell.AllocateAndFill(numberOfPoints, vtkm::cont::CellLocatorTwoLevel::LastCell{}); + vtkm::cont::ArrayHandle lastCell; + lastCell.AllocateAndFill(numberOfPoints, typename LocatorType::LastCell{}); TestLastCell(locator, numberOfPoints, lastCell, points, expCellIds, pcoords); //Call it again using the lastCell just computed to validate. TestLastCell(locator, numberOfPoints, lastCell, points, expCellIds, pcoords); //Test it with uninitialized array. - vtkm::cont::ArrayHandle lastCell2; + vtkm::cont::ArrayHandle lastCell2; lastCell2.Allocate(numberOfPoints); TestLastCell(locator, numberOfPoints, lastCell2, points, expCellIds, pcoords); @@ -287,19 +288,35 @@ void TestCellLocator(const vtkm::Vec& dim, vtkm::Id number TestLastCell(locator, numberOfPoints, lastCell2, points, expCellIds, pcoords); } -void TestingCellLocatorTwoLevel() +void TestingCellLocatorUnstructured() { vtkm::UInt32 seed = static_cast(std::time(nullptr)); std::cout << "Seed: " << seed << std::endl; RandomGenerator.seed(seed); - TestCellLocator(vtkm::Id3(8), 512); // 3D dataset - TestCellLocator(vtkm::Id2(18), 512); // 2D dataset + //Test vtkm::cont::CellLocatorTwoLevel + vtkm::cont::CellLocatorTwoLevel locator2L; + locator2L.SetDensityL1(64.0f); + locator2L.SetDensityL2(1.0f); + + TestCellLocator(locator2L, vtkm::Id3(8), 512); // 3D dataset + TestCellLocator(locator2L, vtkm::Id2(18), 512); // 2D dataset + + //Test vtkm::cont::CellLocatorUniformBins + vtkm::cont::CellLocatorUniformBins locatorUB; + locatorUB.SetDims({ 32, 32, 32 }); + TestCellLocator(locatorUB, vtkm::Id3(8), 512); // 3D dataset + TestCellLocator(locatorUB, vtkm::Id2(18), 512); // 2D dataset + + //Test 2D dataset with 2D bins. + locatorUB.SetDims({ 32, 32, 1 }); + TestCellLocator(locatorUB, vtkm::Id2(18), 512); // 2D dataset } + } // anonymous -int UnitTestCellLocatorTwoLevel(int argc, char* argv[]) +int UnitTestCellLocatorUnstructured(int argc, char* argv[]) { - return vtkm::cont::testing::Testing::Run(TestingCellLocatorTwoLevel, argc, argv); + return vtkm::cont::testing::Testing::Run(TestingCellLocatorUnstructured, argc, argv); } diff --git a/vtkm/cont/testing/UnitTestCellSet.cxx b/vtkm/cont/testing/UnitTestCellSet.cxx index cfe3fdb32..d203f81e7 100644 --- a/vtkm/cont/testing/UnitTestCellSet.cxx +++ b/vtkm/cont/testing/UnitTestCellSet.cxx @@ -20,84 +20,6 @@ #include #include -// Make sure deprecated types still work (while applicable) -VTKM_DEPRECATED_SUPPRESS_BEGIN -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetStructured<3>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagPoint, - vtkm::TopologyElementTagCell>::ExecObjectType>::value)); -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetStructured<3>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagCell, - vtkm::TopologyElementTagPoint>::ExecObjectType>::value)); - -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetExplicit<>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagPoint, - vtkm::TopologyElementTagCell>::ExecObjectType>::value)); -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetExplicit<>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagCell, - vtkm::TopologyElementTagPoint>::ExecObjectType>::value)); - -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetSingleType<>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagPoint, - vtkm::TopologyElementTagCell>::ExecObjectType>::value)); -VTKM_STATIC_ASSERT( - (std::is_same:: - ExecConnectivityType, - typename vtkm::cont::CellSetSingleType<>::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagCell, - vtkm::TopologyElementTagPoint>::ExecObjectType>::value)); - -VTKM_STATIC_ASSERT( - (std::is_same>:: - ExecConnectivityType, - typename vtkm::cont::CellSetPermutation>:: - ExecutionTypes::ExecObjectType>::value)); -VTKM_STATIC_ASSERT( - (std::is_same>:: - ExecConnectivityType, - typename vtkm::cont::CellSetPermutation>:: - ExecutionTypes::ExecObjectType>::value)); - -VTKM_STATIC_ASSERT( - (std::is_same, - typename vtkm::cont::CellSetExtrude::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagPoint, - vtkm::TopologyElementTagCell>::ExecObjectType>::value)); -VTKM_STATIC_ASSERT( - (std::is_same, - typename vtkm::cont::CellSetExtrude::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial, - vtkm::TopologyElementTagCell, - vtkm::TopologyElementTagPoint>::ExecObjectType>::value)); -VTKM_DEPRECATED_SUPPRESS_END - namespace { diff --git a/vtkm/cont/testing/UnitTestCellSetExplicit.cxx b/vtkm/cont/testing/UnitTestCellSetExplicit.cxx index 84337cba5..78627a66e 100644 --- a/vtkm/cont/testing/UnitTestCellSetExplicit.cxx +++ b/vtkm/cont/testing/UnitTestCellSetExplicit.cxx @@ -174,6 +174,7 @@ void TestCellSetExplicit() vtkm::cont::Token token; { vtkm::cont::ScopedRuntimeDeviceTracker deviceScope(vtkm::cont::DeviceAdapterTagSerial{}); + (void)deviceScope; cellset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{}, PointTag{}, CellTag{}, token); } diff --git a/vtkm/cont/arg/testing/UnitTestControlSignatureTag.cxx b/vtkm/cont/testing/UnitTestControlSignatureTag.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestControlSignatureTag.cxx rename to vtkm/cont/testing/UnitTestControlSignatureTag.cxx diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderCurvilinear.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderCurvilinear.cxx index 222ebb572..e60c8f9a8 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderCurvilinear.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderCurvilinear.cxx @@ -29,7 +29,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds, { //Verify basics.. - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields."); VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems."); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates."); VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells."); diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx index 6acb61586..641444f37 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx @@ -37,7 +37,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds, const vtkm::Bounds& bounds) { //Verify basics.. - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields."); VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems."); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates."); VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells."); diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx index b9c97785d..dd0d2a04e 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx @@ -30,7 +30,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds, { //Verify basics.. - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields."); VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems."); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates."); VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells."); diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx index c35fa48bf..a7195b7be 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx @@ -31,7 +31,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds, { //Verify basics.. - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields."); VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems."); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates."); VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells."); diff --git a/vtkm/cont/testing/UnitTestDataSetConvertToExpected.cxx b/vtkm/cont/testing/UnitTestDataSetConvertToExpected.cxx index 58b94268a..dc6717a70 100644 --- a/vtkm/cont/testing/UnitTestDataSetConvertToExpected.cxx +++ b/vtkm/cont/testing/UnitTestDataSetConvertToExpected.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,10 @@ vtkm::cont::DataSet MakeDataSet() vtkm::cont::DataSet dataset; + vtkm::cont::CellSetStructured<3> cellSet; + cellSet.SetPointDimensions(vtkm::Id3(DIM_SIZE)); + dataset.SetCellSet(cellSet); + dataset.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coords", MakeCoordinates())); dataset.AddPointField("scalars", MakeField()); dataset.AddPointField("vectors", MakeVecField()); diff --git a/vtkm/cont/testing/UnitTestDataSetExplicit.cxx b/vtkm/cont/testing/UnitTestDataSetExplicit.cxx index 56abcf63a..0fc67d86f 100644 --- a/vtkm/cont/testing/UnitTestDataSetExplicit.cxx +++ b/vtkm/cont/testing/UnitTestDataSetExplicit.cxx @@ -44,7 +44,7 @@ void TestDataSet_Explicit() vtkm::cont::testing::MakeTestDataSet tds; vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0(); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); // test various field-getting methods and associations const vtkm::cont::Field& f1 = ds.GetField("pointvar"); diff --git a/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx b/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx index 68b8f8588..f1aa27f25 100644 --- a/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx +++ b/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx @@ -42,7 +42,7 @@ static void TwoDimRectilinearTest() vtkm::cont::CellSetStructured<2> cellSet; dataSet.GetCellSet().AsCellSet(cellSet); - VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, "Incorrect number of coordinate systems"); VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points"); @@ -128,7 +128,7 @@ static void ThreeDimRectilinearTest() vtkm::cont::CellSetStructured<3> cellSet; dataSet.GetCellSet().AsCellSet(cellSet); - VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, "Incorrect number of coordinate systems"); diff --git a/vtkm/cont/testing/UnitTestDataSetUniform.cxx b/vtkm/cont/testing/UnitTestDataSetUniform.cxx index f97dfc775..ff400c015 100644 --- a/vtkm/cont/testing/UnitTestDataSetUniform.cxx +++ b/vtkm/cont/testing/UnitTestDataSetUniform.cxx @@ -43,7 +43,7 @@ static void TwoDimUniformTest() vtkm::cont::CellSetStructured<2> cellSet; dataSet.GetCellSet().AsCellSet(cellSet); - VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, "Incorrect number of coordinate systems"); VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points"); @@ -132,7 +132,7 @@ static void ThreeDimUniformTest() vtkm::cont::CellSetStructured<3> cellSet; dataSet.GetCellSet().AsCellSet(cellSet); - VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, "Incorrect number of coordinate systems"); diff --git a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmDependency.cxx b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmDependency.cxx index 777838c41..91b8c85cc 100644 --- a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmDependency.cxx +++ b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmDependency.cxx @@ -37,6 +37,7 @@ void CheckPostDefinedDeviceAdapter() // Nothing to really check. If this compiles, then the test is probably // successful. vtkm::cont::ArrayHandle test; + (void)test; } } // anonymous namespace diff --git a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx index 7a3743a2c..18bc1667e 100644 --- a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx +++ b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx @@ -26,10 +26,6 @@ #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL - #include // Hijack the serial device id so that precompiled units (like memory management) still work. @@ -89,17 +85,6 @@ class DeviceAdapterMemoryManager -struct VirtualObjectTransfer final - : public VirtualObjectTransferShareWithControl -{ - using VirtualObjectTransferShareWithControl::VirtualObjectTransferShareWithControl; -}; -VTKM_DEPRECATED_SUPPRESS_END -#endif //VTKM_NO_DEPRECATED_VIRTUAL - } } } // namespace vtkm::cont::internal diff --git a/vtkm/cont/testing/UnitTestDynamicCellSet.cxx b/vtkm/cont/testing/UnitTestDynamicCellSet.cxx deleted file mode 100644 index e0c82f481..000000000 --- a/vtkm/cont/testing/UnitTestDynamicCellSet.cxx +++ /dev/null @@ -1,179 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include - -// This is testing a deprecated functionality. Remove this test once VariantArrayHandle -// is completely removed from VTK-m. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -#include - -#include - -namespace -{ - -using NonDefaultCellSetList = - vtkm::List, - vtkm::cont::CellSetExplicit::StorageTag>>; - -template -struct CheckFunctor -{ - void operator()(const ExpectedCellType&, bool& called) const { called = true; } - - template - void operator()(const UnexpectedType&, bool& called) const - { - VTKM_TEST_FAIL("CastAndCall functor called with wrong type."); - called = false; - } -}; - -class DummyCellSet : public vtkm::cont::CellSet -{ -}; - -void CheckEmptyDynamicCellSet() -{ - vtkm::cont::DynamicCellSet empty; - - VTKM_TEST_ASSERT(empty.GetNumberOfCells() == 0, "DynamicCellSet should have no cells"); - VTKM_TEST_ASSERT(empty.GetNumberOfFaces() == 0, "DynamicCellSet should have no faces"); - VTKM_TEST_ASSERT(empty.GetNumberOfEdges() == 0, "DynamicCellSet should have no edges"); - VTKM_TEST_ASSERT(empty.GetNumberOfPoints() == 0, "DynamicCellSet should have no points"); - - empty.PrintSummary(std::cout); - - using CellSet2D = vtkm::cont::CellSetStructured<2>; - using CellSet3D = vtkm::cont::CellSetStructured<3>; - VTKM_TEST_ASSERT(!empty.template IsType(), "DynamicCellSet reports wrong type."); - VTKM_TEST_ASSERT(!empty.template IsType(), "DynamicCellSet reports wrong type."); - VTKM_TEST_ASSERT(!empty.template IsType(), "DynamicCellSet reports wrong type."); - - CellSet2D instance; - VTKM_TEST_ASSERT(!empty.IsSameType(instance), "DynamicCellSet reports wrong type."); - - bool gotException = false; - try - { - instance = empty.Cast(); - } - catch (vtkm::cont::ErrorBadType&) - { - gotException = true; - } - VTKM_TEST_ASSERT(gotException, "Empty DynamicCellSet should have thrown on casting"); - - auto empty2 = empty.NewInstance(); - VTKM_TEST_ASSERT(empty.GetCellSetBase() == nullptr, "DynamicCellSet should contain a nullptr"); - VTKM_TEST_ASSERT(empty2.GetCellSetBase() == nullptr, "DynamicCellSet should contain a nullptr"); -} - -template -void CheckDynamicCellSet(const CellSetType& cellSet, - vtkm::cont::DynamicCellSetBase dynamicCellSet) -{ - VTKM_TEST_ASSERT(dynamicCellSet.template IsType(), - "DynamicCellSet reports wrong type."); - VTKM_TEST_ASSERT(dynamicCellSet.IsSameType(cellSet), "DynamicCellSet reports wrong type."); - VTKM_TEST_ASSERT(!dynamicCellSet.template IsType(), - "DynamicCellSet reports wrong type."); - - dynamicCellSet.template Cast(); - - bool called = false; - dynamicCellSet.CastAndCall(CheckFunctor(), called); - - VTKM_TEST_ASSERT( - called, "The functor was never called (and apparently a bad value exception not thrown)."); - - called = false; - CastAndCall(dynamicCellSet, CheckFunctor(), called); - - VTKM_TEST_ASSERT( - called, "The functor was never called (and apparently a bad value exception not thrown)."); -} - -template -void TryNewInstance(CellSetType, vtkm::cont::DynamicCellSetBase originalCellSet) -{ - vtkm::cont::DynamicCellSetBase newCellSet = originalCellSet.NewInstance(); - - VTKM_TEST_ASSERT(newCellSet.template IsType(), "New cell set wrong type."); - - VTKM_TEST_ASSERT(originalCellSet.GetCellSetBase() != newCellSet.GetCellSetBase(), - "NewInstance did not make a copy."); -} - -template -void TryCellSet(CellSetType cellSet, vtkm::cont::DynamicCellSetBase dynamicCellSet) -{ - CheckDynamicCellSet(cellSet, dynamicCellSet); - - CheckDynamicCellSet(cellSet, dynamicCellSet.ResetCellSetList(vtkm::List())); - - TryNewInstance(cellSet, dynamicCellSet); -} - -template -void TryCellSet(CellSetType cellSet, vtkm::cont::DynamicCellSet dynamicCellSet) -{ - TryCellSet(cellSet, dynamicCellSet.ResetCellSetList()); -} - -template -void TryDefaultCellSet(CellSetType cellSet) -{ - vtkm::cont::DynamicCellSet dynamicCellSet(cellSet); - - TryCellSet(cellSet, dynamicCellSet); -} - -template -void TryNonDefaultCellSet(CellSetType cellSet) -{ - vtkm::cont::DynamicCellSetBase dynamicCellSet(cellSet); - - TryCellSet(cellSet, dynamicCellSet); -} - -void TestDynamicCellSet() -{ - std::cout << "Try default types with default type lists." << std::endl; - std::cout << "*** 2D Structured Grid ******************" << std::endl; - TryDefaultCellSet(vtkm::cont::CellSetStructured<2>()); - std::cout << "*** 3D Structured Grid ******************" << std::endl; - TryDefaultCellSet(vtkm::cont::CellSetStructured<3>()); - std::cout << "*** Explicit Grid ***********************" << std::endl; - TryDefaultCellSet(vtkm::cont::CellSetExplicit<>()); - - std::cout << std::endl << "Try non-default types." << std::endl; - std::cout << "*** 1D Structured Grid ******************" << std::endl; - TryNonDefaultCellSet(vtkm::cont::CellSetStructured<1>()); - std::cout << "*** Explicit Grid Constant Shape ********" << std::endl; - TryNonDefaultCellSet( - vtkm::cont::CellSetExplicit::StorageTag>()); - - std::cout << std::endl << "Try empty DynamicCellSet." << std::endl; - CheckEmptyDynamicCellSet(); -} - -} // anonymous namespace - -int UnitTestDynamicCellSet(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestDynamicCellSet, argc, argv); -} - -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/cont/testing/UnitTestImplicitFunction.cxx b/vtkm/cont/testing/UnitTestImplicitFunction.cxx index 57dd514a3..34bd3fe97 100644 --- a/vtkm/cont/testing/UnitTestImplicitFunction.cxx +++ b/vtkm/cont/testing/UnitTestImplicitFunction.cxx @@ -15,10 +15,6 @@ #include #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - #include #include @@ -41,20 +37,6 @@ public: val = function.Value(point); gradient = function.Gradient(point); } - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - template - VTKM_EXEC void operator()(const VecType& point, - ScalarType& val, - VecType& gradient, - const FunctionType* function) const - { - val = function->Value(point); - gradient = function->Gradient(point); - } - VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL }; constexpr std::array points_g = { { { 0, 0, 0 }, @@ -96,20 +78,6 @@ void Try(ImplicitFunctorType& function, VTKM_TEST_ASSERT(test_equal_ArrayHandles(gradients, expectedGradientsArray)); } -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - { - vtkm::cont::ImplicitFunctionHandle functionHandle(&function, false); - vtkm::cont::ArrayHandle values; - vtkm::cont::ArrayHandle> gradients; - EvaluateOnCoordinates(functionHandle, values, gradients); - - VTKM_TEST_ASSERT(test_equal_ArrayHandles(values, expectedValuesArray)); - VTKM_TEST_ASSERT(test_equal_ArrayHandles(gradients, expectedGradientsArray)); - } - VTKM_DEPRECATED_SUPPRESS_END -#endif //!VTKM_NO_DEPRECATED_VIRTUAL - { vtkm::ImplicitFunctionMultiplexer functionChoose(function); vtkm::cont::ArrayHandle values; diff --git a/vtkm/cont/testing/UnitTestInitialize.cxx b/vtkm/cont/testing/UnitTestInitialize.cxx index 4e42f1603..06f3ef0a4 100644 --- a/vtkm/cont/testing/UnitTestInitialize.cxx +++ b/vtkm/cont/testing/UnitTestInitialize.cxx @@ -142,45 +142,13 @@ void InitializeCustomOptionsWithArgs() CheckArgs(argc, argv, "--foo", "bar", "--baz"); } -void InitializeDeprecatedOptionsWithArgs() -{ - std::cout << "Calling program has option --foo that takes arg bar." << std::endl; - - int argc; - char** argv; - vtkm::cont::testing::Testing::MakeArgsAddProgramName( - argc, argv, "--device", "Any", "--foo=bar", "--baz"); - vtkm::cont::Initialize(argc, argv); - CheckArgs(argc, argv, "--foo=bar", "--baz"); - - vtkm::cont::testing::Testing::MakeArgsAddProgramName( - argc, argv, "--foo=bar", "--baz", "--device", "Any"); - vtkm::cont::Initialize(argc, argv); - CheckArgs(argc, argv, "--foo=bar", "--baz"); - - vtkm::cont::testing::Testing::MakeArgsAddProgramName( - argc, argv, "-d", "Any", "--foo", "bar", "--baz"); - vtkm::cont::Initialize(argc, argv); - CheckArgs(argc, argv, "--foo", "bar", "--baz"); - - vtkm::cont::testing::Testing::MakeArgsAddProgramName( - argc, argv, "--foo", "bar", "--baz", "-d", "Any"); - vtkm::cont::Initialize(argc, argv); - CheckArgs(argc, argv, "--foo", "bar", "--baz"); - - vtkm::cont::testing::Testing::MakeArgsAddProgramName( - argc, argv, "--foo", "-v", "OFF", "--", "--device", "Any", "--bar", "baz"); - vtkm::cont::Initialize(argc, argv); - CheckArgs(argc, argv, "--foo", "--", "--device", "Any", "--bar", "baz"); -} - void InitializeRuntimeDeviceConfigurationWithArgs() { int argc; char** argv; vtkm::cont::testing::Testing::MakeArgsAddProgramName(argc, argv, - "--device", + "--vtkm-device", "Any", "--vtkm-num-threads", "100", @@ -199,7 +167,7 @@ void InitializeWithHelp() int argc; char** argv; vtkm::cont::testing::Testing::MakeArgsAddProgramName(argc, argv, "--vtkm-help"); - vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::AddHelp); + vtkm::cont::Initialize(argc, argv); VTKM_TEST_FAIL("Help argument did not exit as expected."); } @@ -217,7 +185,6 @@ void DoInitializeTests() InitializeCustomOptions(); InitializeMixedOptions(); InitializeCustomOptionsWithArgs(); - InitializeDeprecatedOptionsWithArgs(); InitializeRuntimeDeviceConfigurationWithArgs(); // This should be the last function called as it should exit with a zero status. diff --git a/vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx b/vtkm/cont/testing/UnitTestIteratorFromArrayPortal.cxx similarity index 100% rename from vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx rename to vtkm/cont/testing/UnitTestIteratorFromArrayPortal.cxx diff --git a/vtkm/cont/testing/UnitTestLogging.cxx b/vtkm/cont/testing/UnitTestLogging.cxx index a7ec07147..ab42b996c 100644 --- a/vtkm/cont/testing/UnitTestLogging.cxx +++ b/vtkm/cont/testing/UnitTestLogging.cxx @@ -45,22 +45,6 @@ void Scopes(int level = 0) } } -// VTKM_LOG_ERROR_CONTEXT is no longer implemented as it is -// deprecated -void ErrorContext() -{ - // These variables are only logged if a crash occurs. - // Only supports POD by default, but can be extended (see loguru docs) - VTKM_LOG_ERROR_CONTEXT("Some Int", 3); - VTKM_LOG_ERROR_CONTEXT("A Double", 236.7521); - VTKM_LOG_ERROR_CONTEXT("A C-String", "Hiya!"); - - // The error-tracking should work automatically on linux (maybe mac?) but on - // windows it doesn't trigger automatically (see loguru #74). But we can - // manually dump the error context log like so: - std::cerr << vtkm::cont::GetLogErrorContext() << "\n"; -} - void UserDefined() { VTKM_DEFINE_USER_LOG_LEVEL(CustomLevel, 0); @@ -87,9 +71,6 @@ void RunTests() VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Running Scopes test..."); Scopes(); - VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Running ErrorContext test..."); - ErrorContext(); - VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Running UserDefined test..."); UserDefined(); } diff --git a/vtkm/cont/testing/UnitTestParticleArrayCopy.cxx b/vtkm/cont/testing/UnitTestParticleArrayCopy.cxx index 4054270cf..e3f74fccd 100644 --- a/vtkm/cont/testing/UnitTestParticleArrayCopy.cxx +++ b/vtkm/cont/testing/UnitTestParticleArrayCopy.cxx @@ -45,7 +45,7 @@ void TestParticleArrayCopy() { auto p = pPortal.Get(j); auto pt = pos.ReadPortal().Get(j); - VTKM_TEST_ASSERT(p.Pos == pt, "Positions do not match"); + VTKM_TEST_ASSERT(p.GetPosition() == pt, "Positions do not match"); } } else //Test copy everything @@ -62,11 +62,11 @@ void TestParticleArrayCopy() { auto p = pPortal.Get(j); auto pt = pos.ReadPortal().Get(j); - VTKM_TEST_ASSERT(p.Pos == pt, "Positions do not match"); - VTKM_TEST_ASSERT(p.ID == ids.ReadPortal().Get(j), "IDs do not match"); - VTKM_TEST_ASSERT(p.NumSteps == steps.ReadPortal().Get(j), "Steps do not match"); - VTKM_TEST_ASSERT(p.Status == status.ReadPortal().Get(j), "Status do not match"); - VTKM_TEST_ASSERT(p.Time == ptime.ReadPortal().Get(j), "Times do not match"); + VTKM_TEST_ASSERT(p.GetPosition() == pt, "Positions do not match"); + VTKM_TEST_ASSERT(p.GetID() == ids.ReadPortal().Get(j), "IDs do not match"); + VTKM_TEST_ASSERT(p.GetNumberOfSteps() == steps.ReadPortal().Get(j), "Steps do not match"); + VTKM_TEST_ASSERT(p.GetStatus() == status.ReadPortal().Get(j), "Status do not match"); + VTKM_TEST_ASSERT(p.GetTime() == ptime.ReadPortal().Get(j), "Times do not match"); } } } @@ -106,7 +106,7 @@ void TestParticleArrayCopy() { auto p = portal.Get(i); auto pRes = resPortal.Get(resIdx); - VTKM_TEST_ASSERT(p.Pos == pRes, "Positions do not match"); + VTKM_TEST_ASSERT(p.GetPosition() == pRes, "Positions do not match"); resIdx++; } } diff --git a/vtkm/cont/testing/UnitTestPartitionedDataSet.cxx b/vtkm/cont/testing/UnitTestPartitionedDataSet.cxx index 49a336669..78c1c760c 100644 --- a/vtkm/cont/testing/UnitTestPartitionedDataSet.cxx +++ b/vtkm/cont/testing/UnitTestPartitionedDataSet.cxx @@ -224,6 +224,11 @@ void DataSet_Compare(vtkm::cont::DataSet& leftDataSet, vtkm::cont::DataSet& righ { for (vtkm::Id j = 0; j < leftDataSet.GetNumberOfFields(); j++) { + if (leftDataSet.HasCoordinateSystem(leftDataSet.GetField(j).GetName())) + { + // Skip coordinate systems, which have a different array type. + continue; + } vtkm::cont::ArrayHandle lDataArray; leftDataSet.GetField(j).GetData().AsArrayHandle(lDataArray); vtkm::cont::ArrayHandle rDataArray; diff --git a/vtkm/cont/internal/testing/UnitTestRuntimeConfigurationOptions.cxx b/vtkm/cont/testing/UnitTestRuntimeConfigurationOptions.cxx similarity index 100% rename from vtkm/cont/internal/testing/UnitTestRuntimeConfigurationOptions.cxx rename to vtkm/cont/testing/UnitTestRuntimeConfigurationOptions.cxx diff --git a/vtkm/cont/testing/UnitTestStorageListTag.cxx b/vtkm/cont/testing/UnitTestStorageListTag.cxx deleted file mode 100644 index 4b9493289..000000000 --- a/vtkm/cont/testing/UnitTestStorageListTag.cxx +++ /dev/null @@ -1,78 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -// This tests deprecated code until it is deleted. -#include -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -#include - -#include - -namespace -{ - -enum TypeId -{ - BASIC -}; - -TypeId GetTypeId(vtkm::cont::StorageTagBasic) -{ - return BASIC; -} - -struct TestFunctor -{ - std::vector FoundTypes; - - template - VTKM_CONT void operator()(T) - { - this->FoundTypes.push_back(GetTypeId(T())); - } -}; - -template -void CheckSame(const vtkm::Vec& expected, const std::vector& found) -{ - VTKM_TEST_ASSERT(static_cast(found.size()) == N, "Got wrong number of items."); - - for (vtkm::IdComponent index = 0; index < N; index++) - { - vtkm::UInt32 i = static_cast(index); - VTKM_TEST_ASSERT(expected[index] == found[i], "Got wrong type."); - } -} - -template -void TryList(const vtkm::Vec& expected, ListTag) -{ - TestFunctor functor; - vtkm::ListForEach(functor, ListTag()); - CheckSame(expected, functor.FoundTypes); -} - -void TestLists() -{ - std::cout << "StorageListTagBasic" << std::endl; - TryList(vtkm::Vec(BASIC), vtkm::cont::StorageListTagBasic()); -} - -} // anonymous namespace - -int UnitTestStorageListTag(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestLists, argc, argv); -} - -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/cont/arg/testing/UnitTestTransportArrayIn.cxx b/vtkm/cont/testing/UnitTestTransportArrayIn.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportArrayIn.cxx rename to vtkm/cont/testing/UnitTestTransportArrayIn.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTransportArrayInOut.cxx b/vtkm/cont/testing/UnitTestTransportArrayInOut.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportArrayInOut.cxx rename to vtkm/cont/testing/UnitTestTransportArrayInOut.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTransportArrayOut.cxx b/vtkm/cont/testing/UnitTestTransportArrayOut.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportArrayOut.cxx rename to vtkm/cont/testing/UnitTestTransportArrayOut.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTransportCellSetIn.cxx b/vtkm/cont/testing/UnitTestTransportCellSetIn.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportCellSetIn.cxx rename to vtkm/cont/testing/UnitTestTransportCellSetIn.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx b/vtkm/cont/testing/UnitTestTransportExecObject.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx rename to vtkm/cont/testing/UnitTestTransportExecObject.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTransportWholeArray.cxx b/vtkm/cont/testing/UnitTestTransportWholeArray.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTransportWholeArray.cxx rename to vtkm/cont/testing/UnitTestTransportWholeArray.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx b/vtkm/cont/testing/UnitTestTypeCheckArray.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx rename to vtkm/cont/testing/UnitTestTypeCheckArray.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTypeCheckCellSet.cxx b/vtkm/cont/testing/UnitTestTypeCheckCellSet.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTypeCheckCellSet.cxx rename to vtkm/cont/testing/UnitTestTypeCheckCellSet.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTypeCheckExecObject.cxx b/vtkm/cont/testing/UnitTestTypeCheckExecObject.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTypeCheckExecObject.cxx rename to vtkm/cont/testing/UnitTestTypeCheckExecObject.cxx diff --git a/vtkm/cont/arg/testing/UnitTestTypeCheckKeys.cxx b/vtkm/cont/testing/UnitTestTypeCheckKeys.cxx similarity index 100% rename from vtkm/cont/arg/testing/UnitTestTypeCheckKeys.cxx rename to vtkm/cont/testing/UnitTestTypeCheckKeys.cxx diff --git a/vtkm/cont/testing/UnitTestVariantArrayHandle.cxx b/vtkm/cont/testing/UnitTestVariantArrayHandle.cxx deleted file mode 100644 index 79467c31a..000000000 --- a/vtkm/cont/testing/UnitTestVariantArrayHandle.cxx +++ /dev/null @@ -1,552 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include - -// This is testing a deprecated functionality. Remove this test once VariantArrayHandle -// is completely removed from VTK-m. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif - -#include - -#include - -#include -#include -#include -#include - -namespace -{ - -// Make an "unusual" type to use in the test. This is simply a type that -// is sure not to be declared elsewhere. -struct UnusualType -{ - using T = vtkm::Id; - T X; - UnusualType() = default; - UnusualType(T x) - : X(x) - { - } - UnusualType& operator=(T x) - { - this->X = x; - return *this; - } - operator T() const { return this->X; } -}; - -} // anonymous namespace - -namespace vtkm -{ - -// VariantArrayHandle requires its value type to have a defined VecTraits -// class. One of the tests is to use an "unusual" array. -// Make an implementation here. Because I am lazy, this is only a partial -// implementation. -template <> -struct VecTraits : VecTraits -{ - using ComponentType = UnusualType; - using BaseComponentType = UnusualType; -}; - -} // namespace vtkm - -namespace -{ - -const vtkm::Id ARRAY_SIZE = 10; - -template -struct TestValueFunctor -{ - T operator()(vtkm::Id index) const { return TestValue(index, T()); } -}; - -struct CheckFunctor -{ - template - static void CheckArray(const vtkm::cont::ArrayHandle& array) - { - VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size."); - CheckPortal(array.ReadPortal()); - } - - template - static void CheckArray(const vtkm::cont::ArrayHandle& array) - { - VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size."); - auto portal = array.ReadPortal(); - for (vtkm::Id index = 0; index < array.GetNumberOfValues(); ++index) - { - VTKM_TEST_ASSERT(portal.Get(index) == TestValue(index, UnusualType::T{})); - } - } - - template - void operator()(const vtkm::cont::ArrayHandle& array, - bool& calledBasic, - bool& vtkmNotUsed(calledVirtual)) const - { - calledBasic = true; - std::cout << " Checking for basic array type: " << typeid(T).name() << std::endl; - - CheckArray(array); - } - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - template - void operator()(const vtkm::cont::ArrayHandleVirtual& array, - bool& vtkmNotUsed(calledBasic), - bool& calledVirtual) const - { - calledVirtual = true; - std::cout << " Checking for virtual array type: " << typeid(T).name() << std::endl; - - CheckArray(array); - } -#endif //VTKM_NO_DEPRECATED_VIRTUAL - - template - void operator()(const vtkm::cont::ArrayHandle&, bool&, bool&) const - { - VTKM_TEST_FAIL("Array resolved to unexpected type."); - } -}; - -template -void BasicArrayVariantChecks(const vtkm::cont::VariantArrayHandleBase& array, - vtkm::IdComponent numComponents) -{ - VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, - "Dynamic array reports unexpected size."); - std::cout << "array.GetNumberOfComponents() = " << array.GetNumberOfComponentsFlat() << ", " - << "numComponents = " << numComponents << "\n"; - VTKM_TEST_ASSERT(array.GetNumberOfComponentsFlat() == numComponents, - "Dynamic array reports unexpected number of components."); -} - -template -void CheckArrayVariant(const vtkm::cont::VariantArrayHandleBase& array, - vtkm::IdComponent numComponents, - bool isBasicArray) -{ - BasicArrayVariantChecks(array, numComponents); - - std::cout << " CastAndCall with default storage" << std::endl; - bool calledBasic = false; - bool calledVirtual = false; - CastAndCall(array, CheckFunctor(), calledBasic, calledVirtual); - - VTKM_TEST_ASSERT( - calledBasic || calledVirtual, - "The functor was never called (and apparently a bad value exception not thrown)."); - if (isBasicArray) - { - VTKM_TEST_ASSERT(calledBasic, "The functor was never called with the basic array fast path"); - VTKM_TEST_ASSERT(!calledVirtual, "The functor was somehow called with the virtual path"); - } - else - { - VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage."); - } - -// Work around apparent bug in some versions of GCC that give a warning about -// StorageVirtualImpl<>::GetNumberOfValues() being "declared 'static' but never defined" -// (even though nothing about this method is declared static). See the following -// stackoverflow discussion for more details: -// -// https://stackoverflow.com/questions/56615695/how-to-fix-declared-static-but-never-defined-on-member-function -#if !defined(VTKM_GCC) || (__GNUC__ >= 9) - std::cout << " CastAndCall with extra storage" << std::endl; - calledBasic = false; - calledVirtual = false; - array.CastAndCall(vtkm::List{}, - CheckFunctor(), - calledBasic, - calledVirtual); - VTKM_TEST_ASSERT( - calledBasic || calledVirtual, - "The functor was never called (and apparently a bad value exception not thrown)."); - if (isBasicArray) - { - VTKM_TEST_ASSERT(calledBasic, "The functor was never called with the basic array fast path"); - VTKM_TEST_ASSERT(!calledVirtual, "The functor was somehow called with the virtual path"); - } - else - { - VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage."); - } -#endif -} - -template -vtkm::cont::VariantArrayHandle CreateArrayVariant(T) -{ - vtkm::cont::ArrayHandle array; - array.Allocate(ARRAY_SIZE); - SetPortal(array.WritePortal()); - return vtkm::cont::VariantArrayHandle(array); -} - -vtkm::cont::VariantArrayHandle CreateArrayVariant(UnusualType) -{ - vtkm::cont::ArrayHandle array; - array.Allocate(ARRAY_SIZE); - auto portal = array.WritePortal(); - for (vtkm::Id index = 0; index < ARRAY_SIZE; ++index) - { - portal.Set(index, TestValue(index, UnusualType::T{})); - } - return vtkm::cont::VariantArrayHandle(array); -} - -template -void CheckCastToArrayHandle(const ArrayHandleType& array) -{ - VTKM_IS_ARRAY_HANDLE(ArrayHandleType); - - vtkm::cont::VariantArrayHandle arrayVariant = array; - VTKM_TEST_ASSERT(!arrayVariant.IsType>(), - "Dynamic array reporting is wrong type."); - - ArrayHandleType castArray1; - arrayVariant.CopyTo(castArray1); - VTKM_TEST_ASSERT(arrayVariant.CanConvert(), "Did not query handle correctly."); - //VTKM_TEST_ASSERT(array == castArray1, "Did not get back same array."); - auto result = test_equal_ArrayHandles(array, castArray1); - VTKM_TEST_ASSERT(result, result.GetMergedMessage()); - - - ArrayHandleType castArray2 = arrayVariant.Cast(); - //VTKM_TEST_ASSERT(array == castArray2, "Did not get back same array."); - VTKM_TEST_ASSERT(test_equal_ArrayHandles(array, castArray2)); -} - -// A vtkm::Vec if NumComps > 1, otherwise a scalar -template -using VecOrScalar = typename std::conditional<(NumComps > 1), vtkm::Vec, T>::type; - -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -template -void CheckCastToVirtualArrayHandle(const ArrayType& array) -{ - VTKM_IS_ARRAY_HANDLE(ArrayType); - - using ValueType = typename ArrayType::ValueType; - using VTraits = vtkm::VecTraits; - using ComponentType = typename VTraits::ComponentType; - static constexpr vtkm::IdComponent NumComps = VTraits::NUM_COMPONENTS; - - using Storage = typename ArrayType::StorageTag; - using StorageList = vtkm::ListAppend>; - - using TypeList = vtkm::ListAppend>; - using VariantArrayType = vtkm::cont::VariantArrayHandleBase; - - VariantArrayType arrayVariant = array; - - { - auto testArray = arrayVariant.template AsVirtual(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - { - auto testArray = - arrayVariant.template AsVirtual, StorageList>(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - { - auto testArray = - arrayVariant.template AsVirtual, StorageList>(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - { - auto testArray = - arrayVariant.template AsVirtual, StorageList>(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - { - auto testArray = - arrayVariant.template AsVirtual, StorageList>(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - { - auto testArray = - arrayVariant.template AsVirtual, StorageList>(); - VTKM_TEST_ASSERT(testArray.GetNumberOfValues() == array.GetNumberOfValues(), - "Did not get back virtual array handle representation."); - } - - bool threw = false; - try - { - arrayVariant.template AsVirtual, StorageList>(); - } - catch (vtkm::cont::ErrorBadType&) - { - // caught expected exception - threw = true; - } - - VTKM_TEST_ASSERT(threw, - "Casting to different vector width did not throw expected " - "ErrorBadType exception."); -} -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -template -void TryNewInstance(T, ArrayVariantType originalArray) -{ - // This check should already have been performed by caller, but just in case. - CheckArrayVariant(originalArray, vtkm::VecTraits::NUM_COMPONENTS, true); - - std::cout << "Create new instance of array." << std::endl; - ArrayVariantType newArray = originalArray.NewInstance(); - - std::cout << "Get a static instance of the new array (which checks the type)." << std::endl; - vtkm::cont::ArrayHandle staticArray; - newArray.CopyTo(staticArray); - - std::cout << "Fill the new array with invalid values and make sure the original" << std::endl - << "is uneffected." << std::endl; - staticArray.Allocate(ARRAY_SIZE); - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) - { - staticArray.WritePortal().Set(index, TestValue(index + 100, T())); - } - CheckArrayVariant(originalArray, vtkm::VecTraits::NUM_COMPONENTS, true); - - std::cout << "Set the new static array to expected values and make sure the new" << std::endl - << "dynamic array points to the same new values." << std::endl; - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) - { - staticArray.WritePortal().Set(index, TestValue(index, T())); - } - CheckArrayVariant(newArray, vtkm::VecTraits::NUM_COMPONENTS, true); -} - -template -void TryAsMultiplexer(T, ArrayVariantType sourceArray) -{ - auto originalArray = sourceArray.template Cast>(); - - { - std::cout << "Get multiplex array through direct type." << std::endl; - using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer, - vtkm::cont::ArrayHandleConstant>; - MultiplexerType multiplexArray = sourceArray.template AsMultiplexer(); - - VTKM_TEST_ASSERT(multiplexArray.IsValid()); - VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.ReadPortal(), originalArray.ReadPortal())); - } - - { - std::cout << "Get multiplex array through cast type." << std::endl; - using CastT = typename vtkm::VecTraits::template ReplaceBaseComponentType; - using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandleCast>>; - MultiplexerType multiplexArray = sourceArray.template AsMultiplexer(); - - VTKM_TEST_ASSERT(multiplexArray.IsValid()); - VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.ReadPortal(), originalArray.ReadPortal())); - } - - { - std::cout << "Make sure multiplex array prefers direct array (1st arg)" << std::endl; - using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandleCast>>; - MultiplexerType multiplexArray = sourceArray.template AsMultiplexer(); - - VTKM_TEST_ASSERT(multiplexArray.IsValid()); - VTKM_TEST_ASSERT(multiplexArray.GetArrayHandleVariant().GetIndex() == 0); - VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.ReadPortal(), originalArray.ReadPortal())); - } - - { - std::cout << "Make sure multiplex array prefers direct array (2nd arg)" << std::endl; - using MultiplexerType = - vtkm::cont::ArrayHandleMultiplexer>, - vtkm::cont::ArrayHandle>; - MultiplexerType multiplexArray = sourceArray.template AsMultiplexer(); - - VTKM_TEST_ASSERT(multiplexArray.IsValid()); - VTKM_TEST_ASSERT(multiplexArray.GetArrayHandleVariant().GetIndex() == 1); - VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.ReadPortal(), originalArray.ReadPortal())); - } -} - -struct TryDefaultType -{ - template - void operator()(T) const - { - vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T()); - - CheckArrayVariant(array, vtkm::VecTraits::NUM_COMPONENTS, true); - - TryNewInstance(T(), array); - - TryAsMultiplexer(T(), array); - } -}; - -struct TryBasicVTKmType -{ - template - void operator()(T) const - { - vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T()); - - CheckArrayVariant( - array.ResetTypes(vtkm::TypeListAll()), vtkm::VecTraits::NUM_COMPONENTS, true); - - TryNewInstance(T(), array.ResetTypes(vtkm::TypeListAll())); - } -}; - -void TryUnusualType() -{ - // A string is an unlikely type to be declared elsewhere in VTK-m. - vtkm::cont::VariantArrayHandle array = CreateArrayVariant(UnusualType{}); - - try - { - CheckArrayVariant(array, 1, true); - VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type."); - } - catch (vtkm::cont::ErrorBadType&) - { - std::cout << " Caught exception for unrecognized type." << std::endl; - } - CheckArrayVariant(array.ResetTypes(vtkm::List()), 1, true); - std::cout << " Found type when type list was reset." << std::endl; -} -template -void TryCastToArrayHandle(const ArrayHandleType& array) -{ - CheckCastToArrayHandle(array); -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - CheckCastToVirtualArrayHandle(array); -#endif -} - -void TryCastToArrayHandle() -{ - std::cout << " Normal array handle." << std::endl; - vtkm::FloatDefault buffer[ARRAY_SIZE]; - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) - { - buffer[index] = TestValue(index, vtkm::FloatDefault()); - } - - vtkm::cont::ArrayHandle array = - vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On); - TryCastToArrayHandle(array); - - std::cout << " Cast array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCast(array)); - - std::cout << " Composite vector array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCompositeVector(array, array)); - - std::cout << " Constant array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::make_ArrayHandleConstant(5, ARRAY_SIZE)); - - std::cout << " Counting array handle." << std::endl; - vtkm::cont::ArrayHandleCounting countingArray(ARRAY_SIZE - 1, -1, ARRAY_SIZE); - TryCastToArrayHandle(countingArray); - - std::cout << " Group vec array handle" << std::endl; - vtkm::cont::ArrayHandleGroupVec, 2> groupVecArray( - array); - TryCastToArrayHandle(groupVecArray); - - std::cout << " Implicit array handle." << std::endl; - TryCastToArrayHandle( - vtkm::cont::make_ArrayHandleImplicit(TestValueFunctor(), ARRAY_SIZE)); - - std::cout << " Index array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::ArrayHandleIndex(ARRAY_SIZE)); - - std::cout << " Permutation array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::make_ArrayHandlePermutation(countingArray, array)); - - std::cout << " Transform array handle." << std::endl; - TryCastToArrayHandle( - vtkm::cont::make_ArrayHandleTransform(countingArray, TestValueFunctor())); - - std::cout << " Uniform point coordinates array handle." << std::endl; - TryCastToArrayHandle(vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(ARRAY_SIZE))); - - // std::cout << " Zip array handle." << std::endl; - // CheckCastToArrayHandle(vtkm::cont::make_ArrayHandleZip(countingArray, array)); -} - -void TestVariantArrayHandle() -{ - std::cout << "Try common types with default type lists." << std::endl; - vtkm::testing::Testing::TryTypes(TryDefaultType{}, VTKM_DEFAULT_TYPE_LIST{}); - - std::cout << "Try exemplar VTK-m types." << std::endl; - vtkm::testing::Testing::TryTypes(TryBasicVTKmType()); - - std::cout << "Try unusual type." << std::endl; - TryUnusualType(); - - std::cout << "Try CastToArrayHandle" << std::endl; - TryCastToArrayHandle(); -} - -} // anonymous namespace - -int UnitTestVariantArrayHandle(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestVariantArrayHandle, argc, argv); -} - -// The MSVC compiler is sometimes complaining about use of deprecated VariantArrayHandle at the -// end of this file. This is the end of the translation unit, so just keep the suppression on. -//VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/cont/testing/UnitTestVirtualObjectHandle.cxx b/vtkm/cont/testing/UnitTestVirtualObjectHandle.cxx deleted file mode 100644 index 42c2d34a8..000000000 --- a/vtkm/cont/testing/UnitTestVirtualObjectHandle.cxx +++ /dev/null @@ -1,215 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include -#include -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This test should be disabled if the VTKm_NO_DEPRECATED_VIRTUAL is true." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#define ARRAY_LEN 8 - -namespace -{ - -class Transformer : public vtkm::VirtualObjectBase -{ -public: - VTKM_EXEC - virtual vtkm::FloatDefault Eval(vtkm::FloatDefault val) const = 0; -}; - -class Square : public Transformer -{ -public: - VTKM_EXEC - vtkm::FloatDefault Eval(vtkm::FloatDefault val) const override { return val * val; } -}; - -class Multiply : public Transformer -{ -public: - VTKM_CONT - void SetMultiplicand(vtkm::FloatDefault val) - { - this->Multiplicand = val; - this->Modified(); - } - - VTKM_CONT - vtkm::FloatDefault GetMultiplicand() const { return this->Multiplicand; } - - VTKM_EXEC - vtkm::FloatDefault Eval(vtkm::FloatDefault val) const override - { - return val * this->Multiplicand; - } - -private: - vtkm::FloatDefault Multiplicand = 0.0f; -}; - -class TransformerFunctor -{ -public: - TransformerFunctor() = default; - explicit TransformerFunctor(const Transformer* impl) - : Impl(impl) - { - } - - VTKM_EXEC - vtkm::FloatDefault operator()(vtkm::FloatDefault val) const { return this->Impl->Eval(val); } - -private: - const Transformer* Impl; -}; - -using FloatArrayHandle = vtkm::cont::ArrayHandle; -using ArrayTransform = vtkm::cont::ArrayHandleTransform; -using TransformerHandle = vtkm::cont::VirtualObjectHandle; - -class TestStage1 -{ -public: - TestStage1(const FloatArrayHandle& input, TransformerHandle& handle) - : Input(&input) - , Handle(&handle) - { - } - - template - bool operator()(DeviceAdapter device) const - { - using Algorithm = vtkm::cont::DeviceAdapterAlgorithm; - std::cout << "\tDeviceAdapter: " << vtkm::cont::DeviceAdapterTraits::GetName() - << std::endl; - - for (int n = 0; n < 2; ++n) - { - vtkm::cont::Token token; - TransformerFunctor tfnctr(this->Handle->PrepareForExecution(device, token)); - ArrayTransform transformed(*this->Input, tfnctr); - - FloatArrayHandle output; - Algorithm::Copy(transformed, output); - auto portal = output.ReadPortal(); - for (vtkm::Id i = 0; i < ARRAY_LEN; ++i) - { - vtkm::FloatDefault expected = TestValue(i, vtkm::FloatDefault{}); - expected = expected * expected; - VTKM_TEST_ASSERT( - test_equal(portal.Get(i), expected), "Expected ", expected, " but got ", portal.Get(i)); - } - std::cout << "\tSuccess." << std::endl; - - if (n == 0) - { - std::cout << "\tReleaseResources and test again..." << std::endl; - this->Handle->ReleaseExecutionResources(); - } - } - return true; - } - -private: - const FloatArrayHandle* Input; - TransformerHandle* Handle; -}; - -class TestStage2 -{ -public: - TestStage2(const FloatArrayHandle& input, Multiply& mul, TransformerHandle& handle) - : Input(&input) - , Mul(&mul) - , Handle(&handle) - { - } - - template - bool operator()(DeviceAdapter device) const - { - using Algorithm = vtkm::cont::DeviceAdapterAlgorithm; - std::cout << "\tDeviceAdapter: " << vtkm::cont::DeviceAdapterTraits::GetName() - << std::endl; - - this->Mul->SetMultiplicand(2); - for (int n = 0; n < 2; ++n) - { - vtkm::cont::Token token; - TransformerFunctor tfnctr(this->Handle->PrepareForExecution(device, token)); - ArrayTransform transformed(*this->Input, tfnctr); - - FloatArrayHandle output; - Algorithm::Copy(transformed, output); - auto portal = output.ReadPortal(); - for (vtkm::Id i = 0; i < ARRAY_LEN; ++i) - { - vtkm::FloatDefault expected = - TestValue(i, vtkm::FloatDefault{}) * this->Mul->GetMultiplicand(); - VTKM_TEST_ASSERT( - test_equal(portal.Get(i), expected), "Expected ", expected, " but got ", portal.Get(i)); - } - std::cout << "\tSuccess." << std::endl; - - if (n == 0) - { - std::cout << "\tUpdate and test again..." << std::endl; - this->Mul->SetMultiplicand(3); - } - } - return true; - } - -private: - const FloatArrayHandle* Input; - Multiply* Mul; - TransformerHandle* Handle; -}; - -void Run() -{ - vtkm::cont::ArrayHandle input; - input.Allocate(ARRAY_LEN); - SetPortal(input.WritePortal()); - - TransformerHandle handle; - - std::cout << "Testing with concrete type 1 (Square)..." << std::endl; - Square sqr; - handle.Reset(&sqr, false); - vtkm::cont::TryExecute(TestStage1(input, handle)); - - std::cout << "ReleaseResources..." << std::endl; - handle.ReleaseResources(); - - std::cout << "Testing with concrete type 2 (Multiply)..." << std::endl; - Multiply mul; - handle.Reset(&mul, false); - vtkm::cont::TryExecute(TestStage2(input, mul, handle)); -} - -} // anonymous namespace - -VTKM_DEPRECATED_SUPPRESS_END - -int UnitTestVirtualObjectHandle(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(Run, argc, argv); -} diff --git a/vtkm/cont/testlib/CMakeLists.txt b/vtkm/cont/testlib/CMakeLists.txt new file mode 100644 index 000000000..fcc847ce7 --- /dev/null +++ b/vtkm/cont/testlib/CMakeLists.txt @@ -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. +##============================================================================ + +# Headers, which are used by tests all over VTK-m, are expected to be in the +# testing directory where tests are located. We could move things around so +# that this module is built in the testing directory and the tests are created +# somewhere else, which would also be confusing to developers trying to add +# tests. This seems like the least confusing option. +set(testing_library_headers + ../testing/ExplicitTestData.h + ../testing/MakeTestDataSet.h + ../testing/Testing.h + ) + +set(testing_library_sources + MakeTestDataSet.cxx + TestEqualArrayHandles.cxx + Testing.cxx + ) + +vtkm_library( + NAME vtkm_cont_testing + SOURCES ${testing_library_sources} + HEADERS ${testing_library_headers} + ) diff --git a/vtkm/cont/testing/MakeTestDataSet.cxx b/vtkm/cont/testlib/MakeTestDataSet.cxx similarity index 99% rename from vtkm/cont/testing/MakeTestDataSet.cxx rename to vtkm/cont/testlib/MakeTestDataSet.cxx index 76d01fefd..bdfee8762 100644 --- a/vtkm/cont/testing/MakeTestDataSet.cxx +++ b/vtkm/cont/testlib/MakeTestDataSet.cxx @@ -1302,7 +1302,7 @@ vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8() // Coordinates const int nVerts = 8; - const int nCells = 10; + const int nCells = 9; using CoordType = vtkm::Vec3f_32; std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, @@ -1366,7 +1366,7 @@ vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8() // Field data vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; dataSet.AddPointField("pointvar", pointvar, nVerts); dataSet.AddCellField("cellvar", cellvar, nCells); diff --git a/vtkm/cont/testing/TestEqualArrayHandles.cxx b/vtkm/cont/testlib/TestEqualArrayHandles.cxx similarity index 100% rename from vtkm/cont/testing/TestEqualArrayHandles.cxx rename to vtkm/cont/testlib/TestEqualArrayHandles.cxx diff --git a/vtkm/cont/testing/Testing.cxx b/vtkm/cont/testlib/Testing.cxx similarity index 71% rename from vtkm/cont/testing/Testing.cxx rename to vtkm/cont/testlib/Testing.cxx index c4680f982..39c324617 100644 --- a/vtkm/cont/testing/Testing.cxx +++ b/vtkm/cont/testlib/Testing.cxx @@ -16,12 +16,9 @@ namespace enum TestOptionsIndex { TEST_UNKNOWN, - DATADIR, // base dir containing test data files - BASELINEDIR, // base dir for regression test images - WRITEDIR, // base dir for generated regression test images - DEPRECATED_DATADIR, // base dir containing test data files - DEPRECATED_BASELINEDIR, // base dir for regression test images - DEPRECATED_WRITEDIR // base dir for generated regression test images + DATADIR, // base dir containing test data files + BASELINEDIR, // base dir for regression test images + WRITEDIR, // base dir for generated regression test images }; } // anonymous namespace @@ -178,30 +175,6 @@ void Testing::ParseAdditionalTestArgs(int& argc, char* argv[]) "\tPath to the write dir " "to store generated " "regression test images" }); - usage.push_back({ DEPRECATED_DATADIR, - 0, - "D", - "data-dir", - opt::VtkmArg::Required, - " --data-dir " - " " - "\tDEPRECATED: use --vtkm-data-dir instead" }); - usage.push_back({ DEPRECATED_BASELINEDIR, - 0, - "B", - "baseline-dir", - opt::VtkmArg::Required, - " --baseline-dir " - " " - "\tDEPRECATED: use --vtkm-baseline-dir instead" }); - usage.push_back({ WRITEDIR, - 0, - "", - "write-dir", - opt::VtkmArg::Required, - " --write-dir " - " " - "\tDEPRECATED: use --vtkm-write-dir instead" }); // Required to collect unknown arguments when help is off. usage.push_back({ TEST_UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" }); @@ -223,33 +196,6 @@ void Testing::ParseAdditionalTestArgs(int& argc, char* argv[]) exit(1); } - if (options[DEPRECATED_DATADIR]) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Error, - "Supplied deprecated datadir flag: " - << std::string{ options[DEPRECATED_DATADIR].name } - << ", use --vtkm-data-dir instead"); - SetAndGetTestDataBasePath(options[DEPRECATED_DATADIR].arg); - } - - if (options[DEPRECATED_BASELINEDIR]) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Error, - "Supplied deprecated baselinedir flag: " - << std::string{ options[DEPRECATED_BASELINEDIR].name } - << ", use --vtkm-baseline-dir instead"); - SetAndGetRegressionImageBasePath(options[DEPRECATED_BASELINEDIR].arg); - } - - if (options[DEPRECATED_WRITEDIR]) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Error, - "Supplied deprecated writedir flag: " - << std::string{ options[DEPRECATED_WRITEDIR].name } - << ", use --vtkm-write-dir instead"); - SetAndGetWriteDirBasePath(options[DEPRECATED_WRITEDIR].arg); - } - if (options[DATADIR]) { SetAndGetTestDataBasePath(options[DATADIR].arg); diff --git a/vtkm/cont/testlib/vtkm.module b/vtkm/cont/testlib/vtkm.module new file mode 100644 index 000000000..d474624de --- /dev/null +++ b/vtkm/cont/testlib/vtkm.module @@ -0,0 +1,7 @@ +NAME + vtkm_cont_testing +DEPENDS + vtkm_cont +GROUPS + Testing +NO_TESTING diff --git a/vtkm/cont/vtkm.module b/vtkm/cont/vtkm.module new file mode 100644 index 000000000..33396e7ae --- /dev/null +++ b/vtkm/cont/vtkm.module @@ -0,0 +1,14 @@ +NAME + vtkm_cont +GROUPS + Core +DEPENDS + vtkm_optionparser + vtkm_diy + vtkm_lcl +OPTIONAL_DEPENDS + vtkm_loguru +TEST_OPTIONAL_DEPENDS + vtkm_filter_field_conversion +TEST_DEPENDS + vtkm_source diff --git a/vtkm/exec/AtomicArrayExecutionObject.h b/vtkm/exec/AtomicArrayExecutionObject.h index 03687f170..8f730d06c 100644 --- a/vtkm/exec/AtomicArrayExecutionObject.h +++ b/vtkm/exec/AtomicArrayExecutionObject.h @@ -77,46 +77,8 @@ struct ArithType }; } -template -class AtomicArrayExecutionObject; - -template -class VTKM_DEPRECATED(1.6, "AtomicArrayExecutionObject no longer uses Device template parameter.") - AtomicArrayExecutionObject : public AtomicArrayExecutionObject -{ - using Superclass = AtomicArrayExecutionObject; - -public: - AtomicArrayExecutionObject() = default; - - // This constructor is deprecated in VTK-m 1.6. - VTKM_DEPRECATED(1.6, "AtomicArrayExecutionObject no longer uses Device template parameter.") - AtomicArrayExecutionObject(vtkm::cont::ArrayHandle handle) - : Superclass(handle, Device{}) - { - } - - VTKM_DEPRECATED(1.6, "AtomicArrayExecutionObject no longer uses Device template parameter.") - AtomicArrayExecutionObject(vtkm::cont::ArrayHandle handle, vtkm::cont::Token& token) - : Superclass(handle, Device{}, token) - { - } - - // How does this even work? - template -#ifndef VTKM_MSVC - // Some versions of visual studio seem to have a bug that causes an error with the - // deprecated attribute at this location. - VTKM_DEPRECATED(1.6, "AtomicArrayExecutionObject no longer uses Device template parameter.") -#endif - AtomicArrayExecutionObject(const PortalType& portal) - : Superclass(portal) - { - } -}; - template -class AtomicArrayExecutionObject +class AtomicArrayExecutionObject { // Checks if PortalType has a GetIteratorBegin() method that returns a // pointer. @@ -131,19 +93,6 @@ public: AtomicArrayExecutionObject() = default; - // This constructor is deprecated in VTK-m 1.6. - VTKM_CONT VTKM_DEPRECATED(1.6, "AtomicArrayExecutionObject constructor needs token.") - AtomicArrayExecutionObject(vtkm::cont::ArrayHandle handle, - vtkm::cont::DeviceAdapterId device) - : Data{ handle.PrepareForInPlace(device).GetIteratorBegin() } - , NumberOfValues{ handle.GetNumberOfValues() } - { - using PortalType = decltype(handle.PrepareForInPlace(device)); - VTKM_STATIC_ASSERT_MSG(HasPointerAccess::value, - "Source portal must return a pointer from " - "GetIteratorBegin()."); - } - VTKM_CONT AtomicArrayExecutionObject(vtkm::cont::ArrayHandle handle, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) @@ -285,15 +234,6 @@ public: static_cast(newValue)); } - VTKM_DEPRECATED(1.6, "Use CompareExchange. (Note the changed interface.)") - VTKM_EXEC ValueType CompareAndSwap(vtkm::Id index, - const ValueType& newValue, - ValueType oldValue) const - { - this->CompareExchange(index, &oldValue, newValue); - return oldValue; - } - private: ValueType* Data{ nullptr }; vtkm::Id NumberOfValues{ 0 }; diff --git a/vtkm/exec/CMakeLists.txt b/vtkm/exec/CMakeLists.txt index 71021d5e8..2f27cb907 100644 --- a/vtkm/exec/CMakeLists.txt +++ b/vtkm/exec/CMakeLists.txt @@ -18,8 +18,10 @@ set(headers CellInterpolate.h CellLocatorBoundingIntervalHierarchy.h CellLocatorMultiplexer.h + CellLocatorPartitioned.h CellLocatorRectilinearGrid.h CellLocatorTwoLevel.h + CellLocatorUniformBins.h CellLocatorUniformGrid.h CellMeasure.h ColorTable.h @@ -27,25 +29,18 @@ set(headers ConnectivityExtrude.h ConnectivityPermuted.h ConnectivityStructured.h - ExecutionWholeArray.h FieldNeighborhood.h FunctorBase.h ParametricCoordinates.h PointLocatorSparseGrid.h TaskBase.h + Variant.h ) set(header_impls ColorTable.hxx ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - CellLocator.h - PointLocator.h - ) -endif() - #----------------------------------------------------------------------------- add_subdirectory(internal) add_subdirectory(arg) @@ -53,16 +48,3 @@ add_subdirectory(arg) vtkm_declare_headers(${headers} ${header_impls} ) - - -#----------------------------------------------------------------------------- -add_subdirectory(serial) -add_subdirectory(tbb) -add_subdirectory(openmp) -add_subdirectory(cuda) -add_subdirectory(kokkos) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/exec/CellDerivative.h b/vtkm/exec/CellDerivative.h index 2afbba791..9f1e87ccc 100644 --- a/vtkm/exec/CellDerivative.h +++ b/vtkm/exec/CellDerivative.h @@ -11,7 +11,6 @@ #define vtk_m_exec_Derivative_h #include -#include #include #include #include @@ -202,28 +201,6 @@ VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& pointFieldValues, return status; } -template -VTKM_DEPRECATED( - 1.6, - "Call signature has changed to CellDerivative(field, wCoords, pcoords, shape, result).") -VTKM_EXEC vtkm::Vec CellDerivative( - const FieldVecType& field, - const WorldCoordType& wCoords, - const vtkm::Vec& pcoords, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::Vec result; - vtkm::ErrorCode status = CellDerivative(field, wCoords, pcoords, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} } } // namespace vtkm::exec diff --git a/vtkm/exec/CellEdge.h b/vtkm/exec/CellEdge.h index 2f85660b1..e748a8dec 100644 --- a/vtkm/exec/CellEdge.h +++ b/vtkm/exec/CellEdge.h @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -174,22 +173,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellEdgeNumberOfEdges(vtkm::IdComponent } } -template -VTKM_DEPRECATED(1.6, "Signature changed to CellEdgeNumberOfEdges(numPoints, shape, result).") -static inline VTKM_EXEC vtkm::IdComponent - CellEdgeNumberOfEdges(vtkm::IdComponent numPoints, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::IdComponent numEdges; - vtkm::ErrorCode status = CellEdgeNumberOfEdges(numPoints, shape, numEdges); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return numEdges; -} - template static inline VTKM_EXEC vtkm::ErrorCode CellEdgeLocalIndex(vtkm::IdComponent numPoints, vtkm::IdComponent pointIndex, @@ -290,25 +273,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellEdgeLocalIndex(vtkm::IdComponent num } } -template -VTKM_DEPRECATED( - 1.6, - "Signature changed to CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, result).") -static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(vtkm::IdComponent numPoints, - vtkm::IdComponent pointIndex, - vtkm::IdComponent edgeIndex, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::IdComponent result; - vtkm::ErrorCode status = CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - /// \brief Returns a canonical identifier for a cell edge /// /// Given information about a cell edge and the global point indices for that cell, returns a @@ -345,26 +309,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellEdgeCanonicalId( return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED( - 1.6, - "Signature changed to CellEdgeCononicalId(numPoints, edgeIndex, shape, globalIds, result).") -static inline VTKM_EXEC vtkm::Id2 - CellEdgeCanonicalId(vtkm::IdComponent numPoints, - vtkm::IdComponent edgeIndex, - CellShapeTag shape, - const GlobalPointIndicesVecType& globalPointIndicesVec, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::Id2 result; - vtkm::ErrorCode status = - CellEdgeCanonicalId(numPoints, edgeIndex, shape, globalPointIndicesVec, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} } } // namespace vtkm::exec diff --git a/vtkm/exec/CellFace.h b/vtkm/exec/CellFace.h index 199dda74d..200dceebc 100644 --- a/vtkm/exec/CellFace.h +++ b/vtkm/exec/CellFace.h @@ -11,7 +11,6 @@ #define vtk_m_exec_CellFace_h #include -#include #include #include #include @@ -149,20 +148,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellFaceNumberOfFaces(CellShapeTag shape return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED(1.6, "Signature changed to CellFaceNumberOfFaces(shape, result).") -static inline VTKM_EXEC vtkm::IdComponent - CellFaceNumberOfFaces(CellShapeTag shape, const vtkm::exec::FunctorBase& worklet) -{ - vtkm::IdComponent result; - vtkm::ErrorCode status = CellFaceNumberOfFaces(shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - template static inline VTKM_EXEC vtkm::ErrorCode CellFaceNumberOfPoints(vtkm::IdComponent faceIndex, CellShapeTag shape, @@ -186,22 +171,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellFaceNumberOfPoints(vtkm::IdComponent return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED(1.6, "Signature changed to CellFaceNumberOfPoints(faceIndex, shape, result).") -static inline VTKM_EXEC vtkm::IdComponent - CellFaceNumberOfPoints(vtkm::IdComponent faceIndex, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::IdComponent result; - vtkm::ErrorCode status = CellFaceNumberOfPoints(faceIndex, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - template static inline VTKM_EXEC vtkm::ErrorCode CellFaceShape(vtkm::IdComponent faceIndex, CellShapeTag shape, @@ -231,21 +200,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellFaceShape(vtkm::IdComponent faceInde return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED(1.6, "Signature changed to CellFaceShape(faceIndex, shape, result).") -static inline VTKM_EXEC vtkm::UInt8 CellFaceShape(vtkm::IdComponent faceIndex, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::UInt8 result; - vtkm::ErrorCode status = CellFaceShape(faceIndex, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - template static inline VTKM_EXEC vtkm::ErrorCode CellFaceLocalIndex(vtkm::IdComponent pointIndex, vtkm::IdComponent faceIndex, @@ -267,23 +221,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellFaceLocalIndex(vtkm::IdComponent poi return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED(1.6, - "Signature changed to CellFaceLocalIndex(pointIndex, faceIndex, shape, result).") -static inline VTKM_EXEC vtkm::IdComponent CellFaceLocalIndex(vtkm::IdComponent pointIndex, - vtkm::IdComponent faceIndex, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::IdComponent result; - vtkm::ErrorCode status = CellFaceLocalIndex(pointIndex, faceIndex, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - /// \brief Returns a canonical identifier for a cell face /// /// Given information about a cell face and the global point indices for that cell, returns a @@ -369,23 +306,6 @@ static inline VTKM_EXEC vtkm::ErrorCode CellFaceCanonicalId( return vtkm::ErrorCode::Success; } -template -VTKM_DEPRECATED(1.6, - "Signature changed to CellFaceCononicalId(faceIndex, shape, globalIds, result).") -static inline VTKM_EXEC vtkm::Id3 - CellFaceCanonicalId(vtkm::IdComponent faceIndex, - CellShapeTag shape, - const GlobalPointIndicesVecType& globalPointIndicesVec, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::Id3 result; - vtkm::ErrorCode status = CellFaceCanonicalId(faceIndex, shape, globalPointIndicesVec, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} } } // namespace vtkm::exec diff --git a/vtkm/exec/CellInterpolate.h b/vtkm/exec/CellInterpolate.h index e2fb54256..7224c6bd0 100644 --- a/vtkm/exec/CellInterpolate.h +++ b/vtkm/exec/CellInterpolate.h @@ -11,7 +11,6 @@ #define vtk_m_exec_Interpolate_h #include -#include #include #include #include @@ -177,24 +176,6 @@ VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType& pointFieldValues, return status; } -//----------------------------------------------------------------------------- -template -VTKM_DEPRECATED(1.6, - "Signature changed to CellInterpolate(pointFieldValues, pcoords, shape, result).") -VTKM_EXEC typename FieldVecType::ComponentType - CellInterpolate(const FieldVecType& pointFieldValues, - const vtkm::Vec& pcoords, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - typename FieldVecType::ComponentType result; - vtkm::ErrorCode status = CellInterpolate(pointFieldValues, pcoords, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} } } // namespace vtkm::exec diff --git a/vtkm/exec/CellLocator.h b/vtkm/exec/CellLocator.h deleted file mode 100644 index c853d418f..000000000 --- a/vtkm/exec/CellLocator.h +++ /dev/null @@ -1,69 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_exec_CellLocator_h -#define vtk_m_exec_CellLocator_h - -#include -#include -#include -#include -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "CellLocator with virtual methods is removed. Do not include CellLocator.h" -#endif - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace exec -{ - -class VTKM_DEPRECATED( - 1.6, - "CellLocator with virtual methods no longer supported. Use CellLocatorGeneral.") - VTKM_ALWAYS_EXPORT CellLocator : public vtkm::VirtualObjectBase -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN -public: - VTKM_EXEC_CONT virtual ~CellLocator() noexcept - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC - virtual vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, - vtkm::Id& cellId, - vtkm::Vec3f& parametric) const = 0; - - VTKM_DEPRECATED(1.6, "FindCell no longer takes worklet argument.") - VTKM_EXEC - void FindCell(const vtkm::Vec3f& point, - vtkm::Id& cellId, - vtkm::Vec3f& parametric, - const vtkm::exec::FunctorBase& worklet) const - { - vtkm::ErrorCode status = this->FindCell(point, cellId, parametric); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - } - VTKM_DEPRECATED_SUPPRESS_END -}; - -} // namespace exec -} // namespace vtkm - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtk_m_exec_CellLocator_h diff --git a/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h b/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h index d80306982..d60a52c3d 100644 --- a/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h +++ b/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h @@ -176,11 +176,6 @@ public: } } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC CellLocatorBoundingIntervalHierarchy* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const CellLocatorBoundingIntervalHierarchy* operator->() const { return this; } - private: enum struct FindCellState { diff --git a/vtkm/exec/CellLocatorMultiplexer.h b/vtkm/exec/CellLocatorMultiplexer.h index 619ae0a9c..7807e6155 100644 --- a/vtkm/exec/CellLocatorMultiplexer.h +++ b/vtkm/exec/CellLocatorMultiplexer.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace vtkm { @@ -55,12 +55,12 @@ struct FindCellFunctor template class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer { - vtkm::exec::internal::Variant Locators; + vtkm::exec::Variant Locators; public: CellLocatorMultiplexer() = default; - using LastCell = vtkm::exec::internal::Variant; + using LastCell = vtkm::exec::Variant; template VTKM_CONT CellLocatorMultiplexer(const Locator& locator) @@ -83,11 +83,6 @@ public: return this->Locators.CastAndCall( detail::FindCellFunctor{}, point, cellId, parametric, lastCell); } - - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC CellLocatorMultiplexer* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const CellLocatorMultiplexer* operator->() const { return this; } }; } diff --git a/vtkm/exec/CellLocatorPartitioned.h b/vtkm/exec/CellLocatorPartitioned.h new file mode 100644 index 000000000..c89ce8149 --- /dev/null +++ b/vtkm/exec/CellLocatorPartitioned.h @@ -0,0 +1,82 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_exec_CellLocatorPartitioned_h +#define vtk_m_exec_CellLocatorPartitioned_h + +#include +#include +#include + +namespace vtkm +{ +namespace exec +{ +class VTKM_ALWAYS_EXPORT CellLocatorPartitioned +{ +private: + vtkm::cont::ArrayHandle::ReadPortalType Locators; + vtkm::cont::ArrayHandle::ReadPortalType>::ReadPortalType + Ghosts; + +public: + VTKM_CONT CellLocatorPartitioned() = default; + VTKM_CONT CellLocatorPartitioned( + const vtkm::cont::ArrayHandle::ReadPortalType& + locators, + vtkm::cont::ArrayHandle::ReadPortalType>::ReadPortalType + ghosts) + : Locators(locators) + , Ghosts(ghosts) + { + } + + VTKM_EXEC + vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, + vtkm::Id& partitionId, + vtkm::Id& cellId, + vtkm::Vec3f& parametric) const + { + bool found = 0; + for (vtkm::Id partitionIndex = 0; partitionIndex < this->Locators.GetNumberOfValues(); + ++partitionIndex) + { + vtkm::Id cellIndex; + vtkm ::Vec3f parametricLocal; + vtkm ::ErrorCode status = + Locators.Get(partitionIndex).FindCell(point, cellIndex, parametricLocal); + if (status != vtkm ::ErrorCode ::Success) + { + } + else + { + if (Ghosts.Get(partitionIndex).Get(cellIndex) == 0) + { + partitionId = partitionIndex; + cellId = cellIndex; + parametric = parametricLocal; + found = true; + break; + } + } + } + if (found) + { + return vtkm::ErrorCode::Success; + } + else + { + return vtkm::ErrorCode::CellNotFound; + } + } +}; +} //namespace exec +} //namespace vtkm + +#endif //vtk_m_exec_CellLocatorPartitioned_h diff --git a/vtkm/exec/CellLocatorRectilinearGrid.h b/vtkm/exec/CellLocatorRectilinearGrid.h index ede7b95f6..e5bf48655 100644 --- a/vtkm/exec/CellLocatorRectilinearGrid.h +++ b/vtkm/exec/CellLocatorRectilinearGrid.h @@ -157,11 +157,6 @@ public: return vtkm::ErrorCode::Success; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC CellLocatorRectilinearGrid* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const CellLocatorRectilinearGrid* operator->() const { return this; } - private: vtkm::Id PlaneSize; vtkm::Id RowSize; diff --git a/vtkm/exec/CellLocatorTwoLevel.h b/vtkm/exec/CellLocatorTwoLevel.h index d0212efc1..5d0caea8a 100644 --- a/vtkm/exec/CellLocatorTwoLevel.h +++ b/vtkm/exec/CellLocatorTwoLevel.h @@ -195,11 +195,6 @@ public: return this->FindCellImpl(point, cellId, parametric, lastCell); } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC CellLocatorTwoLevel* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const CellLocatorTwoLevel* operator->() const { return this; } - private: VTKM_EXEC vtkm::ErrorCode PointInCell(const vtkm::Vec3f& point, diff --git a/vtkm/exec/CellLocatorUniformBins.h b/vtkm/exec/CellLocatorUniformBins.h new file mode 100644 index 000000000..223ae02ff --- /dev/null +++ b/vtkm/exec/CellLocatorUniformBins.h @@ -0,0 +1,266 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_exec_CellLocatorUniformBins_h +#define vtk_m_exec_CellLocatorUniformBins_h + +#include +#include + +#include +#include + +#include +#include +#include + +namespace vtkm +{ +namespace exec +{ + +//-------------------------------------------------------------------- +template +class VTKM_ALWAYS_EXPORT CellLocatorUniformBins +{ + template + using ReadPortal = typename vtkm::cont::ArrayHandle::ReadPortalType; + + using CoordsPortalType = + typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType; + + using CellIdArrayType = vtkm::cont::ArrayHandle; + using CellIdOffsetArrayType = vtkm::cont::ArrayHandle; + using CellIdReadPortal = + typename vtkm::cont::ArrayHandleGroupVecVariable::ReadPortalType; + +public: + template + VTKM_CONT CellLocatorUniformBins( + const vtkm::Id3& cellDims, + const vtkm::Vec3f& origin, + const vtkm::Vec3f& maxPoint, + const vtkm::Vec3f& invSpacing, + const vtkm::Id3& maxCellIds, + const vtkm::cont::ArrayHandleGroupVecVariable& cellIds, + const CellSetType& cellSet, + const vtkm::cont::CoordinateSystem& coords, + vtkm::cont::DeviceAdapterId device, + vtkm::cont::Token& token) + : CellDims(cellDims) + , Origin(origin) + , MaxPoint(maxPoint) + , InvSpacing(invSpacing) + , MaxCellIds(maxCellIds) + , CellIds(cellIds.PrepareForInput(device, token)) + , CellSet(cellSet.PrepareForInput(device, + vtkm::TopologyElementTagCell{}, + vtkm::TopologyElementTagPoint{}, + token)) + , Coords(coords.GetDataAsMultiplexer().PrepareForInput(device, token)) + { + } + + struct LastCell + { + vtkm::Id CellId = -1; + vtkm::Id BinIdx = -1; + }; + + VTKM_EXEC + vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, + vtkm::Id& cellId, + vtkm::Vec3f& parametric) const + { + LastCell lastCell; + return this->FindCellImpl(point, cellId, parametric, lastCell); + } + + VTKM_EXEC + vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, + vtkm::Id& cellId, + vtkm::Vec3f& parametric, + LastCell& lastCell) const + { + //See if point is inside the last cell. + vtkm::Vec3f pc; + if ((lastCell.CellId >= 0) && (lastCell.CellId < this->CellSet.GetNumberOfElements()) && + this->PointInCell(point, lastCell.CellId, pc) == vtkm::ErrorCode::Success) + { + parametric = pc; + cellId = lastCell.CellId; + return vtkm::ErrorCode::Success; + } + + //See if it's in the last bin. + if ((lastCell.BinIdx >= 0) && (lastCell.BinIdx < this->CellIds.GetNumberOfValues()) && + this->PointInBin(point, lastCell.BinIdx, cellId, pc) == vtkm::ErrorCode::Success) + { + parametric = pc; + lastCell.CellId = cellId; + return vtkm::ErrorCode::Success; + } + + return this->FindCellImpl(point, cellId, parametric, lastCell); + } + + VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") + VTKM_EXEC CellLocatorUniformBins* operator->() { return this; } + VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") + VTKM_EXEC const CellLocatorUniformBins* operator->() const { return this; } + +private: + VTKM_EXEC bool IsInside(const vtkm::Vec3f& point) const + { + if (point[0] < this->Origin[0] || point[0] > this->MaxPoint[0]) + return false; + if (point[1] < this->Origin[1] || point[1] > this->MaxPoint[1]) + return false; + if (point[2] < this->Origin[2] || point[2] > this->MaxPoint[2]) + return false; + + return true; + } + + VTKM_EXEC + vtkm::ErrorCode FindCellImpl(const vtkm::Vec3f& point, + vtkm::Id& cellId, + vtkm::Vec3f& parametric, + LastCell& lastCell) const + { + lastCell.CellId = -1; + lastCell.BinIdx = -1; + + if (!this->IsInside(point)) + { + cellId = -1; + return vtkm::ErrorCode::CellNotFound; + } + + //Find the bin containing the point. + vtkm::Id3 logicalCell(0, 0, 0); + + vtkm::Vec3f temp; + temp = point - this->Origin; + temp = temp * this->InvSpacing; + + //make sure that if we border the upper edge, we sample the correct cell + logicalCell = vtkm::Min(vtkm::Id3(temp), this->MaxCellIds); + + vtkm::Id binIdx = + (logicalCell[2] * this->CellDims[1] + logicalCell[1]) * this->CellDims[0] + logicalCell[0]; + + vtkm::Vec3f pc; + if (this->PointInBin(point, binIdx, cellId, pc) == vtkm::ErrorCode::Success) + { + parametric = pc; + lastCell.CellId = cellId; + lastCell.BinIdx = binIdx; + return vtkm::ErrorCode::Success; + } + + return vtkm::ErrorCode::CellNotFound; + } + + template + VTKM_EXEC vtkm::Bounds ComputeCellBounds(const PointsVecType& points) const + { + auto numPoints = vtkm::VecTraits::GetNumberOfComponents(points); + + vtkm::Bounds bounds; + for (vtkm::IdComponent i = 0; i < numPoints; ++i) + bounds.Include(points[i]); + + return bounds; + } + + // TODO: This function may return false positives for non 3D cells as the + // tests are done on the projection of the point on the cell. Extra checks + // should be added to test if the point actually falls on the cell. + template + VTKM_EXEC vtkm::ErrorCode PointInsideCell(vtkm::Vec3f point, + CellShapeTag cellShape, + CoordsType cellPoints, + vtkm::Vec3f& parametricCoordinates, + bool& inside) const + { + auto bounds = this->ComputeCellBounds(cellPoints); + if (bounds.Contains(point)) + { + VTKM_RETURN_ON_ERROR(vtkm::exec::WorldCoordinatesToParametricCoordinates( + cellPoints, point, cellShape, parametricCoordinates)); + inside = vtkm::exec::CellInside(parametricCoordinates, cellShape); + } + else + { + inside = false; + } + // Return success error code even point is not inside this cell + return vtkm::ErrorCode::Success; + } + + VTKM_EXEC + vtkm::ErrorCode PointInBin(const vtkm::Vec3f& point, + const vtkm::Id& binIdx, + vtkm::Id& cellId, + vtkm::Vec3f& parametric) const + { + auto binIds = this->CellIds.Get(binIdx); + + for (vtkm::IdComponent i = 0; i < binIds.GetNumberOfComponents(); i++) + { + vtkm::Id cid = binIds[i]; + vtkm::Vec3f pc; + if (this->PointInCell(point, cid, pc) == vtkm::ErrorCode::Success) + { + cellId = cid; + parametric = pc; + return vtkm::ErrorCode::Success; + } + } + + return vtkm::ErrorCode::CellNotFound; + } + + VTKM_EXEC + vtkm::ErrorCode PointInCell(const vtkm::Vec3f& point, + const vtkm::Id& cid, + vtkm::Vec3f& parametric) const + { + auto indices = this->CellSet.GetIndices(cid); + auto pts = vtkm::make_VecFromPortalPermute(&indices, this->Coords); + vtkm::Vec3f pc; + bool inside; + auto status = this->PointInsideCell(point, this->CellSet.GetCellShape(cid), pts, pc, inside); + if (status == vtkm::ErrorCode::Success && inside) + { + parametric = pc; + return vtkm::ErrorCode::Success; + } + + return vtkm::ErrorCode::CellNotFound; + } + + vtkm::Id3 CellDims; + vtkm::Vec3f Origin; + vtkm::Vec3f MaxPoint; + vtkm::Vec3f InvSpacing; + vtkm::Id3 MaxCellIds; + + CellIdReadPortal CellIds; + + CellStructureType CellSet; + CoordsPortalType Coords; +}; + +} +} // vtkm::exec + +#endif //vtk_m_exec_CellLocatorUniformBins_h diff --git a/vtkm/exec/CellLocatorUniformGrid.h b/vtkm/exec/CellLocatorUniformGrid.h index bb5398614..63293ae27 100644 --- a/vtkm/exec/CellLocatorUniformGrid.h +++ b/vtkm/exec/CellLocatorUniformGrid.h @@ -95,11 +95,6 @@ public: return vtkm::ErrorCode::Success; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC CellLocatorUniformGrid* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const CellLocatorUniformGrid* operator->() const { return this; } - private: vtkm::Id3 CellDims; vtkm::Id3 MaxCellIds; diff --git a/vtkm/exec/ColorTable.h b/vtkm/exec/ColorTable.h index 92a689024..3eb33a232 100644 --- a/vtkm/exec/ColorTable.h +++ b/vtkm/exec/ColorTable.h @@ -10,7 +10,6 @@ #ifndef vtk_m_exec_ColorTable_h #define vtk_m_exec_ColorTable_h -#include #include namespace vtkm @@ -88,44 +87,6 @@ private: vtkm::Float32 weight) const; }; -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableBase - : public vtkm::exec::ColorTable -{ -}; - -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableRGB final - : public ColorTable -{ -public: - ColorTableRGB() { this->Space = vtkm::ColorSpace::RGB; } -}; - -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableHSV final - : public ColorTable -{ -public: - ColorTableHSV() { this->Space = vtkm::ColorSpace::HSV; } -}; - -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableHSVWrap final - : public ColorTable -{ -public: - ColorTableHSVWrap() { this->Space = vtkm::ColorSpace::HSVWrap; } -}; - -class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableLab final - : public ColorTable -{ -public: - ColorTableLab() { this->Space = vtkm::ColorSpace::Lab; } -}; - -class VTKM_ALWAYS_EXPORT ColorTableDiverging final : public ColorTable -{ -public: - ColorTableDiverging() { this->Space = vtkm::ColorSpace::Diverging; } -}; } } diff --git a/vtkm/exec/ExecutionWholeArray.h b/vtkm/exec/ExecutionWholeArray.h deleted file mode 100644 index bd71c6dcf..000000000 --- a/vtkm/exec/ExecutionWholeArray.h +++ /dev/null @@ -1,191 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_exec_ExecutionWholeArray_h -#define vtk_m_exec_ExecutionWholeArray_h - -#include -#include - -#include - -namespace vtkm -{ -namespace exec -{ - -/// The following classes have been sort of deprecated and are meant to be used -/// internally only. Please use the \c WholeArrayIn, \c WholeArrayOut, and -/// \c WholeArrayInOut \c ControlSignature tags instead. - -/// \c ExecutionWholeArray is an execution object that allows an array handle -/// content to be a parameter in an execution environment -/// function. This can be used to allow worklets to have a shared search -/// structure. -/// -template -class ExecutionWholeArray; - -template -class ExecutionWholeArray -{ -public: - using ValueType = T; - using HandleType = vtkm::cont::ArrayHandle; - using PortalType = typename HandleType::WritePortalType; - - VTKM_CONT - ExecutionWholeArray() - : Portal() - { - } - - VTKM_CONT - ExecutionWholeArray(HandleType& handle, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) - : Portal(handle.PrepareForInPlace(device, token)) - { - } - - VTKM_CONT - ExecutionWholeArray(HandleType& handle, - vtkm::Id length, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) - : Portal(handle.PrepareForOutput(length, device, token)) - { - } - - VTKM_EXEC - vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); } - - VTKM_EXEC - T Get(vtkm::Id index) const { return this->Portal.Get(index); } - - VTKM_EXEC - T operator[](vtkm::Id index) const { return this->Portal.Get(index); } - - VTKM_EXEC - void Set(vtkm::Id index, const T& t) const { this->Portal.Set(index, t); } - - VTKM_EXEC - const PortalType& GetPortal() const { return this->Portal; } - -private: - PortalType Portal; -}; - -template -class VTKM_DEPRECATED(1.6, "ExecutionWholeArray no longer uses Device template parameter.") - ExecutionWholeArray : public ExecutionWholeArray -{ - using Superclass = ExecutionWholeArray; - using HandleType = typename Superclass::HandleType; - -public: - using Superclass::Superclass; - - VTKM_CONT ExecutionWholeArray(HandleType& handle) - : Superclass(handle, Device{}, vtkm::cont::Token{}) - { - } - - VTKM_CONT - ExecutionWholeArray(HandleType& handle, vtkm::Id length) - : Superclass(handle, length, Device{}, vtkm::cont::Token{}) - { - } - - VTKM_CONT - ExecutionWholeArray(HandleType& handle, vtkm::cont::Token& token) - : Superclass(handle, Device{}, token) - { - } - - VTKM_CONT - ExecutionWholeArray(HandleType& handle, vtkm::Id length, vtkm::cont::Token& token) - : Superclass(handle, length, Device{}, token) - { - } -}; - -/// \c ExecutionWholeArrayConst is an execution object that allows an array handle -/// content to be a parameter in an execution environment -/// function. This can be used to allow worklets to have a shared search -/// structure -/// -template -class ExecutionWholeArrayConst; - -template -class ExecutionWholeArrayConst -{ -public: - using ValueType = T; - using HandleType = vtkm::cont::ArrayHandle; - using PortalType = typename HandleType::ReadPortalType; - - VTKM_CONT - ExecutionWholeArrayConst() - : Portal() - { - } - - VTKM_CONT - ExecutionWholeArrayConst(const HandleType& handle, - vtkm::cont::DeviceAdapterId device, - vtkm::cont::Token& token) - : Portal(handle.PrepareForInput(device, token)) - { - } - - VTKM_EXEC - vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); } - - VTKM_EXEC - T Get(vtkm::Id index) const { return this->Portal.Get(index); } - - VTKM_EXEC - T operator[](vtkm::Id index) const { return this->Portal.Get(index); } - - VTKM_EXEC - const PortalType& GetPortal() const { return this->Portal; } - -private: - PortalType Portal; -}; - -template -class VTKM_DEPRECATED(1.6, "ExecutionWholeArray no longer uses Device template parameter.") - ExecutionWholeArrayConst : public ExecutionWholeArrayConst -{ - using Superclass = ExecutionWholeArrayConst; - using HandleType = typename Superclass::HandleType; - -public: - using Superclass::Superclass; - - VTKM_CONT ExecutionWholeArrayConst(HandleType& handle) - : Superclass(handle, Device{}, vtkm::cont::Token{}) - { - } - - VTKM_CONT - ExecutionWholeArrayConst(HandleType& handle, vtkm::cont::Token& token) - : Superclass(handle, Device{}, token) - { - } -}; - - -} -} // namespace vtkm::exec - -#endif //vtk_m_exec_ExecutionWholeArray_h diff --git a/vtkm/exec/ParametricCoordinates.h b/vtkm/exec/ParametricCoordinates.h index d33585420..68b826feb 100644 --- a/vtkm/exec/ParametricCoordinates.h +++ b/vtkm/exec/ParametricCoordinates.h @@ -136,39 +136,6 @@ static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter( return status; } -template -VTKM_DEPRECATED(1.6, "Signature changed to ParametricCoordinatesCenter(numPoints, shape, result).") -static inline VTKM_EXEC void ParametricCoordinatesCenter(vtkm::IdComponent numPoints, - vtkm::Vec& pcoords, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::ErrorCode status = ParametricCoordinatesCenter(numPoints, shape, pcoords); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } -} - -/// Returns the parametric center of the given cell shape with the given number -/// of points. -/// -template -VTKM_DEPRECATED(1.6, "Signature changed to ParametricCoordinatesCenter(numPoints, shape, result).") -static inline VTKM_EXEC vtkm::Vec3f - ParametricCoordinatesCenter(vtkm::IdComponent numPoints, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::Vec3f pcoords(0.0f); - vtkm::ErrorCode status = ParametricCoordinatesCenter(numPoints, shape, pcoords); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return pcoords; -} - //----------------------------------------------------------------------------- template static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint( @@ -293,45 +260,6 @@ static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint( return status; } -template -VTKM_DEPRECATED( - 1.6, - "Signature changed to ParametricCoordinatesPoint(numPoints, pointIndex, shape, result).") -static inline VTKM_EXEC void ParametricCoordinatesPoint(vtkm::IdComponent numPoints, - vtkm::IdComponent pointIndex, - vtkm::Vec& pcoords, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::ErrorCode status = ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } -} - -/// Returns the parametric coordinate of a cell point of the given shape with -/// the given number of points. -/// -template -VTKM_DEPRECATED( - 1.6, - "Signature changed to ParametricCoordinatesPoint(numPoints, pointIndex, shape, result).") -static inline VTKM_EXEC vtkm::Vec3f - ParametricCoordinatesPoint(vtkm::IdComponent numPoints, - vtkm::IdComponent pointIndex, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - vtkm::Vec3f pcoords; - vtkm::ErrorCode status = ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return pcoords; -} - //----------------------------------------------------------------------------- namespace internal { @@ -447,26 +375,6 @@ static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates( return status; } -template -VTKM_DEPRECATED(1.6, - "Signature changed to " - "ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, result).") -static inline VTKM_EXEC typename WorldCoordVector::ComponentType - ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords, - const vtkm::Vec& pcoords, - CellShapeTag shape, - const vtkm::exec::FunctorBase& worklet) -{ - typename WorldCoordVector::ComponentType result; - vtkm::ErrorCode status = - ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, result); - if (status != vtkm::ErrorCode::Success) - { - worklet.RaiseError(vtkm::ErrorString(status)); - } - return result; -} - //----------------------------------------------------------------------------- namespace internal { @@ -654,31 +562,6 @@ static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates( return status; } -template -VTKM_DEPRECATED(1.6, - "Signature changed to " - "WorldCoordinatesToParametricCoordinates(pointWCoords, wcoords, shape, result).") -static inline VTKM_EXEC typename WorldCoordVector::ComponentType - WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords, - const typename WorldCoordVector::ComponentType& wcoords, - CellShapeTag shape, - bool& success, - const vtkm::exec::FunctorBase& worklet) -{ - typename WorldCoordVector::ComponentType result; - vtkm::ErrorCode status = - WorldCoordinatesToParametricCoordinates(pointWCoords, wcoords, shape, result); - if (status != vtkm::ErrorCode::Success) - { - success = false; - worklet.RaiseError(vtkm::ErrorString(status)); - } - else - { - success = true; - } - return result; -} } } // namespace vtkm::exec diff --git a/vtkm/exec/PointLocator.h b/vtkm/exec/PointLocator.h deleted file mode 100644 index e781314e0..000000000 --- a/vtkm/exec/PointLocator.h +++ /dev/null @@ -1,49 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_exec_PointLocator_h -#define vtk_m_exec_PointLocator_h - -#include - -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "PointLocator with virtual methods is removed. Do not include PointLocator.h" -#endif - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ -namespace exec -{ - -class VTKM_DEPRECATED(1.6, "PointLocator with virtual methods no longer supported.") - VTKM_ALWAYS_EXPORT PointLocator : public vtkm::VirtualObjectBase -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN -public: - VTKM_EXEC_CONT virtual ~PointLocator() noexcept - { - // This must not be defaulted, since defaulted virtual destructors are - // troublesome with CUDA __host__ __device__ markup. - } - - VTKM_EXEC - virtual void FindNearestNeighbor(const vtkm::Vec3f& queryPoint, - vtkm::Id& pointId, - vtkm::FloatDefault& distanceSquared) const = 0; - VTKM_DEPRECATED_SUPPRESS_END -}; - -} // vtkm::exec -} // vtkm - -VTKM_DEPRECATED_SUPPRESS_END - -#endif // vtk_m_exec_PointLocator_h diff --git a/vtkm/exec/PointLocatorSparseGrid.h b/vtkm/exec/PointLocatorSparseGrid.h index 8409ad427..1ad0b3a73 100644 --- a/vtkm/exec/PointLocatorSparseGrid.h +++ b/vtkm/exec/PointLocatorSparseGrid.h @@ -12,7 +12,6 @@ #include -#include #include namespace vtkm @@ -83,11 +82,6 @@ public: this->FindInBox(queryPoint, ijk, level, nearestNeighborId, distance2); } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC PointLocatorSparseGrid* operator->() { return this; } - VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.") - VTKM_EXEC const PointLocatorSparseGrid* operator->() const { return this; } - private: vtkm::Vec3f Min; vtkm::Id3 Dims; diff --git a/vtkm/exec/internal/Variant.h b/vtkm/exec/Variant.h similarity index 100% rename from vtkm/exec/internal/Variant.h rename to vtkm/exec/Variant.h diff --git a/vtkm/exec/arg/CMakeLists.txt b/vtkm/exec/arg/CMakeLists.txt index 69e25cfc6..92e774ead 100644 --- a/vtkm/exec/arg/CMakeLists.txt +++ b/vtkm/exec/arg/CMakeLists.txt @@ -46,9 +46,3 @@ set(headers ) vtkm_declare_headers(${headers}) - - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/exec/arg/testing/CMakeLists.txt b/vtkm/exec/arg/testing/CMakeLists.txt deleted file mode 100644 index 1a79f67a0..000000000 --- a/vtkm/exec/arg/testing/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ -set(headers - ThreadIndicesTesting.h - ) - -vtkm_declare_headers(${headers}) - -set(unit_tests - UnitTestExecutionSignatureTag.cxx - UnitTestFetchArrayDirectIn.cxx - UnitTestFetchArrayDirectIn3d.cxx - UnitTestFetchArrayDirectInOut.cxx - UnitTestFetchArrayDirectOut.cxx - UnitTestFetchArrayNeighborhoodIn.cxx - UnitTestFetchArrayTopologyMapIn.cxx - UnitTestFetchExecObject.cxx - UnitTestFetchWorkIndex.cxx - ) - -vtkm_unit_tests(SOURCES ${unit_tests}) diff --git a/vtkm/exec/cuda/internal/CMakeLists.txt b/vtkm/exec/cuda/internal/CMakeLists.txt index c942726e5..1f67c892b 100644 --- a/vtkm/exec/cuda/internal/CMakeLists.txt +++ b/vtkm/exec/cuda/internal/CMakeLists.txt @@ -23,8 +23,3 @@ vtkm_declare_headers(${headers}) set_source_files_properties(ThrustPatches.h PROPERTIES VTKm_CANT_BE_HEADER_TESTED TRUE) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::cuda AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/exec/cuda/internal/testing/CMakeLists.txt b/vtkm/exec/cuda/testing/CMakeLists.txt similarity index 100% rename from vtkm/exec/cuda/internal/testing/CMakeLists.txt rename to vtkm/exec/cuda/testing/CMakeLists.txt diff --git a/vtkm/exec/cuda/internal/testing/UnitTestTaskStrided.cu b/vtkm/exec/cuda/testing/UnitTestTaskStrided.cu similarity index 97% rename from vtkm/exec/cuda/internal/testing/UnitTestTaskStrided.cu rename to vtkm/exec/cuda/testing/UnitTestTaskStrided.cu index 065809da1..c79ac2924 100644 --- a/vtkm/exec/cuda/internal/testing/UnitTestTaskStrided.cu +++ b/vtkm/exec/cuda/testing/UnitTestTaskStrided.cu @@ -274,7 +274,8 @@ void TestNormalFunctorInvoke() vtkm::Id inputTestValues[3] = { 5, 5, 6 }; - vtkm::cont::ArrayHandle input = vtkm::cont::make_ArrayHandle(inputTestValues, 3); + vtkm::cont::ArrayHandle input = + vtkm::cont::make_ArrayHandle(inputTestValues, 3, vtkm::CopyFlag::Off); vtkm::cont::ArrayHandle output; vtkm::internal::FunctionInterface execObjects = @@ -331,8 +332,10 @@ void TestErrorFunctorInvoke() vtkm::Id inputTestValue = 5; vtkm::Id outputTestValue = static_cast(0xDEADDEAD); - vtkm::cont::ArrayHandle input = vtkm::cont::make_ArrayHandle(&inputTestValue, 1); - vtkm::cont::ArrayHandle output = vtkm::cont::make_ArrayHandle(&outputTestValue, 1); + vtkm::cont::ArrayHandle input = + vtkm::cont::make_ArrayHandle(&inputTestValue, 1, vtkm::CopyFlag::Off); + vtkm::cont::ArrayHandle output = + vtkm::cont::make_ArrayHandle(&outputTestValue, 1, vtkm::CopyFlag::Off); vtkm::internal::FunctionInterface execObjects = vtkm::internal::make_FunctionInterface( diff --git a/vtkm/exec/cuda/internal/testing/UnitTestTextureMemorySupport.cu b/vtkm/exec/cuda/testing/UnitTestTextureMemorySupport.cu similarity index 100% rename from vtkm/exec/cuda/internal/testing/UnitTestTextureMemorySupport.cu rename to vtkm/exec/cuda/testing/UnitTestTextureMemorySupport.cu diff --git a/vtkm/exec/cuda/vtkm.module b/vtkm/exec/cuda/vtkm.module new file mode 100644 index 000000000..6c16b6d6f --- /dev/null +++ b/vtkm/exec/cuda/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_exec_cuda +GROUPS + Core +DEPENDS + vtkm_exec +TEST_DEPENDS + vtkm_cuda diff --git a/vtkm/exec/internal/CMakeLists.txt b/vtkm/exec/internal/CMakeLists.txt index 4ce933838..dcc478a97 100644 --- a/vtkm/exec/internal/CMakeLists.txt +++ b/vtkm/exec/internal/CMakeLists.txt @@ -14,14 +14,9 @@ set(headers ReduceByKeyLookup.h TaskSingular.h TwoLevelUniformGridExecutionObject.h - Variant.h WorkletInvokeFunctorDetail.h ) vtkm_declare_headers(${headers}) vtkm_pyexpander_generated_file(WorkletInvokeFunctorDetail.h) - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/exec/internal/testing/CMakeLists.txt b/vtkm/exec/internal/testing/CMakeLists.txt deleted file mode 100644 index a9b56eaae..000000000 --- a/vtkm/exec/internal/testing/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(headers - TestingTaskTiling.h - ) - -vtkm_declare_headers(${headers}) - -set(unit_tests - UnitTestErrorMessageBuffer.cxx - UnitTestTaskSingular.cxx - UnitTestVariant.cxx - UnitTestWorkletInvokeFunctor.cxx - ) -vtkm_unit_tests(SOURCES ${unit_tests}) diff --git a/vtkm/exec/kokkos/vtkm.module b/vtkm/exec/kokkos/vtkm.module new file mode 100644 index 000000000..9add064b9 --- /dev/null +++ b/vtkm/exec/kokkos/vtkm.module @@ -0,0 +1,7 @@ +NAME + vtkm_exec_kokkos +GROUPS + Core +DEPENDS + vtkm_exec +NO_TESTING diff --git a/vtkm/exec/openmp/internal/CMakeLists.txt b/vtkm/exec/openmp/internal/CMakeLists.txt index a5ef2681a..6636141c2 100644 --- a/vtkm/exec/openmp/internal/CMakeLists.txt +++ b/vtkm/exec/openmp/internal/CMakeLists.txt @@ -13,8 +13,3 @@ set(headers ) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_OPENMP AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/exec/openmp/internal/testing/CMakeLists.txt b/vtkm/exec/openmp/testing/CMakeLists.txt similarity index 100% rename from vtkm/exec/openmp/internal/testing/CMakeLists.txt rename to vtkm/exec/openmp/testing/CMakeLists.txt diff --git a/vtkm/exec/openmp/internal/testing/UnitTestTaskTilingOpenMP.cxx b/vtkm/exec/openmp/testing/UnitTestTaskTilingOpenMP.cxx similarity index 92% rename from vtkm/exec/openmp/internal/testing/UnitTestTaskTilingOpenMP.cxx rename to vtkm/exec/openmp/testing/UnitTestTaskTilingOpenMP.cxx index fdc0be884..ef07b56b0 100644 --- a/vtkm/exec/openmp/internal/testing/UnitTestTaskTilingOpenMP.cxx +++ b/vtkm/exec/openmp/testing/UnitTestTaskTilingOpenMP.cxx @@ -10,7 +10,7 @@ #include #include -#include +#include int UnitTestTaskTilingOpenMP(int argc, char* argv[]) { diff --git a/vtkm/exec/openmp/vtkm.module b/vtkm/exec/openmp/vtkm.module new file mode 100644 index 000000000..f3a4f08cf --- /dev/null +++ b/vtkm/exec/openmp/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_exec_openmp +GROUPS + Core +DEPENDS + vtkm_exec +TEST_DEPENDS + vtkm_openmp diff --git a/vtkm/exec/serial/internal/CMakeLists.txt b/vtkm/exec/serial/internal/CMakeLists.txt index 42e374fdb..5cf7d8576 100644 --- a/vtkm/exec/serial/internal/CMakeLists.txt +++ b/vtkm/exec/serial/internal/CMakeLists.txt @@ -13,8 +13,3 @@ set(headers ) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/exec/serial/internal/testing/CMakeLists.txt b/vtkm/exec/serial/testing/CMakeLists.txt similarity index 100% rename from vtkm/exec/serial/internal/testing/CMakeLists.txt rename to vtkm/exec/serial/testing/CMakeLists.txt diff --git a/vtkm/exec/serial/internal/testing/UnitTestTaskTilingSerial.cxx b/vtkm/exec/serial/testing/UnitTestTaskTilingSerial.cxx similarity index 92% rename from vtkm/exec/serial/internal/testing/UnitTestTaskTilingSerial.cxx rename to vtkm/exec/serial/testing/UnitTestTaskTilingSerial.cxx index 16d7f0747..9506808a1 100644 --- a/vtkm/exec/serial/internal/testing/UnitTestTaskTilingSerial.cxx +++ b/vtkm/exec/serial/testing/UnitTestTaskTilingSerial.cxx @@ -10,7 +10,7 @@ #include #include -#include +#include int UnitTestTaskTilingSerial(int argc, char* argv[]) { diff --git a/vtkm/exec/serial/vtkm.module b/vtkm/exec/serial/vtkm.module new file mode 100644 index 000000000..746ef5ced --- /dev/null +++ b/vtkm/exec/serial/vtkm.module @@ -0,0 +1,6 @@ +NAME + vtkm_exec_serial +GROUPS + Core +DEPENDS + vtkm_exec diff --git a/vtkm/exec/tbb/internal/CMakeLists.txt b/vtkm/exec/tbb/internal/CMakeLists.txt index 9758b7a7a..5cf7d8576 100644 --- a/vtkm/exec/tbb/internal/CMakeLists.txt +++ b/vtkm/exec/tbb/internal/CMakeLists.txt @@ -13,8 +13,3 @@ set(headers ) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (TARGET vtkm::tbb AND VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif() diff --git a/vtkm/exec/tbb/internal/testing/CMakeLists.txt b/vtkm/exec/tbb/testing/CMakeLists.txt similarity index 100% rename from vtkm/exec/tbb/internal/testing/CMakeLists.txt rename to vtkm/exec/tbb/testing/CMakeLists.txt diff --git a/vtkm/exec/tbb/internal/testing/UnitTestTaskTilingTBB.cxx b/vtkm/exec/tbb/testing/UnitTestTaskTilingTBB.cxx similarity index 92% rename from vtkm/exec/tbb/internal/testing/UnitTestTaskTilingTBB.cxx rename to vtkm/exec/tbb/testing/UnitTestTaskTilingTBB.cxx index 7a3ffdda1..f12ea113c 100644 --- a/vtkm/exec/tbb/internal/testing/UnitTestTaskTilingTBB.cxx +++ b/vtkm/exec/tbb/testing/UnitTestTaskTilingTBB.cxx @@ -10,7 +10,7 @@ #include #include -#include +#include int UnitTestTaskTilingTBB(int argc, char* argv[]) { diff --git a/vtkm/exec/tbb/vtkm.module b/vtkm/exec/tbb/vtkm.module new file mode 100644 index 000000000..f53294995 --- /dev/null +++ b/vtkm/exec/tbb/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_exec_tbb +GROUPS + Core +DEPENDS + vtkm_exec +TEST_DEPENDS + vtkm_tbb diff --git a/vtkm/exec/testing/CMakeLists.txt b/vtkm/exec/testing/CMakeLists.txt index f5337e74f..fd3ec1767 100644 --- a/vtkm/exec/testing/CMakeLists.txt +++ b/vtkm/exec/testing/CMakeLists.txt @@ -8,10 +8,30 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ +set(headers + TestingTaskTiling.h + ThreadIndicesTesting.h + ) + +vtkm_declare_headers(${headers}) + set(unit_tests UnitTestCellDerivative.cxx UnitTestCellEdgeFace.cxx UnitTestCellInterpolate.cxx + UnitTestErrorMessageBuffer.cxx + UnitTestExecutionSignatureTag.cxx + UnitTestFetchArrayDirectIn.cxx + UnitTestFetchArrayDirectIn3d.cxx + UnitTestFetchArrayDirectInOut.cxx + UnitTestFetchArrayDirectOut.cxx + UnitTestFetchArrayNeighborhoodIn.cxx + UnitTestFetchArrayTopologyMapIn.cxx + UnitTestFetchExecObject.cxx + UnitTestFetchWorkIndex.cxx UnitTestParametricCoordinates.cxx + UnitTestTaskSingular.cxx + UnitTestVariant.cxx + UnitTestWorkletInvokeFunctor.cxx ) vtkm_unit_tests(SOURCES ${unit_tests}) diff --git a/vtkm/exec/internal/testing/TestingTaskTiling.h b/vtkm/exec/testing/TestingTaskTiling.h similarity index 100% rename from vtkm/exec/internal/testing/TestingTaskTiling.h rename to vtkm/exec/testing/TestingTaskTiling.h diff --git a/vtkm/exec/arg/testing/ThreadIndicesTesting.h b/vtkm/exec/testing/ThreadIndicesTesting.h similarity index 100% rename from vtkm/exec/arg/testing/ThreadIndicesTesting.h rename to vtkm/exec/testing/ThreadIndicesTesting.h diff --git a/vtkm/exec/internal/testing/UnitTestErrorMessageBuffer.cxx b/vtkm/exec/testing/UnitTestErrorMessageBuffer.cxx similarity index 100% rename from vtkm/exec/internal/testing/UnitTestErrorMessageBuffer.cxx rename to vtkm/exec/testing/UnitTestErrorMessageBuffer.cxx diff --git a/vtkm/exec/arg/testing/UnitTestExecutionSignatureTag.cxx b/vtkm/exec/testing/UnitTestExecutionSignatureTag.cxx similarity index 100% rename from vtkm/exec/arg/testing/UnitTestExecutionSignatureTag.cxx rename to vtkm/exec/testing/UnitTestExecutionSignatureTag.cxx diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectIn.cxx b/vtkm/exec/testing/UnitTestFetchArrayDirectIn.cxx similarity index 97% rename from vtkm/exec/arg/testing/UnitTestFetchArrayDirectIn.cxx rename to vtkm/exec/testing/UnitTestFetchArrayDirectIn.cxx index 0d638ce31..f27c8503b 100644 --- a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectIn.cxx +++ b/vtkm/exec/testing/UnitTestFetchArrayDirectIn.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectIn3d.cxx b/vtkm/exec/testing/UnitTestFetchArrayDirectIn3d.cxx similarity index 100% rename from vtkm/exec/arg/testing/UnitTestFetchArrayDirectIn3d.cxx rename to vtkm/exec/testing/UnitTestFetchArrayDirectIn3d.cxx diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectInOut.cxx b/vtkm/exec/testing/UnitTestFetchArrayDirectInOut.cxx similarity index 97% rename from vtkm/exec/arg/testing/UnitTestFetchArrayDirectInOut.cxx rename to vtkm/exec/testing/UnitTestFetchArrayDirectInOut.cxx index d2663dc01..b83ed8207 100644 --- a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectInOut.cxx +++ b/vtkm/exec/testing/UnitTestFetchArrayDirectInOut.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectOut.cxx b/vtkm/exec/testing/UnitTestFetchArrayDirectOut.cxx similarity index 97% rename from vtkm/exec/arg/testing/UnitTestFetchArrayDirectOut.cxx rename to vtkm/exec/testing/UnitTestFetchArrayDirectOut.cxx index 8eebfdaec..c5c55210e 100644 --- a/vtkm/exec/arg/testing/UnitTestFetchArrayDirectOut.cxx +++ b/vtkm/exec/testing/UnitTestFetchArrayDirectOut.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayNeighborhoodIn.cxx b/vtkm/exec/testing/UnitTestFetchArrayNeighborhoodIn.cxx similarity index 100% rename from vtkm/exec/arg/testing/UnitTestFetchArrayNeighborhoodIn.cxx rename to vtkm/exec/testing/UnitTestFetchArrayNeighborhoodIn.cxx diff --git a/vtkm/exec/arg/testing/UnitTestFetchArrayTopologyMapIn.cxx b/vtkm/exec/testing/UnitTestFetchArrayTopologyMapIn.cxx similarity index 100% rename from vtkm/exec/arg/testing/UnitTestFetchArrayTopologyMapIn.cxx rename to vtkm/exec/testing/UnitTestFetchArrayTopologyMapIn.cxx diff --git a/vtkm/exec/arg/testing/UnitTestFetchExecObject.cxx b/vtkm/exec/testing/UnitTestFetchExecObject.cxx similarity index 97% rename from vtkm/exec/arg/testing/UnitTestFetchExecObject.cxx rename to vtkm/exec/testing/UnitTestFetchExecObject.cxx index 3df0af672..78b5fd9ab 100644 --- a/vtkm/exec/arg/testing/UnitTestFetchExecObject.cxx +++ b/vtkm/exec/testing/UnitTestFetchExecObject.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include diff --git a/vtkm/exec/arg/testing/UnitTestFetchWorkIndex.cxx b/vtkm/exec/testing/UnitTestFetchWorkIndex.cxx similarity index 96% rename from vtkm/exec/arg/testing/UnitTestFetchWorkIndex.cxx rename to vtkm/exec/testing/UnitTestFetchWorkIndex.cxx index c23ad40b8..191bdfbe8 100644 --- a/vtkm/exec/arg/testing/UnitTestFetchWorkIndex.cxx +++ b/vtkm/exec/testing/UnitTestFetchWorkIndex.cxx @@ -12,7 +12,7 @@ #include -#include +#include #include diff --git a/vtkm/exec/internal/testing/UnitTestTaskSingular.cxx b/vtkm/exec/testing/UnitTestTaskSingular.cxx similarity index 100% rename from vtkm/exec/internal/testing/UnitTestTaskSingular.cxx rename to vtkm/exec/testing/UnitTestTaskSingular.cxx diff --git a/vtkm/exec/internal/testing/UnitTestVariant.cxx b/vtkm/exec/testing/UnitTestVariant.cxx similarity index 66% rename from vtkm/exec/internal/testing/UnitTestVariant.cxx rename to vtkm/exec/testing/UnitTestVariant.cxx index 5fbc9d6c5..e7168cb94 100644 --- a/vtkm/exec/internal/testing/UnitTestVariant.cxx +++ b/vtkm/exec/testing/UnitTestVariant.cxx @@ -8,7 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include #include @@ -93,7 +93,7 @@ void TestSize() { std::cout << "Test size" << std::endl; - using VariantType = vtkm::exec::internal::Variant; + using VariantType = vtkm::exec::Variant; constexpr size_t variantSize = sizeof(VariantType); @@ -106,36 +106,36 @@ void TestIndexing() { std::cout << "Test indexing" << std::endl; - using VariantType = vtkm::exec::internal::Variant, - TypePlaceholder<1>, - TypePlaceholder<2>, - TypePlaceholder<3>, - TypePlaceholder<4>, - TypePlaceholder<5>, - TypePlaceholder<6>, - TypePlaceholder<7>, - TypePlaceholder<8>, - TypePlaceholder<9>, - TypePlaceholder<10>, - TypePlaceholder<11>, - TypePlaceholder<12>, - TypePlaceholder<13>, - TypePlaceholder<14>, - TypePlaceholder<15>, - TypePlaceholder<16>, - TypePlaceholder<17>, - TypePlaceholder<18>, - TypePlaceholder<19>, - TypePlaceholder<20>, - TypePlaceholder<21>, - TypePlaceholder<22>, - TypePlaceholder<23>, - TypePlaceholder<24>, - TypePlaceholder<25>, - TypePlaceholder<26>, - TypePlaceholder<27>, - TypePlaceholder<28>, - TypePlaceholder<29>>; + using VariantType = vtkm::exec::Variant, + TypePlaceholder<1>, + TypePlaceholder<2>, + TypePlaceholder<3>, + TypePlaceholder<4>, + TypePlaceholder<5>, + TypePlaceholder<6>, + TypePlaceholder<7>, + TypePlaceholder<8>, + TypePlaceholder<9>, + TypePlaceholder<10>, + TypePlaceholder<11>, + TypePlaceholder<12>, + TypePlaceholder<13>, + TypePlaceholder<14>, + TypePlaceholder<15>, + TypePlaceholder<16>, + TypePlaceholder<17>, + TypePlaceholder<18>, + TypePlaceholder<19>, + TypePlaceholder<20>, + TypePlaceholder<21>, + TypePlaceholder<22>, + TypePlaceholder<23>, + TypePlaceholder<24>, + TypePlaceholder<25>, + TypePlaceholder<26>, + TypePlaceholder<27>, + TypePlaceholder<28>, + TypePlaceholder<29>>; VariantType variant; @@ -256,51 +256,48 @@ void TestTriviallyCopyable() VTKM_STATIC_ASSERT(!vtkmstd::is_trivial::value); // A variant of trivially constructable things should be trivially constructable - VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible< - vtkm::exec::internal::detail::VariantUnion>::value)); VTKM_STATIC_ASSERT( - (vtkmstd::is_trivially_constructible>::value)); + (vtkmstd::is_trivially_constructible>::value)); + VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible>::value)); // A variant of trivially copyable things should be trivially copyable VTKM_STATIC_ASSERT((vtkmstd::is_trivially_copyable< - vtkm::exec::internal::detail::VariantUnion>::value)); - VTKM_STATIC_ASSERT(( - vtkmstd::is_trivially_copyable>::value)); + vtkm::exec::detail::VariantUnion>::value)); + VTKM_STATIC_ASSERT( + (vtkmstd::is_trivially_copyable>::value)); // A variant of any non-trivially constructable things is not trivially copyable VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::detail::VariantUnion>::value)); + vtkm::exec::detail::VariantUnion>::value)); VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::detail::VariantUnion>::value)); + vtkm::exec::detail::VariantUnion>::value)); VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::detail::VariantUnion>::value)); - VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::Variant>::value)); - VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::Variant>::value)); - VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible< - vtkm::exec::internal::Variant>::value)); + vtkm::exec::detail::VariantUnion>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_constructible>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_constructible>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_constructible>::value)); // A variant of any non-trivially copyable things is not trivially copyable VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable< - vtkm::exec::internal::detail::VariantUnion>::value)); + vtkm::exec::detail::VariantUnion>::value)); VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable< - vtkm::exec::internal::detail::VariantUnion>::value)); + vtkm::exec::detail::VariantUnion>::value)); VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable< - vtkm::exec::internal::detail::VariantUnion>::value)); - VTKM_STATIC_ASSERT(( - !vtkmstd::is_trivially_copyable>::value)); - VTKM_STATIC_ASSERT(( - !vtkmstd::is_trivially_copyable>::value)); - VTKM_STATIC_ASSERT(( - !vtkmstd::is_trivially_copyable>::value)); + vtkm::exec::detail::VariantUnion>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_copyable>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_copyable>::value)); + VTKM_STATIC_ASSERT( + (!vtkmstd::is_trivially_copyable>::value)); // A variant of trivial things should be trivial - VTKM_STATIC_ASSERT((vtkmstd::is_trivial>::value)); - VTKM_STATIC_ASSERT( - (!vtkmstd::is_trivial>::value)); - VTKM_STATIC_ASSERT( - (!vtkmstd::is_trivial>::value)); + VTKM_STATIC_ASSERT((vtkmstd::is_trivial>::value)); + VTKM_STATIC_ASSERT((!vtkmstd::is_trivial>::value)); + VTKM_STATIC_ASSERT((!vtkmstd::is_trivial>::value)); #endif // VTKM_USE_STD_IS_TRIVIAL } @@ -329,36 +326,36 @@ void TestGet() { std::cout << "Test Get" << std::endl; - using VariantType = vtkm::exec::internal::Variant, - TypePlaceholder<1>, - vtkm::Id, - TypePlaceholder<3>, - TypePlaceholder<4>, - TypePlaceholder<5>, - TypePlaceholder<6>, - TypePlaceholder<7>, - TypePlaceholder<8>, - TypePlaceholder<9>, - TypePlaceholder<10>, - TypePlaceholder<11>, - TypePlaceholder<12>, - TypePlaceholder<13>, - TypePlaceholder<14>, - TypePlaceholder<15>, - TypePlaceholder<16>, - TypePlaceholder<17>, - TypePlaceholder<18>, - TypePlaceholder<19>, - TypePlaceholder<20>, - TypePlaceholder<21>, - TypePlaceholder<22>, - TypePlaceholder<23>, - TypePlaceholder<24>, - TypePlaceholder<25>, - TypePlaceholder<26>, - vtkm::Float32, - TypePlaceholder<28>, - TypePlaceholder<29>>; + using VariantType = vtkm::exec::Variant, + TypePlaceholder<1>, + vtkm::Id, + TypePlaceholder<3>, + TypePlaceholder<4>, + TypePlaceholder<5>, + TypePlaceholder<6>, + TypePlaceholder<7>, + TypePlaceholder<8>, + TypePlaceholder<9>, + TypePlaceholder<10>, + TypePlaceholder<11>, + TypePlaceholder<12>, + TypePlaceholder<13>, + TypePlaceholder<14>, + TypePlaceholder<15>, + TypePlaceholder<16>, + TypePlaceholder<17>, + TypePlaceholder<18>, + TypePlaceholder<19>, + TypePlaceholder<20>, + TypePlaceholder<21>, + TypePlaceholder<22>, + TypePlaceholder<23>, + TypePlaceholder<24>, + TypePlaceholder<25>, + TypePlaceholder<26>, + vtkm::Float32, + TypePlaceholder<28>, + TypePlaceholder<29>>; { const vtkm::Id expectedValue = TestValue(3, vtkm::Id{}); @@ -392,36 +389,36 @@ void TestCastAndCall() { std::cout << "Test CastAndCall" << std::endl; - using VariantType = vtkm::exec::internal::Variant, - TypePlaceholder<1>, - TypePlaceholder<2>, - TypePlaceholder<3>, - TypePlaceholder<4>, - TypePlaceholder<5>, - TypePlaceholder<6>, - TypePlaceholder<7>, - TypePlaceholder<8>, - TypePlaceholder<9>, - TypePlaceholder<10>, - TypePlaceholder<11>, - TypePlaceholder<12>, - TypePlaceholder<13>, - TypePlaceholder<14>, - TypePlaceholder<15>, - TypePlaceholder<16>, - TypePlaceholder<17>, - TypePlaceholder<18>, - TypePlaceholder<19>, - TypePlaceholder<20>, - TypePlaceholder<21>, - TypePlaceholder<22>, - TypePlaceholder<23>, - TypePlaceholder<24>, - TypePlaceholder<25>, - TypePlaceholder<26>, - TypePlaceholder<27>, - TypePlaceholder<28>, - TypePlaceholder<29>>; + using VariantType = vtkm::exec::Variant, + TypePlaceholder<1>, + TypePlaceholder<2>, + TypePlaceholder<3>, + TypePlaceholder<4>, + TypePlaceholder<5>, + TypePlaceholder<6>, + TypePlaceholder<7>, + TypePlaceholder<8>, + TypePlaceholder<9>, + TypePlaceholder<10>, + TypePlaceholder<11>, + TypePlaceholder<12>, + TypePlaceholder<13>, + TypePlaceholder<14>, + TypePlaceholder<15>, + TypePlaceholder<16>, + TypePlaceholder<17>, + TypePlaceholder<18>, + TypePlaceholder<19>, + TypePlaceholder<20>, + TypePlaceholder<21>, + TypePlaceholder<22>, + TypePlaceholder<23>, + TypePlaceholder<24>, + TypePlaceholder<25>, + TypePlaceholder<26>, + TypePlaceholder<27>, + TypePlaceholder<28>, + TypePlaceholder<29>>; vtkm::FloatDefault result; VariantType variant0{ TypePlaceholder<0>{} }; @@ -454,7 +451,7 @@ void TestCopyInvalid() { std::cout << "Test copy invalid variant" << std::endl; - using VariantType = vtkm::exec::internal::Variant, NonTrivial>; + using VariantType = vtkm::exec::Variant, NonTrivial>; VariantType source; source.Reset(); @@ -488,11 +485,11 @@ void TestCopyDestroy() { std::cout << "Test copy destroy" << std::endl; - using VariantType = vtkm::exec::internal::Variant, - TypePlaceholder<1>, - CountConstructDestruct, - TypePlaceholder<3>, - TypePlaceholder<4>>; + using VariantType = vtkm::exec::Variant, + TypePlaceholder<1>, + CountConstructDestruct, + TypePlaceholder<3>, + TypePlaceholder<4>>; #ifdef VTKM_USE_STD_IS_TRIVIAL VTKM_STATIC_ASSERT(!vtkmstd::is_trivially_copyable::value); #endif // VTKM_USE_STD_IS_TRIVIAL @@ -545,7 +542,7 @@ void TestEmplace() { std::cout << "Test Emplace" << std::endl; - using VariantType = vtkm::exec::internal::Variant>; + using VariantType = vtkm::exec::Variant>; VariantType variant; variant.Emplace(TestValue(0, vtkm::Id{})); @@ -577,7 +574,7 @@ void TestConstructDestruct() g_NonTrivialCount = 0; - using VariantType = vtkm::exec::internal::Variant; + using VariantType = vtkm::exec::Variant; { VariantType variant1 = NonTrivial{}; @@ -597,8 +594,7 @@ void TestCopySelf() { std::cout << "Make sure copying a Variant to itself works" << std::endl; - using VariantType = - vtkm::exec::internal::Variant, NonTrivial, TypePlaceholder<2>>; + using VariantType = vtkm::exec::Variant, NonTrivial, TypePlaceholder<2>>; VariantType variant{ NonTrivial{} }; VariantType& variantRef = variant; diff --git a/vtkm/exec/internal/testing/UnitTestWorkletInvokeFunctor.cxx b/vtkm/exec/testing/UnitTestWorkletInvokeFunctor.cxx similarity index 100% rename from vtkm/exec/internal/testing/UnitTestWorkletInvokeFunctor.cxx rename to vtkm/exec/testing/UnitTestWorkletInvokeFunctor.cxx diff --git a/vtkm/exec/vtkm.module b/vtkm/exec/vtkm.module new file mode 100644 index 000000000..430f197d9 --- /dev/null +++ b/vtkm/exec/vtkm.module @@ -0,0 +1,4 @@ +NAME + vtkm_exec +GROUPS + Core diff --git a/vtkm/filter/AmrArrays.h b/vtkm/filter/AmrArrays.h deleted file mode 100644 index c7ef489c1..000000000 --- a/vtkm/filter/AmrArrays.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_AmrArrays_h -#define vtk_m_filter_AmrArrays_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/multi_block/AmrArrays.h instead of vtkm/filter/AmrArrays.h.") -inline void AmrArrays_deprecated() {} - -inline void AmrArrays_deprecated_warning() -{ - AmrArrays_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_AmrArrays_h diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 8fc26e60a..af945fd15 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -8,107 +8,22 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -set(deprecated_headers - AmrArrays.h - CellAverage.h - CellMeasures.h - CellSetConnectivity.h - CleanGrid.h - ClipWithField.h - ClipWithImplicitFunction.h - ComputeMoments.h - Contour.h - ContourTreeUniform.h - ContourTreeUniformAugmented.h - ContourTreeUniformDistributed.h - CoordinateSystemTransform.h - CreateResult.h - CrossProduct.h - DotProduct.h - Entropy.h - ExternalFaces.h - ExtractGeometry.h - ExtractPoints.h - ExtractStructured.h - FieldToColors.h - FieldMetadata.h - FilterCell.h - FilterDataSet.h - FilterDataSet.hxx - FilterDataSetWithField.h - FilterDataSetWithField.hxx - FilterField.h - FilterField.hxx - Filter.h - Filter.hxx - FilterTraits.h - GenerateIds.h - GhostCellClassify.h - GhostCellRemove.h - Gradient.h - Histogram.h - ImageConnectivity.h - ImageDifference.h - ImageMedian.h - Instantiations.h - Lagrangian.h - LagrangianStructures.h - Mask.h - MaskPoints.h - MeshQuality.h - MIRFilter.h - NDEntropy.h - NDHistogram.h - ParticleAdvection.h - ParticleDensityCloudInCell.h - ParticleDensityNearestGridPoint.h - Pathline.h - PathParticle.h - PointAverage.h - PointElevation.h - PointTransform.h - PolicyBase.h - PolicyDefault.h - Probe.h - Slice.h - SplitSharpEdges.h - Streamline.h - StreamSurface.h - SurfaceNormals.h - Tetrahedralize.h - Threshold.h - ThresholdPoints.h - Triangulate.h - Tube.h - VertexClustering.h - VectorMagnitude.h - WarpScalar.h - WarpVector.h - ZFPCompressor1D.h - ZFPCompressor2D.h - ZFPCompressor3D.h - ZFPDecompressor1D.h - ZFPDecompressor2D.h - ZFPDecompressor3D.h - ) - -vtkm_declare_headers(${deprecated_headers}) - set(core_headers FieldSelection.h - NewFilter.h - NewFilterField.h + Filter.h + FilterField.h MapFieldMergeAverage.h MapFieldPermutation.h TaskQueue.h ) set(core_sources - NewFilterField.cxx + FieldSelection.cxx + FilterField.cxx ) set(core_sources_device MapFieldMergeAverage.cxx MapFieldPermutation.cxx - NewFilter.cxx + Filter.cxx ) vtkm_library( @@ -128,33 +43,8 @@ set_target_properties( UNITY_BUILD_MODE BATCH ) -target_link_libraries(vtkm_filter_core PUBLIC vtkm_cont vtkm_worklet) - target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_core ) -install(TARGETS vtkm_filter EXPORT ${VTKm_EXPORT_NAME}) - -add_subdirectory(clean_grid) -add_subdirectory(connected_components) -add_subdirectory(contour) -add_subdirectory(density_estimate) -add_subdirectory(entity_extraction) -add_subdirectory(flow) -add_subdirectory(image_processing) -add_subdirectory(internal) -add_subdirectory(field_conversion) -add_subdirectory(field_transform) -add_subdirectory(geometry_refinement) -add_subdirectory(mesh_info) -add_subdirectory(multi_block) -add_subdirectory(resampling) -add_subdirectory(scalar_topology) -add_subdirectory(vector_analysis) -add_subdirectory(zfp) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () +vtkm_install_targets(TARGETS vtkm_filter) diff --git a/vtkm/filter/CellAverage.h b/vtkm/filter/CellAverage.h deleted file mode 100644 index b4250cc53..000000000 --- a/vtkm/filter/CellAverage.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CellAverage_h -#define vtk_m_filter_CellAverage_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_conversion/CellAverage.h instead of vtkm/filter/CellAverage.h.") -inline void CellAverage_deprecated() {} - -inline void CellAverage_deprecated_warning() -{ - CellAverage_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_CellAverage_h diff --git a/vtkm/filter/CellMeasures.h b/vtkm/filter/CellMeasures.h deleted file mode 100644 index 17b1fafc5..000000000 --- a/vtkm/filter/CellMeasures.h +++ /dev/null @@ -1,24 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CellMeasures_h -#define vtk_m_filter_CellMeasures_h - -#include -#include - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/mesh_info/CellMeasures.h instead of vtkm/filter/CellMeasures.h.") -inline void CellMeasures_deprecated() {} - -inline void CellMeasures_deprecated_warning() -{ - CellMeasures_deprecated(); -} -#endif //vtk_m_filter_CellMeasures_h diff --git a/vtkm/filter/CellSetConnectivity.h b/vtkm/filter/CellSetConnectivity.h deleted file mode 100644 index 7609cc688..000000000 --- a/vtkm/filter/CellSetConnectivity.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CellSetConnectivity_h -#define vtk_m_filter_CellSetConnectivity_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/connected_components/CellSetConnectivity.h instead of " - "vtkm/filter/CellSetConnectivity.h.") -inline void CellSetConnectivity_deprecated() {} - -inline void CellSetConnectivity_deprecated_warning() -{ - CellSetConnectivity_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_CellSetConnectivity_h diff --git a/vtkm/filter/CleanGrid.h b/vtkm/filter/CleanGrid.h deleted file mode 100644 index 4da9de239..000000000 --- a/vtkm/filter/CleanGrid.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CleanGrid_h -#define vtk_m_filter_CleanGrid_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/clean_grid/CleanGrid.h instead of vtkm/filter/CleanGrid.h.") -inline void CleanGrid_deprecated() {} - -inline void CleanGrid_deprecated_warning() -{ - CleanGrid_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_CleanGrid_h diff --git a/vtkm/filter/ClipWithField.h b/vtkm/filter/ClipWithField.h deleted file mode 100644 index a9d56d221..000000000 --- a/vtkm/filter/ClipWithField.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ClipWithField_h -#define vtk_m_filter_ClipWithField_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/contour/ClipWithField.h instead of vtkm/filter/ClipWithField.h.") -inline void ClipWithField_deprecated() {} - -inline void ClipWithField_deprecated_warning() -{ - ClipWithField_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ClipWithField_h diff --git a/vtkm/filter/ClipWithImplicitFunction.h b/vtkm/filter/ClipWithImplicitFunction.h deleted file mode 100644 index 86c51b4d2..000000000 --- a/vtkm/filter/ClipWithImplicitFunction.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ClipWithImplicitFunction_h -#define vtk_m_filter_ClipWithImplicitFunction_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/contour/ClipWithImplicitFunction.h instead of " - "vtkm/filter/ClipWithImplicitFunction.h.") -inline void ClipWithImplicitFunction_deprecated() {} - -inline void ClipWithImplicitFunction_deprecated_warning() -{ - ClipWithImplicitFunction_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ClipWithImplicitFunction_h diff --git a/vtkm/filter/ComputeMoments.h b/vtkm/filter/ComputeMoments.h deleted file mode 100644 index 475ea2575..000000000 --- a/vtkm/filter/ComputeMoments.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ComputeMoments_h -#define vtk_m_filter_ComputeMoments_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/image_processing/ComputeMoments.h instead of vtkm/filter/ComputeMoments.h.") -inline void ComputeMoments_deprecated() {} - -inline void ComputeMoments_deprecated_warning() -{ - ComputeMoments_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ComputeMoments_h diff --git a/vtkm/filter/Contour.h b/vtkm/filter/Contour.h deleted file mode 100644 index e7ee66394..000000000 --- a/vtkm/filter/Contour.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Contour_h -#define vtk_m_filter_Contour_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/contour/Contour.h instead of vtkm/filter/Contour.h.") -inline void Contour_deprecated() {} - -inline void Contour_deprecated_warning() -{ - Contour_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Contour_h diff --git a/vtkm/filter/ContourTreeUniform.h b/vtkm/filter/ContourTreeUniform.h deleted file mode 100644 index ee576f85e..000000000 --- a/vtkm/filter/ContourTreeUniform.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ContourTreeUniform_h -#define vtk_m_filter_ContourTreeUniform_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/scalar_topology/ContourTreeUniform.h instead of " - "vtkm/filter/ContourTreeUniform.h.") -inline void ContourTreeUniform_deprecated() {} - -inline void ContourTreeUniform_deprecated_warning() -{ - ContourTreeUniform_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ContourTreeUniform_h diff --git a/vtkm/filter/ContourTreeUniformAugmented.h b/vtkm/filter/ContourTreeUniformAugmented.h deleted file mode 100644 index 01bab8602..000000000 --- a/vtkm/filter/ContourTreeUniformAugmented.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ContourTreeUniformAugmented_h -#define vtk_m_filter_ContourTreeUniformAugmented_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/scalar_topology/ContourTreeUniformAugmented.h instead of " - "vtkm/filter/ContourTreeUniformAugmented.h.") -inline void ContourTreeUniformAugmented_deprecated() {} - -inline void ContourTreeUniformAugmented_deprecated_warning() -{ - ContourTreeUniformAugmented_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ContourTreeUniformAugmented_h diff --git a/vtkm/filter/ContourTreeUniformDistributed.h b/vtkm/filter/ContourTreeUniformDistributed.h deleted file mode 100644 index 017c05a27..000000000 --- a/vtkm/filter/ContourTreeUniformDistributed.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ContourTreeUniformDistributed_h -#define vtk_m_filter_ContourTreeUniformDistributed_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/scalar_topology/ContourTreeUniformDistributed.h instead of " - "vtkm/filter/ContourTreeUniformDistributed.h.") -inline void ContourTreeUniformDistributed_deprecated() {} - -inline void ContourTreeUniformDistributed_deprecated_warning() -{ - ContourTreeUniformDistributed_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ContourTreeUniformDistributed_h diff --git a/vtkm/filter/CoordinateSystemTransform.h b/vtkm/filter/CoordinateSystemTransform.h deleted file mode 100644 index 61c59c0dc..000000000 --- a/vtkm/filter/CoordinateSystemTransform.h +++ /dev/null @@ -1,36 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CoordinateSystemTransform_h -#define vtk_m_filter_CoordinateSystemTransform_h - -#include -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/field_transform/CylindricalCoordinateTransform.h or " - "vtkm/filter/field_transform/SphericalCoordinateTransform.h instead of " - "vtkm/filter/CoordinateSystemTransform.h.") -inline void CoordinateSystemTransform_deprecated() {} - -inline void CoordinateSystemTransform_deprecated_warning() -{ - CoordinateSystemTransform_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_CoordinateSystemTransform_h diff --git a/vtkm/filter/CreateResult.h b/vtkm/filter/CreateResult.h deleted file mode 100644 index 840609517..000000000 --- a/vtkm/filter/CreateResult.h +++ /dev/null @@ -1,168 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_CreateResult_h -#define vtk_m_filter_CreateResult_h - -#include -#include -#include - -#include - -// Once all the filters move to the NewFilter base classes, this header should -// be deprecated. - -namespace vtkm -{ -namespace filter -{ -//@{ -/// These are utility functions defined to use in filters when creating an -/// output dataset to return from `DoExecute` methods. The various overloads -/// provides different ways of creating the output dataset (copying the input -/// without any of the fields) and adding additional field(s). - -/// Use this if you have built a \c Field object. An output -/// \c DataSet will be created by adding the field to the input. -VTKM_DEPRECATED(1.9, "Use CreateResultField method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::Field& field) -{ - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(field); - VTKM_ASSERT(!field.GetName().empty()); - VTKM_ASSERT(clone.HasField(field.GetName(), field.GetAssociation())); - return clone; -} - -/// Use this function if you have an ArrayHandle that holds the data for -/// the field. You also need to specify a name for the field. -template -VTKM_DEPRECATED(1.9, "Use CreateResultField method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet - CreateResult(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::ArrayHandle& fieldArray, - const std::string& fieldName, - const vtkm::filter::FieldMetadata& metaData) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(metaData.AsField(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasField(fieldName, metaData.GetAssociation())); - return clone; -} - -/// Use this function if you have a UnknownArrayHandle that holds the data -/// for the field. -VTKM_DEPRECATED(1.9, "Use CreateResultField method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownArrayHandle& fieldArray, - const std::string& fieldName, - const vtkm::filter::FieldMetadata& metaData) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(metaData.AsField(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasField(fieldName, metaData.GetAssociation())); - return clone; -} - -/// Use this function if you want to explicit construct a Cell field and have a ArrayHandle -/// that holds the data for the field. -template -VTKM_DEPRECATED(1.9, "Use CreateResultFieldCell method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet - CreateResultFieldCell(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::ArrayHandle& fieldArray, - const std::string& fieldName) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(vtkm::cont::make_FieldCell(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasCellField(fieldName)); - return clone; -} - -/// Use this function if you want to explicit construct a Cell field and have a UnknownArrayHandle -/// that holds the data for the field. -VTKM_DEPRECATED(1.9, "Use CreateResultFieldCell method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell( - const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownArrayHandle& fieldArray, - const std::string& fieldName) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(vtkm::cont::make_FieldCell(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasCellField(fieldName)); - return clone; -} - -/// Use this function if you want to explicit construct a Point field and have a ArrayHandle -/// that holds the data for the field. -template -VTKM_DEPRECATED(1.9, "Use CreateResultFieldPoint method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet - CreateResultFieldPoint(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::ArrayHandle& fieldArray, - const std::string& fieldName) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(vtkm::cont::make_FieldPoint(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasPointField(fieldName)); - return clone; -} - -/// Use this function if you want to explicit construct a Point field and have a UnknownArrayHandle -/// that holds the data for the field. -VTKM_DEPRECATED(1.9, "Use CreateResultFieldCell method in NewFilterField.") -inline VTKM_CONT vtkm::cont::DataSet CreateResultFieldPoint( - const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownArrayHandle& fieldArray, - const std::string& fieldName) -{ - VTKM_ASSERT(!fieldName.empty()); - - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - clone.AddField(vtkm::cont::make_FieldPoint(fieldName, fieldArray)); - - // Sanity check. - VTKM_ASSERT(clone.HasPointField(fieldName)); - return clone; -} - -//@} -} // namespace vtkm::filter -} // namespace vtkm - -#endif diff --git a/vtkm/filter/CrossProduct.h b/vtkm/filter/CrossProduct.h deleted file mode 100644 index 56f62986d..000000000 --- a/vtkm/filter/CrossProduct.h +++ /dev/null @@ -1,35 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_CrossProduct_h -#define vtk_m_filter_CrossProduct_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/vector_analysis/CrossProduct.h instead of vtkm/filter/CrossProduct.h.") -inline void CrossProduct_deprecated() {} - -inline void CrossProduct_deprecated_warning() -{ - CrossProduct_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif // vtk_m_filter_CrossProduct_h diff --git a/vtkm/filter/DotProduct.h b/vtkm/filter/DotProduct.h deleted file mode 100644 index 97c4e7a4d..000000000 --- a/vtkm/filter/DotProduct.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_DotProduct_h -#define vtk_m_filter_DotProduct_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/vector_analysis/DotProduct.h instead of vtkm/filter/DotProduct.h.") -inline void DotProduct_deprecated() {} - -inline void DotProduct_deprecated_warning() -{ - DotProduct_deprecated(); -} - - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_DotProduct_h diff --git a/vtkm/filter/Entropy.h b/vtkm/filter/Entropy.h deleted file mode 100644 index 309d0d013..000000000 --- a/vtkm/filter/Entropy.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Entropy_h -#define vtk_m_filter_Entropy_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/density_estimate/Entropy.h instead of vtkm/filter/Entropy.h.") -inline void Entropy_deprecated() {} - -inline void Entropy_deprecated_warning() -{ - Entropy_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Entropy_h diff --git a/vtkm/filter/ExternalFaces.h b/vtkm/filter/ExternalFaces.h deleted file mode 100644 index 1f42bd5bf..000000000 --- a/vtkm/filter/ExternalFaces.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ExternalFaces_h -#define vtk_m_filter_ExternalFaces_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/ExternalFaces.h instead of vtkm/filter/ExternalFaces.h.") -inline void ExternalFaces_deprecated() {} - -inline void ExternalFaces_deprecated_warning() -{ - ExternalFaces_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ExternalFaces_h diff --git a/vtkm/filter/ExtractGeometry.h b/vtkm/filter/ExtractGeometry.h deleted file mode 100644 index e9d3e7594..000000000 --- a/vtkm/filter/ExtractGeometry.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ExtractGeometry_h -#define vtk_m_filter_ExtractGeometry_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/ExtractGeometry.h instead of vtkm/filter/ExtractGeometry.h.") -inline void ExtractGeometry_deprecated() {} - -inline void ExtractGeometry_deprecated_warning() -{ - ExtractGeometry_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ExtractGeometry_h diff --git a/vtkm/filter/ExtractPoints.h b/vtkm/filter/ExtractPoints.h deleted file mode 100644 index ee0f210c1..000000000 --- a/vtkm/filter/ExtractPoints.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ExtractPoints_h -#define vtk_m_filter_ExtractPoints_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/ExtractPoints.h instead of vtkm/filter/ExtractPoints.h.") -inline void ExtractPoints_deprecated() {} - -inline void ExtractPoints_deprecated_warning() -{ - ExtractPoints_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ExtractPoints_h diff --git a/vtkm/filter/ExtractStructured.h b/vtkm/filter/ExtractStructured.h deleted file mode 100644 index fe9e77d3d..000000000 --- a/vtkm/filter/ExtractStructured.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ExtractStructured_h -#define vtk_m_filter_ExtractStructured_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/entity_extraction/ExtractStructured.h instead of " - "vtkm/filter/ExtractStructured.h.") -inline void ExtractStructured_deprecated() {} - -inline void ExtractStructured_deprecated_warning() -{ - ExtractStructured_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ExtractStructured_h diff --git a/vtkm/filter/FieldMetadata.h b/vtkm/filter/FieldMetadata.h deleted file mode 100644 index 2b6c5805a..000000000 --- a/vtkm/filter/FieldMetadata.h +++ /dev/null @@ -1,94 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_FieldMetadata_h -#define vtk_m_filter_FieldMetadata_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -class VTKM_DEPRECATED(1.9) FieldMetadata -{ -public: - VTKM_CONT - FieldMetadata() - : Name() - , Association(vtkm::cont::Field::Association::Any) - { - } - - VTKM_CONT - FieldMetadata(const vtkm::cont::Field& f) - : Name(f.GetName()) - , Association(f.GetAssociation()) - { - } - - VTKM_CONT - FieldMetadata(const vtkm::cont::CoordinateSystem& sys) - : Name(sys.GetName()) - , Association(sys.GetAssociation()) - { - } - - VTKM_CONT - bool IsPointField() const { return this->Association == vtkm::cont::Field::Association::Points; } - - VTKM_CONT - bool IsCellField() const { return this->Association == vtkm::cont::Field::Association::Cells; } - - VTKM_CONT - const std::string& GetName() const { return this->Name; } - - VTKM_CONT - vtkm::cont::Field::Association GetAssociation() const { return this->Association; } - - /// Construct a new field with the same association as stored in this FieldMetaData - /// but with a new name - template - VTKM_CONT vtkm::cont::Field AsField(const std::string& name, - const vtkm::cont::ArrayHandle& handle) const - { - return vtkm::cont::Field(name, this->Association, handle); - } - /// Construct a new field with the same association as stored in this FieldMetaData - /// but with a new name - VTKM_CONT - vtkm::cont::Field AsField(const std::string& name, - const vtkm::cont::UnknownArrayHandle& handle) const - { - return vtkm::cont::Field(name, this->Association, handle); - } - - /// Construct a new field with the same association and name as stored in this FieldMetaData - template - VTKM_CONT vtkm::cont::Field AsField(const vtkm::cont::ArrayHandle& handle) const - { - return this->AsField(this->Name, handle); - } - /// Construct a new field with the same association and name as stored in this FieldMetaData - VTKM_CONT vtkm::cont::Field AsField(const vtkm::cont::UnknownArrayHandle& handle) const - { - return this->AsField(this->Name, handle); - } - -private: - std::string Name; ///< name of field - vtkm::cont::Field::Association Association; -}; -} -} - -#endif //vtk_m_filter_FieldMetadata_h diff --git a/vtkm/filter/FieldSelection.cxx b/vtkm/filter/FieldSelection.cxx new file mode 100644 index 000000000..d7aa71212 --- /dev/null +++ b/vtkm/filter/FieldSelection.cxx @@ -0,0 +1,215 @@ +//============================================================================ +// 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. +//============================================================================ + +#include + +#include + +namespace +{ + +struct FieldDescription +{ + std::string Name; + vtkm::cont::Field::Association Association; + FieldDescription() = default; + FieldDescription(const std::string& name, vtkm::cont::Field::Association assoc) + : Name(name) + , Association(assoc) + { + } + + FieldDescription(const FieldDescription&) = default; + FieldDescription& operator=(const FieldDescription&) = default; + + bool operator<(const FieldDescription& other) const + { + return (this->Association == other.Association) ? (this->Name < other.Name) + : (this->Association < other.Association); + } +}; + +} // anonymous namespace + +namespace vtkm +{ +namespace filter +{ + +struct FieldSelection::InternalStruct +{ + Mode ModeType; + + std::map Fields; +}; + +FieldSelection::FieldSelection(Mode mode) + : Internals(new InternalStruct) +{ + this->SetMode(mode); +} + +FieldSelection::FieldSelection(const std::string& field, Mode mode) + : FieldSelection(mode) +{ + this->AddField(field, vtkm::cont::Field::Association::Any); +} + +FieldSelection::FieldSelection(const char* field, Mode mode) + : FieldSelection(mode) +{ + this->AddField(field, vtkm::cont::Field::Association::Any); +} + +FieldSelection::FieldSelection(const std::string& field, + vtkm::cont::Field::Association association, + Mode mode) + : FieldSelection(mode) +{ + this->AddField(field, association); +} + +FieldSelection::FieldSelection(std::initializer_list fields, Mode mode) + : FieldSelection(mode) +{ + for (const std::string& afield : fields) + { + this->AddField(afield, vtkm::cont::Field::Association::Any); + } +} + +FieldSelection::FieldSelection( + std::initializer_list> fields, + Mode mode) + : FieldSelection(mode) +{ + for (const auto& item : fields) + { + this->AddField(item.first, item.second); + } +} + +FieldSelection::FieldSelection( + std::initializer_list> fields, + Mode mode) + : FieldSelection(mode) +{ + for (const auto& item : fields) + { + this->AddField(item.first, item.second); + } +} + +FieldSelection::FieldSelection(const FieldSelection& src) + : Internals(new InternalStruct(*src.Internals)) +{ +} + +FieldSelection::FieldSelection(FieldSelection&&) = default; + +FieldSelection& FieldSelection::operator=(const FieldSelection& src) +{ + *this->Internals = *src.Internals; + return *this; +} + +FieldSelection& FieldSelection::operator=(FieldSelection&&) = default; + +FieldSelection::~FieldSelection() = default; + +bool FieldSelection::IsFieldSelected(const std::string& name, + vtkm::cont::Field::Association association) const +{ + switch (this->GetFieldMode(name, association)) + { + case Mode::Select: + return true; + case Mode::Exclude: + return false; + default: + switch (this->GetMode()) + { + case Mode::None: + case Mode::Select: + // Fields are not selected unless explicitly set + return false; + case Mode::All: + case Mode::Exclude: + // Fields are selected unless explicitly excluded + return true; + } + } + VTKM_ASSERT(false && "Internal error. Unexpected mode"); + return false; +} + +void FieldSelection::AddField(const std::string& fieldName, + vtkm::cont::Field::Association association, + Mode mode) +{ + this->Internals->Fields[FieldDescription(fieldName, association)] = mode; +} + +FieldSelection::Mode FieldSelection::GetFieldMode(const std::string& fieldName, + vtkm::cont::Field::Association association) const +{ + auto iter = this->Internals->Fields.find(FieldDescription(fieldName, association)); + if (iter != this->Internals->Fields.end()) + { + return iter->second; + } + + // if not exact match, let's lookup for Association::Any. + for (const auto& aField : this->Internals->Fields) + { + if (aField.first.Name == fieldName) + { + if (aField.first.Association == vtkm::cont::Field::Association::Any || + association == vtkm::cont::Field::Association::Any) + { + return aField.second; + } + } + } + + return Mode::None; +} + +void FieldSelection::ClearFields() +{ + this->Internals->Fields.clear(); +} + +FieldSelection::Mode FieldSelection::GetMode() const +{ + return this->Internals->ModeType; +} + +void FieldSelection::SetMode(Mode val) +{ + switch (val) + { + case Mode::None: + this->ClearFields(); + this->Internals->ModeType = Mode::Select; + break; + case Mode::All: + this->ClearFields(); + this->Internals->ModeType = Mode::Exclude; + break; + case Mode::Select: + case Mode::Exclude: + this->Internals->ModeType = val; + break; + } +} + +} +} // namespace vtkm::filter diff --git a/vtkm/filter/FieldSelection.h b/vtkm/filter/FieldSelection.h index 1320e7c13..0bdc3a0c6 100644 --- a/vtkm/filter/FieldSelection.h +++ b/vtkm/filter/FieldSelection.h @@ -10,12 +10,14 @@ #ifndef vtk_m_filter_FieldSelection_h #define vtk_m_filter_FieldSelection_h -#include -#include -#include #include #include +#include + +#include +#include + namespace vtkm { namespace filter @@ -26,7 +28,7 @@ namespace filter /// `vtkm::filter::Filter::Execute` to execute the filter and map selected /// fields. It is possible to easily construct \c FieldSelection that selects all or /// none of the input fields. -class FieldSelection +class VTKM_FILTER_CORE_EXPORT FieldSelection { public: enum struct Mode @@ -36,69 +38,34 @@ public: Select, Exclude }; - VTKM_DEPRECATED(1.8, "Use FieldSelection::Mode::None.") - static constexpr Mode MODE_NONE = Mode::None; - VTKM_DEPRECATED(1.8, "Use FieldSelection::Mode::All.") static constexpr Mode MODE_ALL = Mode::All; - VTKM_DEPRECATED(1.8, "Use FieldSelection::Mode::Select.") - static constexpr Mode MODE_SELECT = Mode::Select; - VTKM_DEPRECATED(1.8, "Use FieldSelection::Mode::Exclude.") - static constexpr Mode MODE_EXCLUDE = Mode::Exclude; - using ModeEnum VTKM_DEPRECATED(1.8, "Use FieldSelection::Mode.") = Mode; - VTKM_CONT - FieldSelection(Mode mode = Mode::Select) - : ModeType(mode) - { - } + VTKM_CONT FieldSelection(Mode mode = Mode::Select); /// Use this constructor to create a field selection given a single field name /// \code{cpp} /// FieldSelection("field_name"); /// \endcode - VTKM_CONT - FieldSelection(const std::string& field, Mode mode = Mode::Select) - : ModeType(mode) - { - this->AddField(field, vtkm::cont::Field::Association::Any); - } + VTKM_CONT FieldSelection(const std::string& field, Mode mode = Mode::Select); /// Use this constructor to create a field selection given a single field name /// \code{cpp} /// FieldSelection("field_name"); /// \endcode - VTKM_CONT - FieldSelection(const char* field, Mode mode = Mode::Select) - : ModeType(mode) - { - this->AddField(field, vtkm::cont::Field::Association::Any); - } + VTKM_CONT FieldSelection(const char* field, Mode mode = Mode::Select); /// Use this constructor to create a field selection given a single name and association. /// \code{cpp} /// FieldSelection("field_name", vtkm::cont::Field::Association::Points) /// \endcode{cpp} - VTKM_CONT - FieldSelection(const std::string& field, - vtkm::cont::Field::Association association, - Mode mode = Mode::Select) - : ModeType(mode) - { - this->AddField(field, association); - } + VTKM_CONT FieldSelection(const std::string& field, + vtkm::cont::Field::Association association, + Mode mode = Mode::Select); /// Use this constructor to create a field selection given the field names. /// \code{cpp} /// FieldSelection({"field_one", "field_two"}); /// \endcode - VTKM_CONT - FieldSelection(std::initializer_list fields, Mode mode = Mode::Select) - : ModeType(mode) - { - for (const std::string& afield : fields) - { - this->AddField(afield, vtkm::cont::Field::Association::Any); - } - } + VTKM_CONT FieldSelection(std::initializer_list fields, Mode mode = Mode::Select); /// Use this constructor create a field selection given the field names and /// associations e.g. @@ -108,17 +75,9 @@ public: /// pair_type{"field_one", vtkm::cont::Field::Association::Points}, /// pair_type{"field_two", vtkm::cont::Field::Association::Cells} }); /// @endcode - VTKM_CONT - FieldSelection( + VTKM_CONT FieldSelection( std::initializer_list> fields, - Mode mode = Mode::Select) - : ModeType(mode) - { - for (const auto& item : fields) - { - this->AddField(item.first, item.second); - } - } + Mode mode = Mode::Select); /// Use this constructor create a field selection given the field names and /// associations e.g. @@ -128,44 +87,16 @@ public: /// pair_type{"field_one", vtkm::cont::Field::Association::Points}, /// pair_type{"field_two", vtkm::cont::Field::Association::Cells} }); /// @endcode - VTKM_CONT - FieldSelection( + VTKM_CONT FieldSelection( std::initializer_list> fields, - Mode mode = Mode::Select) - : ModeType(mode) - { - for (const auto& item : fields) - { - this->AddField(item.first, item.second); - } - } + Mode mode = Mode::Select); - // Normally the default compiler construction of each of these would be fine, - // but we don't want any of them compiled for devices (like CUDA), so we have - // to explicitly mark them as VTKM_CONT. - VTKM_CONT FieldSelection(const FieldSelection& src) - : ModeType(src.ModeType) - , Fields(src.Fields) - { - } - VTKM_CONT FieldSelection(FieldSelection&& rhs) - : ModeType(rhs.ModeType) - , Fields(std::move(rhs.Fields)) - { - } - VTKM_CONT FieldSelection& operator=(const FieldSelection& src) - { - this->ModeType = src.ModeType; - this->Fields = src.Fields; - return *this; - } - VTKM_CONT FieldSelection& operator=(FieldSelection&& rhs) - { - this->ModeType = rhs.ModeType; - this->Fields = std::move(rhs.Fields); - return *this; - } - VTKM_CONT ~FieldSelection() {} + VTKM_CONT FieldSelection(const FieldSelection& src); + VTKM_CONT FieldSelection(FieldSelection&& rhs); + VTKM_CONT FieldSelection& operator=(const FieldSelection& src); + VTKM_CONT FieldSelection& operator=(FieldSelection&& rhs); + + VTKM_CONT ~FieldSelection(); /// Returns true if the input field should be mapped to the output /// dataset. @@ -175,113 +106,98 @@ public: return this->IsFieldSelected(inputField.GetName(), inputField.GetAssociation()); } - bool IsFieldSelected( + VTKM_CONT bool IsFieldSelected( const std::string& name, - vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const - { - switch (this->ModeType) - { - case Mode::None: - return false; - - case Mode::All: - return true; - - case Mode::Select: - default: - return this->HasField(name, association); - - case Mode::Exclude: - return !this->HasField(name, association); - } - } + vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const; ///@{ - /// Add fields to map. Note, if Mode is not MODE_SELECT, then adding fields - /// will have no impact of the fields that will be mapped. - VTKM_CONT - void AddField(const vtkm::cont::Field& inputField) + /// Add fields to select or exclude. If no mode is specified, then the mode will follow + /// that of `GetMode()`. + VTKM_CONT void AddField(const vtkm::cont::Field& inputField) { - this->AddField(inputField.GetName(), inputField.GetAssociation()); + this->AddField(inputField.GetName(), inputField.GetAssociation(), this->GetMode()); + } + + VTKM_CONT void AddField(const vtkm::cont::Field& inputField, Mode mode) + { + this->AddField(inputField.GetName(), inputField.GetAssociation(), mode); } VTKM_CONT void AddField(const std::string& fieldName, vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) { - this->Fields.insert(Field(fieldName, association)); + this->AddField(fieldName, association, this->GetMode()); } + + VTKM_CONT void AddField(const std::string& fieldName, Mode mode) + { + this->AddField(fieldName, vtkm::cont::Field::Association::Any, mode); + } + + VTKM_CONT void AddField(const std::string& fieldName, + vtkm::cont::Field::Association association, + Mode mode); + ///@} + + ///@{ + /// Returns the mode for a particular field. If the field as been added with `AddField` + /// (or another means), then this will return `Select` or `Exclude`. If the field has + /// not been added, `None` will be returned. + VTKM_CONT Mode GetFieldMode(const vtkm::cont::Field& inputField) const + { + return this->GetFieldMode(inputField.GetName(), inputField.GetAssociation()); + } + + VTKM_CONT Mode GetFieldMode( + const std::string& fieldName, + vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const; ///@} /// Returns true if the input field has been added to this selection. /// Note that depending on the mode of this selection, the result of HasField /// is not necessarily the same as IsFieldSelected. (If the mode is MODE_SELECT, /// then the result of the two will be the same.) - VTKM_CONT - bool HasField(const vtkm::cont::Field& inputField) const + VTKM_CONT bool HasField(const vtkm::cont::Field& inputField) const { return this->HasField(inputField.GetName(), inputField.GetAssociation()); } - bool HasField( + VTKM_CONT bool HasField( const std::string& name, vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const { - if (this->Fields.find(Field(name, association)) != this->Fields.end()) - { - return true; - } - // if not exact match, let's lookup for Association::Any. - for (const auto& aField : this->Fields) - { - if (aField.Name == name) - { - if (aField.Association == vtkm::cont::Field::Association::Any || - association == vtkm::cont::Field::Association::Any) - { - return true; - } - } - } - return false; + return (this->GetFieldMode(name, association) != Mode::None); } /// Clear all fields added using `AddField`. - VTKM_CONT - void ClearFields() { this->Fields.clear(); } + VTKM_CONT void ClearFields(); - VTKM_CONT - Mode GetMode() const { return this->ModeType; } - void SetMode(Mode val) { this->ModeType = val; } + /// Gets the mode of the field selection. If `Select` mode is on, then only fields that have a + /// `Select` mode are considered as selected. (All others are considered unselected.) Calling + /// `AddField` in this mode will mark it as `Select`. If `Exclude` mode is on, then all fields + /// are considered selected except those fields with an `Exclude` mode. Calling `AddField` in + /// this mode will mark it as `Exclude`. + VTKM_CONT Mode GetMode() const; + + /// Sets the mode of the field selection. If `Select` mode is on, then only fields that have a + /// `Select` mode are considered as selected. (All others are considered unselected.) Calling + /// `AddField` in this mode will mark it as `Select`. If `Exclude` mode is on, then all fields + /// are considered selected except those fields with an `Exclude` mode. Calling `AddField` in + /// this mode will mark it as `Exclude`. + /// + /// If the mode is set to `None`, then the field modes are cleared and the overall mode is set to + /// `Select` (meaning none of the fields are initially selected). If the mode is set to `All`, + /// then the field modes are cleared and the overall mode is set to `Exclude` (meaning all of the + /// fields are initially selected). + VTKM_CONT void SetMode(Mode val); private: - Mode ModeType; ///< mode - - struct Field - { - std::string Name; - vtkm::cont::Field::Association Association; - Field() = default; - Field(const std::string& name, vtkm::cont::Field::Association assoc) - : Name(name) - , Association(assoc) - { - } - - Field(const Field&) = default; - Field& operator=(const Field&) = default; - - bool operator<(const Field& other) const - { - return (this->Association == other.Association) ? (this->Name < other.Name) - : (this->Association < other.Association); - } - }; - - std::set Fields; + struct InternalStruct; + std::unique_ptr Internals; }; -} -} +} +} // namespace vtkm::filter #endif // vtk_m_filter_FieldSelection_h diff --git a/vtkm/filter/FieldToColors.h b/vtkm/filter/FieldToColors.h deleted file mode 100644 index a26b77773..000000000 --- a/vtkm/filter/FieldToColors.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_FieldToColors_h -#define vtk_m_filter_FieldToColors_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_transform/FieldToColors.h instead of vtkm/filter/FieldToColors.h.") -inline void FieldToColors_deprecated() {} - -inline void FieldToColors_deprecated_warning() -{ - FieldToColors_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_FieldToColors_h diff --git a/vtkm/filter/NewFilter.cxx b/vtkm/filter/Filter.cxx similarity index 77% rename from vtkm/filter/NewFilter.cxx rename to vtkm/filter/Filter.cxx index cea0a3dd7..c1586f965 100644 --- a/vtkm/filter/NewFilter.cxx +++ b/vtkm/filter/Filter.cxx @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -23,9 +23,7 @@ namespace filter namespace { -void RunFilter(NewFilter* self, - vtkm::filter::DataSetQueue& input, - vtkm::filter::DataSetQueue& output) +void RunFilter(Filter* self, vtkm::filter::DataSetQueue& input, vtkm::filter::DataSetQueue& output) { auto& tracker = vtkm::cont::GetRuntimeDeviceTracker(); bool prevVal = tracker.GetThreadFriendlyMemAlloc(); @@ -44,15 +42,15 @@ void RunFilter(NewFilter* self, } -NewFilter::~NewFilter() = default; +Filter::~Filter() = default; -bool NewFilter::CanThread() const +bool Filter::CanThread() const { return true; } //---------------------------------------------------------------------------- -vtkm::cont::PartitionedDataSet NewFilter::DoExecutePartitions( +vtkm::cont::PartitionedDataSet Filter::DoExecutePartitions( const vtkm::cont::PartitionedDataSet& input) { vtkm::cont::PartitionedDataSet output; @@ -91,33 +89,30 @@ vtkm::cont::PartitionedDataSet NewFilter::DoExecutePartitions( return this->CreateResult(input, output); } -vtkm::cont::DataSet NewFilter::Execute(const vtkm::cont::DataSet& input) +vtkm::cont::DataSet Filter::Execute(const vtkm::cont::DataSet& input) { return this->DoExecute(input); } -vtkm::cont::PartitionedDataSet NewFilter::Execute(const vtkm::cont::PartitionedDataSet& input) +vtkm::cont::PartitionedDataSet Filter::Execute(const vtkm::cont::PartitionedDataSet& input) { VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, - "NewFilter (%d partitions): '%s'", + "Filter (%d partitions): '%s'", (int)input.GetNumberOfPartitions(), vtkm::cont::TypeToString().c_str()); return this->DoExecutePartitions(input); } -vtkm::cont::DataSet NewFilter::CreateResult(const vtkm::cont::DataSet& inDataSet) const +vtkm::cont::DataSet Filter::CreateResult(const vtkm::cont::DataSet& inDataSet) const { - vtkm::cont::DataSet clone; - clone.CopyStructure(inDataSet); - this->MapFieldsOntoOutput( - inDataSet, clone, [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { - out.AddField(fieldToPass); - }); - return clone; + auto fieldMapper = [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { + out.AddField(fieldToPass); + }; + return this->CreateResult(inDataSet, inDataSet.GetCellSet(), fieldMapper); } -vtkm::cont::PartitionedDataSet NewFilter::CreateResult( +vtkm::cont::PartitionedDataSet Filter::CreateResult( const vtkm::cont::PartitionedDataSet& input, const vtkm::cont::PartitionedDataSet& resultPartitions) const { @@ -127,7 +122,7 @@ vtkm::cont::PartitionedDataSet NewFilter::CreateResult( return this->CreateResult(input, resultPartitions, fieldMapper); } -vtkm::Id NewFilter::DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input) +vtkm::Id Filter::DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input) { vtkm::Id numDS = input.GetNumberOfPartitions(); diff --git a/vtkm/filter/Filter.h b/vtkm/filter/Filter.h index 729fed715..3e171362a 100644 --- a/vtkm/filter/Filter.h +++ b/vtkm/filter/Filter.h @@ -10,20 +10,15 @@ #ifndef vtk_m_filter_Filter_h #define vtk_m_filter_Filter_h -#include - -#include #include -#include #include #include #include #include -#include #include -#include -#include +#include +#include namespace vtkm { @@ -31,159 +26,213 @@ namespace filter { /// \brief base class for all filters. /// -/// This is the base class for all filters. To add a new filter, one can -/// subclass this (or any of the existing subclasses e.g. FilterField, -/// FilterDataSet, FilterDataSetWithField, etc. and implement relevant methods. +/// This is the base class for all filters. To add a new filter, one can subclass this (or any of +/// the existing subclasses e.g. FilterField, FilterParticleAdvection, etc.) and implement relevant +/// methods. /// /// \section FilterUsage Usage /// -/// To execute a filter, one typically calls the `auto result = -/// filter.Execute(input)`. Typical usage is as follows: +/// To execute a filter, one typically calls the `auto result = filter.Execute(input)`. Typical +/// usage is as follows: /// /// \code{cpp} /// -/// // create the concrete subclass (e.g. MarchingCubes). -/// vtkm::filter::MarchingCubes marchingCubes; +/// // create the concrete subclass (e.g. Contour). +/// vtkm::filter::contour::Contour contour; /// -/// // select fieds to map to the output, if different from default which is to -/// // map all input fields. -/// marchingCubes.SetFieldToPass({"var1", "var2"}); +/// // select fields to map to the output, if different from default which is to map all input +/// // fields. +/// contour.SetFieldToPass({"var1", "var2"}); /// /// // execute the filter on vtkm::cont::DataSet. /// vtkm::cont::DataSet dsInput = ... -/// auto outputDS = filter.Execute(dsInput); +/// auto outputDS = contour.Execute(dsInput); /// /// // or, execute on a vtkm::cont::PartitionedDataSet /// vtkm::cont::PartitionedDataSet mbInput = ... -/// auto outputMB = filter.Execute(mbInput); +/// auto outputMB = contour.Execute(mbInput); /// \endcode /// -/// `Execute` methods take in the input DataSet or PartitionedDataSet to -/// process and return the result. The type of the result is same as the input -/// type, thus `Execute(DataSet&)` returns a DataSet while -/// `Execute(PartitionedDataSet&)` returns a PartitionedDataSet. +/// `Execute` methods take in the input DataSet or PartitionedDataSet to process and return the +/// result. The type of the result is same as the input type, thus `Execute(DataSet&)` returns +/// a DataSet while `Execute(PartitionedDataSet&)` returns a PartitionedDataSet. /// -/// The implementation for `Execute(DataSet&)` is merely provided for -/// convenience. Internally, it creates a PartitionedDataSet with a single -/// partition for the input and then forwards the call to -/// `Execute(PartitionedDataSet&)`. The method returns the first partition, if -/// any, from the PartitionedDataSet returned by the forwarded call. If the -/// PartitionedDataSet returned has more than 1 partition, then -/// `vtkm::cont::ErrorFilterExecution` will be thrown. +/// `Execute` simply calls the pure virtual function `DoExecute(DataSet&)` which is the main +/// extension point of the Filter interface. Filter developer needs to override +/// `DoExecute(DataSet)` to implement the business logic of filtering operations on a single +/// DataSet. +/// +/// The default implementation of `Execute(PartitionedDataSet&)` is merely provided for +/// convenience. Internally, it calls `DoExecutePartitions(PartitionedDataSet)` to iterate DataSets +/// of a PartitionedDataSet and pass each individual DataSets to `DoExecute(DataSet&)`, +/// possibly in a multi-threaded setting. Developer of `DoExecute(DataSet&)` needs to indicate +/// the thread-safeness of `DoExecute(DataSet&)` by overriding the `CanThread()` virtual method +/// which by default returns `true`. +/// +/// In the case that filtering on a PartitionedDataSet can not be simply implemented as a +/// for-each loop on the component DataSets, filter implementor needs to override the +/// `DoExecutePartitions(PartitionedDataSet&)`. See the implementation of +/// `FilterParticleAdvection::Execute(PartitionedDataSet&)` for an example. /// /// \section FilterSubclassing Subclassing /// -/// Typically, one subclasses one of the immediate subclasses of this class such as -/// FilterField, FilterDataSet, FilterDataSetWithField, etc. Those may impose -/// additional constraints on the methods to implement in the subclasses. -/// Here, we describes the things to consider when directly subclassing -/// vtkm::filter::Filter. +/// In many uses cases, one subclasses one of the immediate subclasses of this class such as +/// FilterField, FilterParticleAdvection, etc. Those may impose additional constraints on the +/// methods to implement in the subclasses. Here, we describes the things to consider when directly +/// subclassing vtkm::filter::Filter. /// -/// \subsection FilterPreExecutePostExecute PreExecute and PostExecute +/// \subsection FilterExecution Execute /// -/// Subclasses may provide implementations for either or both of the following -/// methods. +/// A concrete subclass of Filter must provide `DoExecute` implementation that provides the meat +/// for the filter i.e. the implementation for the filter's data processing logic. There are two +/// signatures available; which one to implement depends on the nature of the filter. +/// +/// Let's consider simple filters that do not need to do anything special to handle +/// PartitionedDataSet e.g. clip, contour, etc. These are the filters where executing the filter +/// on a PartitionedDataSet simply means executing the filter on one partition at a time and +/// packing the output for each iteration info the result PartitionedDataSet. For such filters, +/// one must implement the following signature. /// /// \code{cpp} /// -/// template -/// void PreExecute(const vtkm::cont::PartitionedDataSet& input, -/// const vtkm::filter::PolicyBase& policy); -/// -/// template -/// void PostExecute(const vtkm::cont::PartitionedDataSet& input, vtkm::cont::PartitionedDataSet& output -/// const vtkm::filter::PolicyBase& policy); +/// vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input); /// /// \endcode /// -/// As the name suggests, these are called and the beginning and before the end -/// of an `Filter::Execute` call. Most filters that don't need to handle -/// PartitionedDataSet specially, e.g. clip, cut, iso-contour, need not worry -/// about these methods or provide any implementation. If, however, your filter -/// needs do to some initialization e.g. allocation buffers to accumulate -/// results, or finalization e.g. reduce results across all partitions, then -/// these methods provide convenient hooks for the same. +/// The role of this method is to execute on the input dataset and generate the result and return +/// it. If there are any errors, the subclass must throw an exception +/// (e.g. `vtkm::cont::ErrorFilterExecution`). /// -/// \subsection FilterPrepareForExecution PrepareForExecution +/// In this simple case, the Filter superclass handles iterating over multiple partitions in the +/// input PartitionedDataSet and calling `DoExecute(DataSet&)` iteratively. /// -/// A concrete subclass of Filter must provide `PrepareForExecution` -/// implementation that provides the meat for the filter i.e. the implementation -/// for the filter's data processing logic. There are two signatures -/// available; which one to implement depends on the nature of the filter. -/// -/// Let's consider simple filters that do not need to do anything special to -/// handle PartitionedDataSet e.g. clip, contour, etc. These are the filters -/// where executing the filter on a PartitionedDataSet simply means executing -/// the filter on one partition at a time and packing the output for each -/// iteration info the result PartitionedDataSet. For such filters, one must -/// implement the following signature. +/// The aforementioned approach is also suitable for filters that need special handling for +/// PartitionedDataSets that requires certain cross DataSet operations (usually scatter/gather +/// and reduction on DataSets) before and/or after the per DataSet operation. This can be done by +/// overriding `DoExecutePartitions(PartitionedDataSet&)` while calling to the base class +/// `DoExecutePartitions(PartitionedDataSet&) as helper function for iteration on DataSets. /// /// \code{cpp} -/// -/// template -/// vtkm::cont::DataSet PrepareForExecution( -/// const vtkm::cont::DataSet& input, -/// const vtkm::filter::PolicyBase& policy); -/// +/// vtkm::cont::PartitionedDataSet FooFilter::DoExecutePartitions( +/// const vtkm::cont::PartitionedDataSet& input) +/// { +/// // Do pre execute stuff, e.g. scattering to each DataSet +/// auto output = this->Filter::DoExecutePartitions(input); +/// // Do post execute stuff, e.g gather/reduce from DataSets +/// return output; +/// } /// \endcode /// -/// The role of this method is to execute on the input dataset and generate the -/// result and return it. If there are any errors, the subclass must throw an -/// exception (e.g. `vtkm::cont::ErrorFilterExecution`). +/// For more complex filters, like streamlines, particle tracking, where the processing of +/// PartitionedDataSets cannot be modelled as mapping and reduction operation on DataSet, one +/// needs fully implement `DoExecutePartitions(PartitionedDataSet&)`. Now the subclass is given +/// full control over the execution, including any mapping of fields to output (described in next +/// sub-section). /// -/// In this case, the Filter superclass handles iterating over multiple -/// partitions in the input PartitionedDataSet and calling -/// `PrepareForExecution` iteratively. +/// \subsection Creating results and mapping fields /// -/// The aforementioned approach is also suitable for filters that need special -/// handling for PartitionedDataSets which can be modelled as PreExecute and -/// PostExecute steps (e.g. `vtkm::filter::Histogram`). -/// -/// For more complex filters, like streamlines, particle tracking, where the -/// processing of PartitionedDataSets cannot be modelled as a reduction of the -/// results, one can implement the following signature. +/// For subclasses that map input fields into output fields, the implementation of its +/// `DoExecute(DataSet&)` should create the `DataSet` to be returned with a call to +/// `Filter::CreateResult` or a similar method in a subclass (such as +/// `FilterField::CreateResultField`). /// /// \code{cpp} -/// template -/// vtkm::cont::PartitionedDataSet PrepareForExecution( -/// const vtkm::cont::PartitionedDataSet& input, -/// const vtkm::filter::PolicyBase& policy); +/// VTKM_CONT DataSet SomeFilter::DoExecute(const vtkm::cont::DataSet& input) +/// { +/// vtkm::cont::UnknownCellSet outCellSet; +/// outCellSet = ... // Generation of the new CellSet +/// +/// // Mapper is a callable object (function object, lambda, etc.) that takes an input Field +/// // and maps it to an output Field and then add the output Field to the output DataSet +/// auto mapper = [](auto& outputDs, const auto& inputField) { +/// auto outputField = ... // Business logic for mapping input field to output field +/// output.AddField(outputField); +/// }; +/// // This passes coordinate systems directly from input to output. If the points of +/// // the cell set change at all, they will have to be mapped by hand. +/// return this->CreateResult(input, outCellSet, mapper); +/// } /// \endcode /// -/// The responsibility of this method is the same, except now the subclass is -/// given full control over the execution, including any mapping of fields to -/// output (described in next sub-section). +/// In addition to creating a new `DataSet` filled with the proper cell structure and coordinate +/// systems, `CreateResult` iterates through each `FieldToPass` in the input DataSet and calls the +/// FieldMapper to map the input Field to output Field. For simple filters that just pass on input +/// fields to the output DataSet without any computation, an overload of +/// `CreateResult(const vtkm::cont::DataSet& input)` is also +/// provided as a convenience that uses the default mapper which trivially adds input Field to +/// output DataSet (via a shallow copy). /// -/// \subsection FilterMapFieldOntoOutput MapFieldOntoOutput +/// \subsection FilterThreadSafety CanThread /// -/// Subclasses may provide `MapFieldOntoOutput` method with the following -/// signature: +/// By default, the implementation of `DoExecute(DataSet&)` should model a *pure function*, i.e. it +/// does not have any mutable shared state. This makes it thread-safe by default and allows +/// the default implementation of `DoExecutePartitions(PartitionedDataSet&)` to be simply a parallel +/// for-each, thus facilitates multi-threaded execution without any lock. +/// +/// Many legacy (VTKm 1.x) filter implementations needed to store states between the mesh generation +/// phase and field mapping phase of filter execution, for example, parameters for field +/// interpolation. The shared mutable states were mostly stored as mutable data members of the +/// filter class (either in terms of ArrayHandle or some kind of Worket). The new filter interface, +/// by combining the two phases into a single call to `DoExecute(DataSet&)`, we have eliminated most +/// of the cases that require such shared mutable states. New implementations of filters that +/// require passing information between these two phases can now use local variables within the +/// `DoExecute(DataSet&)`. For example: /// /// \code{cpp} +/// struct SharedState; // shared states between mesh generation and field mapping. +/// VTKM_CONT DataSet ThreadSafeFilter::DoExecute(const vtkm::cont::DataSet& input) +/// { +/// // Mutable states that was a data member of the filter is now a local variable. +/// // Each invocation of Execute(DataSet) in the multi-threaded execution of +/// // Execute(PartitionedDataSet&) will have a copy of `states` on each thread's stack +/// // thus making it thread-safe. +/// SharedStates states; /// -/// template -/// VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, -/// const vtkm::cont::Field& field, -/// const vtkm::filter::PolicyBase& policy); +/// vtkm::cont::CellSetExplicit<> cellSet; +/// cellSet = ... // Generation of the new DataSet and store interpolation parameters in `states` /// +/// // Lambda capture of `states`, effectively passing the shared states to the Mapper. +/// auto mapper = [&states](auto& outputDs, const auto& inputField) { +/// auto outputField = ... // Use `states` for mapping input field to output field +/// output.AddField(outputField); +/// }; +/// this->CreateOutput(input, cellSet, mapper); +/// +/// return output; +/// } /// \endcode /// -/// When present, this method will be called after each partition execution to -/// map an input field from the corresponding input partition to the output -/// partition. +/// In the rare cases that filter implementation can not be made thread-safe, the implementation +/// needs to override the `CanThread()` virtual method to return `false`. The default +/// `Execute(PartitionedDataSet&)` implementation will fallback to a serial for loop execution. /// -template -class VTKM_DEPRECATED(1.9, "Use vtkm::filter::NewFilter.") Filter +/// \subsection FilterThreadScheduling DoExecute +/// The default multi-threaded execution of `Execute(PartitionedDataSet&)` uses a simple FIFO queue +/// of DataSet and pool of *worker* threads. Implementation of Filter subclass can override the +/// `DoExecutePartitions(PartitionedDataSet)` virtual method to provide implementation specific +/// scheduling policy. The default number of *worker* threads in the pool are determined by the +/// `DetermineNumberOfThreads()` virtual method using several backend dependent heuristic. +/// Implementations of Filter subclass can also override +/// `DetermineNumberOfThreads()` to provide implementation specific heuristic. +/// +class VTKM_FILTER_CORE_EXPORT Filter { public: - VTKM_CONT - Filter(); - VTKM_CONT virtual ~Filter(); VTKM_CONT - virtual bool CanThread() const { return false; } + virtual bool CanThread() const; + + VTKM_CONT + void SetThreadsPerCPU(vtkm::Id numThreads) { this->NumThreadsPerCPU = numThreads; } + VTKM_CONT + void SetThreadsPerGPU(vtkm::Id numThreads) { this->NumThreadsPerGPU = numThreads; } + + VTKM_CONT + vtkm::Id GetThreadsPerCPU() const { return this->NumThreadsPerCPU; } + VTKM_CONT + vtkm::Id GetThreadsPerGPU() const { return this->NumThreadsPerGPU; } VTKM_CONT bool GetRunMultiThreadedFilter() const @@ -199,52 +248,11 @@ public: else { std::string msg = - "Multi threaded filter not supported for " + std::string(typeid(Derived).name()); + "Multi threaded filter not supported for " + std::string(typeid(*this).name()); VTKM_LOG_S(vtkm::cont::LogLevel::Info, msg); } } - VTKM_CONT - virtual Filter* Clone() const - { - throw vtkm::cont::ErrorExecution("You must implement Clone in the derived class."); - } - - /// \brief Specify which subset of types a filter supports. - /// - /// A filter is able to state what subset of types it supports. - using SupportedTypes = VTKM_DEFAULT_TYPE_LIST; - - /// \brief Specify which additional field storage to support. - /// - /// When a filter gets a field value from a DataSet, it has to determine what type - /// of storage the array has. Typically this is taken from the default storage - /// types defined in DefaultTypes.h. In some cases it is useful to support additional - /// types. For example, the filter might make sense to support ArrayHandleIndex or - /// ArrayHandleConstant. If so, the storage of those additional types should be - /// listed here. - using AdditionalFieldStorage = vtkm::ListEmpty; - - /// \brief Specify which structured cell sets to support. - /// - /// When a filter gets a cell set from a DataSet, it has to determine what type - /// of concrete cell set it is. This provides a list of supported structured - /// cell sets. - using SupportedStructuredCellSets = VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED; - - /// \brief Specify which unstructured cell sets to support. - /// - /// When a filter gets a cell set from a DataSet, it has to determine what type - /// of concrete cell set it is. This provides a list of supported unstructured - /// cell sets. - using SupportedUnstructuredCellSets = VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED; - - /// \brief Specify which unstructured cell sets to support. - /// - /// When a filter gets a cell set from a DataSet, it has to determine what type - /// of concrete cell set it is. This provides a list of supported cell sets. - using SupportedCellSets = VTKM_DEFAULT_CELL_SET_LIST; - ///@{ /// \brief Specify which fields get passed from input to output. /// @@ -284,18 +292,26 @@ public: vtkm::filter::FieldSelection& GetFieldsToPass() { return this->FieldsToPass; } ///@} + ///@{ + /// \brief Specify whether to always pass coordinate systems. + /// + /// `CoordinateSystem`s in a `DataSet` are really just point fields marked as being a + /// coordinate system. Thus, a coordinate system is passed if and only if the associated + /// field is passed. + /// + /// By default, the filter will pass all fields associated with a coordinate system + /// regardless of the `FieldsToPass` marks the field as passing. If this option is set + /// to `false`, then coordinate systems will only be passed if it is marked so by + /// `FieldsToPass`. + VTKM_CONT void SetPassCoordinateSystems(bool flag) { this->PassCoordinateSystems = flag; } + VTKM_CONT bool GetPassCoordinateSystems() const { return this->PassCoordinateSystems; } + ///@} + ///@{ /// Executes the filter on the input and produces a result dataset. /// /// On success, this the dataset produced. On error, vtkm::cont::ErrorExecution will be thrown. VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input); - - template - VTKM_DEPRECATED(1.6, - "Filter::Execute no longer guarantees policy modifications. " - "Specify default types in CMake configuration instead.") - VTKM_CONT vtkm::cont::DataSet - Execute(const vtkm::cont::DataSet& input, vtkm::filter::PolicyBase policy); ///@} ///@{ @@ -303,49 +319,227 @@ public: /// /// On success, this the dataset produced. On error, vtkm::cont::ErrorExecution will be thrown. VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input); - - VTKM_CONT vtkm::cont::PartitionedDataSet ExecuteThreaded( - const vtkm::cont::PartitionedDataSet& input, - vtkm::Id numThreads); - - template - VTKM_DEPRECATED(1.6, - "Filter::Execute no longer guarantees policy modifications. " - "Specify default types in CMake configuration instead.") - VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input, - vtkm::filter::PolicyBase policy); ///@} - /// Map fields from input dataset to output. - /// This is not intended for external use. Subclasses of Filter, however, may - /// use this method to map fields. - template - VTKM_CONT void MapFieldsToPass(const vtkm::cont::DataSet& input, - vtkm::cont::DataSet& output, - vtkm::filter::PolicyBase policy); - + // FIXME: Is this actually materialize? Are there different kinds of Invoker? /// Specify the vtkm::cont::Invoker to be used to execute worklets by /// this filter instance. Overriding the default allows callers to control /// which device adapters a filter uses. void SetInvoker(vtkm::cont::Invoker inv) { this->Invoke = inv; } - VTKM_CONT - virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input); - protected: vtkm::cont::Invoker Invoke; - vtkm::filter::Filter& operator=(const vtkm::filter::Filter&) = default; + /// \brief Create the output data set for `DoExecute`. + /// + /// This form of `CreateResult` will create an output data set with the same cell + /// structure and coordinate system as the input and pass all fields (as requested + /// by the `Filter` state). + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed into + /// `DoExecute`). The returned `DataSet` is filled with the cell set, coordinate system, and + /// fields of `inDataSet` (as selected by the `FieldsToPass` state of the filter). + /// + VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet) const; - VTKM_CONT - void CopyStateFrom(const Filter* filter) { *this = *filter; } + + /// \brief Create the output data set for `DoExecute`. + /// + /// This form of `CreateResult` will create an output PartitionedDataSet with the + /// same partitions and pass all PartitionedDataSet fields (as requested by the + /// `Filter` state). + /// + /// \param[in] input The input data set being modified (usually the one passed into + /// `DoExecute`). + /// \param[in] resultPartitions The output data created by the filter. Fields from the input are + /// passed onto the return result partition as requested by the `Filter` state. + /// + VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::cont::PartitionedDataSet& resultPartitions) const; + + /// \brief Create the output data set for `DoExecute`. + /// + /// This form of `CreateResult` will create an output PartitionedDataSet with the + /// same partitions and pass all PartitionedDataSet fields (as requested by the + /// `Filter` state). + /// + /// \param[in] input The input data set being modified (usually the one passed into + /// `DoExecute`). + /// \param[in] resultPartitions The output data created by the filter. Fields from the input are + /// passed onto the return result partition as requested by the `Filter` state. + /// \param[in] fieldMapper A function or functor that takes a `PartitionedDataSet` as its first + /// argument and a `Field` as its second argument. The `PartitionedDataSet` is the data being + /// created and will eventually be returned by `CreateResult`. The `Field` comes from `input`. + /// + template + VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::cont::PartitionedDataSet& resultPartitions, + FieldMapper&& fieldMapper) const + { + vtkm::cont::PartitionedDataSet output(resultPartitions.GetPartitions()); + this->MapFieldsOntoOutput(input, this->GetFieldsToPass(), output, fieldMapper); + return output; + } + + /// \brief Create the output data set for `DoExecute`. + /// + /// This form of `CreateResult` will create an output data set with the given `CellSet`. You must + /// also provide a field mapper function, which is a function that takes the output `DataSet` + /// being created and a `Field` from the input and then applies any necessary transformations to + /// the field array and adds it to the `DataSet`. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultCellSet The `CellSet` of the output will be set to this. + /// \param[in] fieldMapper A function or functor that takes a `DataSet` as its first + /// argument and a `Field` as its second argument. The `DataSet` is the data being + /// created and will eventually be returned by `CreateResult`. The `Field` comes from + /// `inDataSet`. The function should map the `Field` to match `resultCellSet` and then + /// add the resulting field to the `DataSet`. If the mapping is not possible, then + /// the function should do nothing. + /// + template + VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet, + const vtkm::cont::UnknownCellSet& resultCellSet, + FieldMapper&& fieldMapper) const + { + vtkm::cont::DataSet outDataSet; + outDataSet.SetCellSet(resultCellSet); + this->MapFieldsOntoOutput(inDataSet, this->GetFieldsToPass(), outDataSet, fieldMapper); + return outDataSet; + } + + ///@{ + /// \brief Create the output data set for `DoExecute`. + /// + /// This form of `CreateResult` will create an output data set with the given `CellSet` + /// and `CoordinateSystem`. You must also provide a field mapper function, which is a + /// function that takes the output `DataSet` being created and a `Field` from the input + /// and then applies any necessary transformations to the field array and adds it to + /// the `DataSet`. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultCellSet The `CellSet` of the output will be set to this. + /// \param[in] resultCoordSystem This `CoordinateSystem` will be added to the output. + /// \param[in] fieldMapper A function or functor that takes a `DataSet` as its first + /// argument and a `Field` as its second argument. The `DataSet` is the data being + /// created and will eventually be returned by `CreateResult`. The `Field` comes from + /// `inDataSet`. The function should map the `Field` to match `resultCellSet` and then + /// add the resulting field to the `DataSet`. If the mapping is not possible, then + /// the function should do nothing. + /// + template + VTKM_CONT vtkm::cont::DataSet CreateResultCoordinateSystem( + const vtkm::cont::DataSet& inDataSet, + const vtkm::cont::UnknownCellSet& resultCellSet, + const vtkm::cont::CoordinateSystem& resultCoordSystem, + FieldMapper&& fieldMapper) const + { + vtkm::cont::DataSet outDataSet; + outDataSet.SetCellSet(resultCellSet); + outDataSet.AddCoordinateSystem(resultCoordSystem); + vtkm::filter::FieldSelection fieldSelection = this->GetFieldsToPass(); + fieldSelection.AddField(resultCoordSystem, vtkm::filter::FieldSelection::Mode::Exclude); + this->MapFieldsOntoOutput(inDataSet, fieldSelection, outDataSet, fieldMapper); + return outDataSet; + } + + template + VTKM_CONT vtkm::cont::DataSet CreateResultCoordinateSystem( + const vtkm::cont::DataSet& inDataSet, + const vtkm::cont::UnknownCellSet& resultCellSet, + const std::string& coordsName, + const vtkm::cont::UnknownArrayHandle& coordsData, + FieldMapper&& fieldMapper) const + { + return this->CreateResultCoordinateSystem( + inDataSet, + resultCellSet, + vtkm::cont::CoordinateSystem{ coordsName, coordsData }, + fieldMapper); + } + ///@} + + VTKM_CONT virtual vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) = 0; + VTKM_CONT virtual vtkm::cont::PartitionedDataSet DoExecutePartitions( + const vtkm::cont::PartitionedDataSet& inData); private: - vtkm::filter::FieldSelection FieldsToPass; + template + VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input, + const vtkm::filter::FieldSelection& fieldSelection, + vtkm::cont::DataSet& output, + FieldMapper&& fieldMapper) const + { + // Basic field mapping + for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) + { + auto field = input.GetField(cc); + if (fieldSelection.IsFieldSelected(field)) + { + fieldMapper(output, field); + } + } + + // Check if the ghost levels have been copied. If so, set so on the output. + if (input.HasGhostCellField()) + { + const std::string& ghostFieldName = input.GetGhostCellFieldName(); + if (output.HasCellField(ghostFieldName) && (output.GetGhostCellFieldName() != ghostFieldName)) + { + output.SetGhostCellFieldName(ghostFieldName); + } + } + + for (vtkm::IdComponent csIndex = 0; csIndex < input.GetNumberOfCoordinateSystems(); ++csIndex) + { + auto coords = input.GetCoordinateSystem(csIndex); + if (!output.HasCoordinateSystem(coords.GetName())) + { + if (!output.HasPointField(coords.GetName()) && this->GetPassCoordinateSystems()) + { + fieldMapper(output, coords); + } + if (output.HasPointField(coords.GetName())) + { + output.AddCoordinateSystem(coords.GetName()); + } + } + } + } + + template + VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::FieldSelection& fieldSelection, + vtkm::cont::PartitionedDataSet& output, + FieldMapper&& fieldMapper) const + { + for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) + { + auto field = input.GetField(cc); + if (fieldSelection.IsFieldSelected(field)) + { + fieldMapper(output, field); + } + } + } + + VTKM_CONT + virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input); + + + vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All; + bool PassCoordinateSystems = true; bool RunFilterWithMultipleThreads = false; + vtkm::Id NumThreadsPerCPU = 4; + vtkm::Id NumThreadsPerGPU = 8; }; } } // namespace vtkm::filter -#include #endif diff --git a/vtkm/filter/Filter.hxx b/vtkm/filter/Filter.hxx deleted file mode 100644 index d81cd7fb2..000000000 --- a/vtkm/filter/Filter.hxx +++ /dev/null @@ -1,469 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace vtkm -{ -namespace filter -{ - -namespace internal -{ - -template -struct SupportsPreExecute -{ - template ().PreExecute( - std::declval(), - std::declval>()))> - static std::true_type has(int); - template - static std::false_type has(...); - using type = decltype(has(0)); -}; - -template -struct SupportsPostExecute -{ - template ().PostExecute( - std::declval(), - std::declval(), - std::declval>()))> - static std::true_type has(int); - template - static std::false_type has(...); - using type = decltype(has(0)); -}; - - -template -struct SupportsPrepareForExecution -{ - template ().PrepareForExecution( - std::declval(), - std::declval>()))> - static std::true_type has(int); - template - static std::false_type has(...); - using type = decltype(has(0)); -}; - -template -struct SupportsMapFieldOntoOutput -{ - template ().MapFieldOntoOutput( - std::declval(), - std::declval(), - std::declval>()))> - static std::true_type has(int); - template - static std::false_type has(...); - using type = decltype(has(0)); -}; - -//-------------------------------------------------------------------------------- -template -void CallPreExecuteInternal(std::true_type, Derived* self, Args&&... args) -{ - return self->PreExecute(std::forward(args)...); -} - -//-------------------------------------------------------------------------------- -template -void CallPreExecuteInternal(std::false_type, Derived*, Args&&...) -{ -} - -//-------------------------------------------------------------------------------- -template -void CallPreExecute(Derived* self, - const InputType& input, - const vtkm::filter::PolicyBase& policy) -{ - using call_supported_t = typename SupportsPreExecute::type; - CallPreExecuteInternal(call_supported_t(), self, input, policy); -} - -//-------------------------------------------------------------------------------- -template -void CallMapFieldOntoOutputInternal(std::true_type, - Derived* self, - const vtkm::cont::DataSet& input, - vtkm::cont::DataSet& output, - const vtkm::filter::PolicyBase& policy) -{ - for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) - { - auto field = input.GetField(cc); - if (self->GetFieldsToPass().IsFieldSelected(field)) - { - self->MapFieldOntoOutput(output, field, policy); - } - } -} - -//-------------------------------------------------------------------------------- -template -void CallMapFieldOntoOutputInternal(std::false_type, - Derived* self, - const vtkm::cont::DataSet& input, - vtkm::cont::DataSet& output, - const vtkm::filter::PolicyBase&) -{ - // no MapFieldOntoOutput method is present. In that case, we simply copy the - // requested input fields to the output. - for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) - { - auto field = input.GetField(cc); - if (self->GetFieldsToPass().IsFieldSelected(field)) - { - output.AddField(field); - } - } -} - -//-------------------------------------------------------------------------------- -template -void CallMapFieldOntoOutput(Derived* self, - const vtkm::cont::DataSet& input, - vtkm::cont::DataSet& output, - vtkm::filter::PolicyBase policy) -{ - using call_supported_t = typename SupportsMapFieldOntoOutput::type; - CallMapFieldOntoOutputInternal(call_supported_t(), self, input, output, policy); -} - -//-------------------------------------------------------------------------------- -// forward declare. -template -InputType CallPrepareForExecution(Derived* self, - const InputType& input, - const vtkm::filter::PolicyBase& policy); - -//-------------------------------------------------------------------------------- -template -InputType CallPrepareForExecutionInternal(std::true_type, - Derived* self, - const InputType& input, - const vtkm::filter::PolicyBase& policy) -{ - return self->PrepareForExecution(input, policy); -} - -template -void RunFilter(Derived* self, - const vtkm::filter::PolicyBase& policy, - vtkm::filter::DataSetQueue& input, - vtkm::filter::DataSetQueue& output) -{ - auto filterClone = static_cast(self->Clone()); - - std::pair task; - while (input.GetTask(task)) - { - auto outDS = CallPrepareForExecution(filterClone, task.second, policy); - CallMapFieldOntoOutput(filterClone, task.second, outDS, policy); - output.Push(std::make_pair(task.first, std::move(outDS))); - } - - vtkm::cont::Algorithm::Synchronize(); - delete filterClone; -} - -//-------------------------------------------------------------------------------- -// specialization for PartitionedDataSet input when `PrepareForExecution` is not provided -// by the subclass. we iterate over blocks and execute for each block -// individually. -template -vtkm::cont::PartitionedDataSet CallPrepareForExecutionInternal( - std::false_type, - Derived* self, - const vtkm::cont::PartitionedDataSet& input, - const vtkm::filter::PolicyBase& policy) -{ - vtkm::cont::PartitionedDataSet output; - - if (self->GetRunMultiThreadedFilter()) - { - vtkm::filter::DataSetQueue inputQueue(input); - vtkm::filter::DataSetQueue outputQueue; - - vtkm::Id numThreads = self->DetermineNumberOfThreads(input); - - //Run 'numThreads' filters. - std::vector> futures(static_cast(numThreads)); - for (std::size_t i = 0; i < static_cast(numThreads); i++) - { - auto f = std::async(std::launch::async, - RunFilter, - self, - policy, - std::ref(inputQueue), - std::ref(outputQueue)); - futures[i] = std::move(f); - } - - for (auto& f : futures) - f.get(); - - //Get results from the outputQueue. - output = outputQueue.Get(); - } - else - { - for (const auto& inBlock : input) - { - vtkm::cont::DataSet outBlock = CallPrepareForExecution(self, inBlock, policy); - CallMapFieldOntoOutput(self, inBlock, outBlock, policy); - output.AppendPartition(outBlock); - } - } - - return output; -} - -//-------------------------------------------------------------------------------- -template -InputType CallPrepareForExecution(Derived* self, - const InputType& input, - const vtkm::filter::PolicyBase& policy) -{ - using call_supported_t = - typename SupportsPrepareForExecution::type; - return CallPrepareForExecutionInternal(call_supported_t(), self, input, policy); -} - -//-------------------------------------------------------------------------------- -template -void CallPostExecuteInternal(std::true_type, - Derived* self, - const InputType& input, - InputType& output, - const vtkm::filter::PolicyBase& policy) -{ - self->PostExecute(input, output, policy); -} - -//-------------------------------------------------------------------------------- -template -void CallPostExecuteInternal(std::false_type, Derived*, Args&&...) -{ -} - -//-------------------------------------------------------------------------------- -template -void CallPostExecute(Derived* self, - const InputType& input, - InputType& output, - const vtkm::filter::PolicyBase& policy) -{ - using call_supported_t = typename SupportsPostExecute::type; - CallPostExecuteInternal(call_supported_t(), self, input, output, policy); -} -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT Filter::Filter() - : Invoke() - , FieldsToPass(vtkm::filter::FieldSelection::Mode::All) -{ -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT Filter::~Filter() -{ -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT vtkm::cont::DataSet Filter::Execute(const vtkm::cont::DataSet& input) -{ - Derived* self = static_cast(this); - vtkm::cont::PartitionedDataSet output = self->Execute(vtkm::cont::PartitionedDataSet(input)); - if (output.GetNumberOfPartitions() > 1) - { - throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block."); - } - return output.GetNumberOfPartitions() == 1 ? output.GetPartition(0) : vtkm::cont::DataSet(); -} - -template -inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter::Execute( - const vtkm::cont::PartitionedDataSet& input) -{ - VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, - "Filter (%d partitions): '%s'", - (int)input.GetNumberOfPartitions(), - vtkm::cont::TypeToString().c_str()); - - Derived* self = static_cast(this); - - vtkm::filter::PolicyDefault policy; - - // Call `void Derived::PreExecute(input, policy)`, if defined. - internal::CallPreExecute(self, input, policy); - - // Call `PrepareForExecution` (which should probably be renamed at some point) - vtkm::cont::PartitionedDataSet output = internal::CallPrepareForExecution(self, input, policy); - - // Call `Derived::PostExecute(input, output, policy)` if defined. - internal::CallPostExecute(self, input, output, policy); - return output; -} - -template -inline VTKM_CONT vtkm::Id Filter::DetermineNumberOfThreads( - const vtkm::cont::PartitionedDataSet& input) -{ - vtkm::Id numDS = input.GetNumberOfPartitions(); - - //Aribitrary constants. - const vtkm::Id threadsPerGPU = 8; - const vtkm::Id threadsPerCPU = 4; - - vtkm::Id availThreads = 1; - - auto& tracker = vtkm::cont::GetRuntimeDeviceTracker(); - - if (tracker.CanRunOn(vtkm::cont::DeviceAdapterTagCuda{})) - availThreads = threadsPerGPU; - else if (tracker.CanRunOn(vtkm::cont::DeviceAdapterTagKokkos{})) - { - //Kokkos doesn't support threading on the CPU. -#ifdef VTKM_KOKKOS_CUDA - availThreads = threadsPerGPU; -#else - availThreads = 1; -#endif - } - else if (tracker.CanRunOn(vtkm::cont::DeviceAdapterTagSerial{})) - availThreads = 1; - else - availThreads = threadsPerCPU; - - vtkm::Id numThreads = std::min(numDS, availThreads); - return numThreads; -} - -template -inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter::ExecuteThreaded( - const vtkm::cont::PartitionedDataSet& input, - vtkm::Id vtkmNotUsed(numThreads)) -{ - VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, - "Filter (%d partitions): '%s'", - (int)input.GetNumberOfPartitions(), - vtkm::cont::TypeToString().c_str()); - - Derived* self = static_cast(this); - - vtkm::filter::PolicyDefault policy; - - // Call `void Derived::PreExecute(input, policy)`, if defined. - internal::CallPreExecute(self, input, policy); - - // Call `PrepareForExecution` (which should probably be renamed at some point) - vtkm::cont::PartitionedDataSet output = internal::CallPrepareForExecution(self, input, policy); - - // Call `Derived::PostExecute(input, output, policy)` if defined. - internal::CallPostExecute(self, input, output, policy); - return output; -} - - - - -//---------------------------------------------------------------------------- -template -template -VTKM_CONT vtkm::cont::DataSet Filter::Execute( - const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy) -{ - Derived* self = static_cast(this); - VTKM_DEPRECATED_SUPPRESS_BEGIN - vtkm::cont::PartitionedDataSet output = - self->Execute(vtkm::cont::PartitionedDataSet(input), policy); - VTKM_DEPRECATED_SUPPRESS_END - if (output.GetNumberOfPartitions() > 1) - { - throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block."); - } - return output.GetNumberOfPartitions() == 1 ? output.GetPartition(0) : vtkm::cont::DataSet(); -} - -//---------------------------------------------------------------------------- -template -template -VTKM_CONT vtkm::cont::PartitionedDataSet Filter::Execute( - const vtkm::cont::PartitionedDataSet& input, - vtkm::filter::PolicyBase policy) -{ - VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, - "Filter (%d partitions): '%s'", - (int)input.GetNumberOfPartitions(), - vtkm::cont::TypeToString().c_str()); - - Derived* self = static_cast(this); - - // Call `void Derived::PreExecute(input, policy)`, if defined. - internal::CallPreExecute(self, input, policy); - - // Call `PrepareForExecution` (which should probably be renamed at some point) - vtkm::cont::PartitionedDataSet output = internal::CallPrepareForExecution(self, input, policy); - - // Call `Derived::PostExecute(input, output, policy)` if defined. - internal::CallPostExecute(self, input, output, policy); - return output; -} - -//---------------------------------------------------------------------------- -template -template -inline VTKM_CONT void Filter::MapFieldsToPass( - const vtkm::cont::DataSet& input, - vtkm::cont::DataSet& output, - vtkm::filter::PolicyBase policy) -{ - Derived* self = static_cast(this); - for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) - { - auto field = input.GetField(cc); - if (this->GetFieldsToPass().IsFieldSelected(field)) - { - internal::CallMapFieldOntoOutput(self, output, field, policy); - } - } -} -} -} diff --git a/vtkm/filter/FilterCell.h b/vtkm/filter/FilterCell.h deleted file mode 100644 index 2025dae64..000000000 --- a/vtkm/filter/FilterCell.h +++ /dev/null @@ -1,28 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_CellFilter_h -#define vtk_m_filter_CellFilter_h - -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -using FilterCell VTKM_DEPRECATED(1.6, "Use FilterField instead of FilterCell.") = - vtkm::filter::FilterField; -VTKM_DEPRECATED_SUPPRESS_END -} -} -#endif // vtk_m_filter_CellFilter_h diff --git a/vtkm/filter/FilterDataSet.h b/vtkm/filter/FilterDataSet.h deleted file mode 100644 index cf2b3df78..000000000 --- a/vtkm/filter/FilterDataSet.h +++ /dev/null @@ -1,78 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_DataSetFilter_h -#define vtk_m_filter_DataSetFilter_h - -#include -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -class VTKM_DEPRECATED(1.9, "Use vtkm::filter::NewFilter.") FilterDataSet - : public vtkm::filter::Filter -{ -public: - VTKM_CONT - FilterDataSet(); - - VTKM_CONT - ~FilterDataSet(); - - VTKM_CONT - void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; } - - VTKM_CONT - vtkm::Id GetActiveCoordinateSystemIndex() const { return this->CoordinateSystemIndex; } - - /// These are provided to satisfy the Filter API requirements. - - //From the field we can extract the association component - // Association::Any -> unable to map - // Association::WholeDataSet -> (I think this is points) - // Association::Points -> map using point mapping - // Association::Cells -> how do we map this? - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy); - -protected: - vtkm::filter::FilterDataSet& operator=(const vtkm::filter::FilterDataSet&) = - default; - VTKM_CONT - void CopyStateFrom(const FilterDataSet* filter) { *this = *filter; } - -private: - vtkm::Id CoordinateSystemIndex; - - friend class vtkm::filter::Filter; -}; -VTKM_DEPRECATED_SUPPRESS_END -} -} // namespace vtkm::filter - -#include - -#endif // vtk_m_filter_DataSetFilter_h diff --git a/vtkm/filter/FilterDataSet.hxx b/vtkm/filter/FilterDataSet.hxx deleted file mode 100644 index 04df41b17..000000000 --- a/vtkm/filter/FilterDataSet.hxx +++ /dev/null @@ -1,82 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include -#include - -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterDataSet::FilterDataSet() - : CoordinateSystemIndex(0) -{ -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterDataSet::~FilterDataSet() -{ -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT vtkm::cont::DataSet FilterDataSet::PrepareForExecution( - const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy) -{ - return (static_cast(this))->DoExecute(input, policy); -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT bool FilterDataSet::MapFieldOntoOutput( - vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy) -{ - bool valid = false; - - vtkm::filter::FieldMetadata metaData(field); - using FunctorType = internal::ResolveFieldTypeAndMap; - FunctorType functor(static_cast(this), result, metaData, policy, valid); - - try - { - vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyFieldNotActive(field, policy), functor); - } - catch (vtkm::cont::ErrorBadType& error) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Warn, - "Failed to map field " << field.GetName() - << " because it is an unknown type. Cast error:\n" - << error.GetMessage()); - (void)error; // Suppress unused error message if logging is turned off. - } - - //the bool valid will be modified by the map algorithm to hold if the - //mapping occurred or not. If the mapping was good a new field has been - //added to the result that was passed in. - return valid; -} -} -} diff --git a/vtkm/filter/FilterDataSetWithField.h b/vtkm/filter/FilterDataSetWithField.h deleted file mode 100644 index 4a93d237f..000000000 --- a/vtkm/filter/FilterDataSetWithField.h +++ /dev/null @@ -1,120 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_DataSetWithFieldFilter_h -#define vtk_m_filter_DataSetWithFieldFilter_h - -#include -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -class VTKM_DEPRECATED(1.9, "Use vtkm::filter::NewFilterField.") FilterDataSetWithField - : public vtkm::filter::Filter -{ -public: - VTKM_CONT - FilterDataSetWithField(); - - VTKM_CONT - ~FilterDataSetWithField(); - - VTKM_CONT - void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; } - - VTKM_CONT - vtkm::Id GetActiveCoordinateSystemIndex() const { return this->CoordinateSystemIndex; } - - ///@{ - /// Choose the field to operate on. Note, if - /// `this->UseCoordinateSystemAsField` is true, then the active field is not used. - VTKM_CONT - void SetActiveField( - const std::string& name, - vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) - { - this->ActiveFieldName = name; - this->ActiveFieldAssociation = association; - } - - VTKM_CONT const std::string& GetActiveFieldName() const { return this->ActiveFieldName; } - VTKM_CONT vtkm::cont::Field::Association GetActiveFieldAssociation() const - { - return this->ActiveFieldAssociation; - } - ///@} - - ///@{ - /// To simply use the active coordinate system as the field to operate on, set - /// UseCoordinateSystemAsField to true. - VTKM_CONT - void SetUseCoordinateSystemAsField(bool val) { this->UseCoordinateSystemAsField = val; } - VTKM_CONT - bool GetUseCoordinateSystemAsField() const { return this->UseCoordinateSystemAsField; } - ///@} - - //From the field we can extract the association component - // Association::Any -> unable to map - // Association::WholeDataSet -> (I think this is points) - // Association::Points -> map using point mapping - // Association::Cells -> how do we map this? - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy); - -protected: - vtkm::filter::FilterDataSetWithField& operator=( - const vtkm::filter::FilterDataSetWithField&) = default; - - VTKM_CONT - void CopyStateFrom(const FilterDataSetWithField* filter) { *this = *filter; } - -private: - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - - //How do we specify float/double coordinate types? - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - const vtkm::cont::CoordinateSystem& field, - vtkm::filter::PolicyBase policy); - - std::string OutputFieldName; - vtkm::Id CoordinateSystemIndex; - std::string ActiveFieldName; - vtkm::cont::Field::Association ActiveFieldAssociation; - bool UseCoordinateSystemAsField; - - friend class vtkm::filter::Filter; -}; -VTKM_DEPRECATED_SUPPRESS_END -} -} // namespace vtkm::filter - -#include - -#endif // vtk_m_filter_DataSetWithFieldFilter_h diff --git a/vtkm/filter/FilterDataSetWithField.hxx b/vtkm/filter/FilterDataSetWithField.hxx deleted file mode 100644 index d42442606..000000000 --- a/vtkm/filter/FilterDataSetWithField.hxx +++ /dev/null @@ -1,141 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterDataSetWithField::FilterDataSetWithField() - : OutputFieldName() - , CoordinateSystemIndex(0) - , ActiveFieldName() - , ActiveFieldAssociation(vtkm::cont::Field::Association::Any) - , UseCoordinateSystemAsField(false) -{ -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterDataSetWithField::~FilterDataSetWithField() -{ -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField::PrepareForExecution( - const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy) -{ - if (this->UseCoordinateSystemAsField) - { - // we need to state that the field is actually a coordinate system, so that - // the filter uses the proper policy to convert the types. - return this->PrepareForExecution(input, input.GetCoordinateSystem(), policy); - } - else - { - return this->PrepareForExecution( - input, input.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation()), policy); - } -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField::PrepareForExecution( - const vtkm::cont::DataSet& input, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy) -{ - vtkm::filter::FieldMetadata metaData(field); - vtkm::cont::DataSet result; - - vtkm::cont::CastAndCall( - vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits()), - internal::ResolveFieldTypeAndExecute(), - static_cast(this), - input, - metaData, - policy, - result); - return result; -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField::PrepareForExecution( - const vtkm::cont::DataSet& input, - const vtkm::cont::CoordinateSystem& field, - vtkm::filter::PolicyBase policy) -{ - //We have a special signature just for CoordinateSystem, so that we can ask - //the policy for the storage types and value types just for coordinate systems - vtkm::filter::FieldMetadata metaData(field); - vtkm::cont::DataSet result; - - //determine the field type first - using Traits = vtkm::filter::FilterTraits; - constexpr bool supportsVec3 = - vtkm::ListHas::value; - using supportsCoordinateSystem = std::integral_constant; - vtkm::cont::ConditionalCastAndCall(supportsCoordinateSystem(), - field, - internal::ResolveFieldTypeAndExecute(), - static_cast(this), - input, - metaData, - policy, - result); - - return result; -} - -//----------------------------------------------------------------------------- -template -template -inline VTKM_CONT bool FilterDataSetWithField::MapFieldOntoOutput( - vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy) -{ - bool valid = false; - - vtkm::filter::FieldMetadata metaData(field); - using FunctorType = internal::ResolveFieldTypeAndMap; - FunctorType functor(static_cast(this), result, metaData, policy, valid); - - vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyFieldNotActive(field, policy), functor); - - //the bool valid will be modified by the map algorithm to hold if the - //mapping occurred or not. If the mapping was good a new field has been - //added to the result that was passed in. - return valid; -} -} -} diff --git a/vtkm/filter/NewFilterField.cxx b/vtkm/filter/FilterField.cxx similarity index 82% rename from vtkm/filter/NewFilterField.cxx rename to vtkm/filter/FilterField.cxx index 30a5b1f7a..89d85e40f 100644 --- a/vtkm/filter/NewFilterField.cxx +++ b/vtkm/filter/FilterField.cxx @@ -7,15 +7,15 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include namespace vtkm { namespace filter { -vtkm::cont::DataSet NewFilterField::CreateResultField(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::Field& resultField) const +vtkm::cont::DataSet FilterField::CreateResultField(const vtkm::cont::DataSet& inDataSet, + const vtkm::cont::Field& resultField) const { vtkm::cont::DataSet outDataSet = this->CreateResult(inDataSet); outDataSet.AddField(resultField); @@ -24,7 +24,7 @@ vtkm::cont::DataSet NewFilterField::CreateResultField(const vtkm::cont::DataSet& return outDataSet; } -void NewFilterField::ResizeIfNeeded(size_t index_st) +void FilterField::ResizeIfNeeded(size_t index_st) { if (this->ActiveFieldNames.size() <= index_st) { diff --git a/vtkm/filter/FilterField.h b/vtkm/filter/FilterField.h index ffc4bc4ef..1e6d7389c 100644 --- a/vtkm/filter/FilterField.h +++ b/vtkm/filter/FilterField.h @@ -8,33 +8,20 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_FieldFilter_h -#define vtk_m_filter_FieldFilter_h - -#include -#include -#include -#include +#ifndef vtk_m_filter_FilterField_h +#define vtk_m_filter_FilterField_h #include -#include namespace vtkm { namespace filter { -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -class VTKM_DEPRECATED(1.9, "Use vtkm::filter::NewFilterField.") FilterField - : public vtkm::filter::Filter +class VTKM_FILTER_CORE_EXPORT FilterField : public vtkm::filter::Filter { public: - VTKM_CONT - FilterField(); - - VTKM_CONT - ~FilterField(); + FilterField() { this->SetActiveCoordinateSystem(0); } VTKM_CONT void SetOutputFieldName(const std::string& name) { this->OutputFieldName = name; } @@ -50,14 +37,63 @@ public: const std::string& name, vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) { - this->ActiveFieldName = name; - this->ActiveFieldAssociation = association; + this->SetActiveField(0, name, association); } - VTKM_CONT const std::string& GetActiveFieldName() const { return this->ActiveFieldName; } - VTKM_CONT vtkm::cont::Field::Association GetActiveFieldAssociation() const + void SetActiveField( + vtkm::IdComponent index, + const std::string& name, + vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) { - return this->ActiveFieldAssociation; + auto index_st = static_cast(index); + ResizeIfNeeded(index_st); + this->ActiveFieldNames[index_st] = name; + this->ActiveFieldAssociation[index_st] = association; + } + + VTKM_CONT const std::string& GetActiveFieldName(vtkm::IdComponent index = 0) const + { + VTKM_ASSERT((index >= 0) && + (index < static_cast(this->ActiveFieldNames.size()))); + return this->ActiveFieldNames[index]; + } + + VTKM_CONT vtkm::cont::Field::Association GetActiveFieldAssociation( + vtkm::IdComponent index = 0) const + { + return this->ActiveFieldAssociation[index]; + } + ///@} + + ///@{ + /// Select the coordinate system coord_idx to make active to use when processing the input + /// DataSet. This is used primarily by the Filter to select the coordinate system + /// to use as a field when \c UseCoordinateSystemAsField is true. + VTKM_CONT + void SetActiveCoordinateSystem(vtkm::Id coord_idx) + { + this->SetActiveCoordinateSystem(0, coord_idx); + } + + VTKM_CONT + void SetActiveCoordinateSystem(vtkm::IdComponent index, vtkm::Id coord_idx) + { + auto index_st = static_cast(index); + ResizeIfNeeded(index_st); + this->ActiveCoordinateSystemIndices[index_st] = coord_idx; + } + + VTKM_CONT + vtkm::Id GetActiveCoordinateSystemIndex() const + { + return this->GetActiveCoordinateSystemIndex(0); + } + + VTKM_CONT + vtkm::Id GetActiveCoordinateSystemIndex(vtkm::IdComponent index) const + { + auto index_st = static_cast(index); + return this->ActiveCoordinateSystemIndices[index_st]; } ///@} @@ -65,59 +101,203 @@ public: /// To simply use the active coordinate system as the field to operate on, set /// UseCoordinateSystemAsField to true. VTKM_CONT - void SetUseCoordinateSystemAsField(bool val) { this->UseCoordinateSystemAsField = val; } - VTKM_CONT - bool GetUseCoordinateSystemAsField() const { return this->UseCoordinateSystemAsField; } - ///@} - - - ///@{ - /// Select the coordinate system index to make active to use when processing the input - /// DataSet. This is used primarily by the Filter to select the coordinate system - /// to use as a field when \c UseCoordinateSystemAsField is true. - VTKM_CONT - void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; } + void SetUseCoordinateSystemAsField(bool val) { SetUseCoordinateSystemAsField(0, val); } VTKM_CONT - vtkm::Id GetActiveCoordinateSystemIndex() const { return this->CoordinateSystemIndex; } - ///@} + void SetUseCoordinateSystemAsField(vtkm::IdComponent index, bool val) + { + auto index_st = static_cast(index); + this->ResizeIfNeeded(index_st); + this->UseCoordinateSystemAsField[index] = val; + } - ///@{ - /// These are provided to satisfy the Filter API requirements. - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy); - - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - - template - VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, - const vtkm::cont::CoordinateSystem& field, - vtkm::filter::PolicyBase policy); + VTKM_CONT + bool GetUseCoordinateSystemAsField(vtkm::IdComponent index = 0) const + { + VTKM_ASSERT((index >= 0) && + (index < static_cast(this->ActiveFieldNames.size()))); + return this->UseCoordinateSystemAsField[index]; + } ///@} protected: - vtkm::filter::FilterField& operator=(const vtkm::filter::FilterField&) = - default; VTKM_CONT - void CopyStateFrom(const FilterField* filter) { *this = *filter; } + const vtkm::cont::Field& GetFieldFromDataSet(const vtkm::cont::DataSet& input) const + { + return this->GetFieldFromDataSet(0, input); + } + + VTKM_CONT + const vtkm::cont::Field& GetFieldFromDataSet(vtkm::IdComponent index, + const vtkm::cont::DataSet& input) const + { + if (this->UseCoordinateSystemAsField[index]) + { + // Note that we cannot use input.GetCoordinateSystem because that does not return + // a reference to a field. Instead, get the field name for the coordinate system + // and return the field. + const std::string& coordSystemName = + input.GetCoordinateSystemName(this->GetActiveCoordinateSystemIndex(index)); + return input.GetPointField(coordSystemName); + } + else + { + return input.GetField(this->GetActiveFieldName(index), + this->GetActiveFieldAssociation(index)); + } + } + + template + VTKM_CONT void CastAndCallScalarField(const vtkm::cont::UnknownArrayHandle& fieldArray, + Functor&& functor, + Args&&... args) const + { + fieldArray + .CastAndCallForTypesWithFloatFallback( + std::forward(functor), std::forward(args)...); + } + + template + VTKM_CONT void CastAndCallScalarField(const vtkm::cont::Field& field, + Functor&& functor, + Args&&... args) const + { + this->CastAndCallScalarField( + field.GetData(), std::forward(functor), std::forward(args)...); + } + private: + template + struct ScalarToVec + { + template + using type = vtkm::Vec; + }; + +protected: + template + VTKM_CONT void CastAndCallVecField(const vtkm::cont::UnknownArrayHandle& fieldArray, + Functor&& functor, + Args&&... args) const + { + using VecList = + vtkm::ListTransform::template type>; + fieldArray.CastAndCallForTypesWithFloatFallback( + std::forward(functor), std::forward(args)...); + } + + template + VTKM_CONT void CastAndCallVecField(const vtkm::cont::Field& field, + Functor&& functor, + Args&&... args) const + { + this->CastAndCallVecField( + field.GetData(), std::forward(functor), std::forward(args)...); + } + + /// \brief Create the output data set for `DoExecute` + /// + /// This form of `CreateResult` will create an output data set with the same cell + /// structure and coordinate system as the input and pass all fields (as requested + /// by the `Filter` state). Additionally, it will add the provided field to the + /// result. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultField A `Field` that is added to the returned `DataSet`. + /// + VTKM_CONT vtkm::cont::DataSet CreateResultField(const vtkm::cont::DataSet& inDataSet, + const vtkm::cont::Field& resultField) const; + + /// \brief Create the output data set for `DoExecute` + /// + /// This form of `CreateResult` will create an output data set with the same cell + /// structure and coordinate system as the input and pass all fields (as requested + /// by the `Filter` state). Additionally, it will add a field matching the provided + /// specifications to the result. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. + /// \param[in] resultFieldAssociation The association of the field (e.g. point or cell) + /// added to the returned `DataSet`. + /// \param[in] resultFieldArray An array containing the data for the field added to the + /// returned `DataSet`. + /// + VTKM_CONT vtkm::cont::DataSet CreateResultField( + const vtkm::cont::DataSet& inDataSet, + const std::string& resultFieldName, + vtkm::cont::Field::Association resultFieldAssociation, + const vtkm::cont::UnknownArrayHandle& resultFieldArray) const + { + return this->CreateResultField( + inDataSet, vtkm::cont::Field{ resultFieldName, resultFieldAssociation, resultFieldArray }); + } + + /// \brief Create the output data set for `DoExecute` + /// + /// This form of `CreateResult` will create an output data set with the same cell + /// structure and coordinate system as the input and pass all fields (as requested + /// by the `Filter` state). Additionally, it will add a point field matching the + /// provided specifications to the result. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. + /// \param[in] resultFieldArray An array containing the data for the field added to the + /// returned `DataSet`. + /// + VTKM_CONT vtkm::cont::DataSet CreateResultFieldPoint( + const vtkm::cont::DataSet& inDataSet, + const std::string& resultFieldName, + const vtkm::cont::UnknownArrayHandle& resultFieldArray) const + { + return this->CreateResultField(inDataSet, + vtkm::cont::Field{ resultFieldName, + vtkm::cont::Field::Association::Points, + resultFieldArray }); + } + + /// \brief Create the output data set for `DoExecute` + /// + /// This form of `CreateResult` will create an output data set with the same cell + /// structure and coordinate system as the input and pass all fields (as requested + /// by the `Filter` state). Additionally, it will add a cell field matching the + /// provided specifications to the result. + /// + /// \param[in] inDataSet The input data set being modified (usually the one passed + /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` + /// (as selected by the `FieldsToPass` state of the filter). + /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. + /// \param[in] resultFieldArray An array containing the data for the field added to the + /// returned `DataSet`. + /// + VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell( + const vtkm::cont::DataSet& inDataSet, + const std::string& resultFieldName, + const vtkm::cont::UnknownArrayHandle& resultFieldArray) const + { + return this->CreateResultField(inDataSet, + vtkm::cont::Field{ resultFieldName, + vtkm::cont::Field::Association::Cells, + resultFieldArray }); + } + +private: + void ResizeIfNeeded(size_t index_st); + std::string OutputFieldName; - vtkm::Id CoordinateSystemIndex; - std::string ActiveFieldName; - vtkm::cont::Field::Association ActiveFieldAssociation; - bool UseCoordinateSystemAsField; - friend class vtkm::filter::Filter; + std::vector ActiveFieldNames; + std::vector ActiveFieldAssociation; + std::vector UseCoordinateSystemAsField; + std::vector ActiveCoordinateSystemIndices; }; -VTKM_DEPRECATED_SUPPRESS_END -} -} // namespace vtkm::filter +} // namespace filter +} // namespace vtkm -#include - -#endif // vtk_m_filter_FieldFilter_h +#endif // vtk_m_filter_FilterField_h diff --git a/vtkm/filter/FilterField.hxx b/vtkm/filter/FilterField.hxx deleted file mode 100644 index a65a50bf2..000000000 --- a/vtkm/filter/FilterField.hxx +++ /dev/null @@ -1,119 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterField::FilterField() - : OutputFieldName() - , CoordinateSystemIndex(0) - , ActiveFieldName() - , ActiveFieldAssociation(vtkm::cont::Field::Association::Any) - , UseCoordinateSystemAsField(false) -{ -} - -//---------------------------------------------------------------------------- -template -inline VTKM_CONT FilterField::~FilterField() -{ -} - -//----------------------------------------------------------------------------- -template -template -VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( - const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy) -{ - if (this->UseCoordinateSystemAsField) - { - // we need to state that the field is actually a coordinate system, so that - // the filter uses the proper policy to convert the types. - return this->PrepareForExecution( - input, input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), policy); - } - else - { - return this->PrepareForExecution( - input, input.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation()), policy); - } -} - -//----------------------------------------------------------------------------- -template -template -VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( - const vtkm::cont::DataSet& input, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy) -{ - vtkm::filter::FieldMetadata metaData(field); - vtkm::cont::DataSet result; - - vtkm::cont::CastAndCall( - vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits()), - internal::ResolveFieldTypeAndExecute(), - static_cast(this), - input, - metaData, - policy, - result); - return result; -} - -//----------------------------------------------------------------------------- -template -template -VTKM_CONT vtkm::cont::DataSet FilterField::PrepareForExecution( - const vtkm::cont::DataSet& input, - const vtkm::cont::CoordinateSystem& field, - vtkm::filter::PolicyBase policy) -{ - //We have a special signature just for CoordinateSystem, so that we can ask - //the policy for the storage types and value types just for coordinate systems - vtkm::filter::FieldMetadata metaData(field); - vtkm::cont::DataSet result; - - using Traits = vtkm::filter::FilterTraits; - constexpr bool supportsVec3 = - vtkm::ListHas::value; - - using supportsCoordinateSystem = std::integral_constant; - vtkm::cont::ConditionalCastAndCall(supportsCoordinateSystem(), - field, - internal::ResolveFieldTypeAndExecute(), - static_cast(this), - input, - metaData, - policy, - result); - - return result; -} -} -} diff --git a/vtkm/filter/FilterTraits.h b/vtkm/filter/FilterTraits.h deleted file mode 100644 index c7b85428d..000000000 --- a/vtkm/filter/FilterTraits.h +++ /dev/null @@ -1,50 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_FilterTraits_h -#define vtk_m_filter_FilterTraits_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -template -class Filter; - - -template -struct VTKM_DEPRECATED(1.9) FilterTraits -{ - using InputFieldTypeList = typename Filter::SupportedTypes; - using AdditionalFieldStorage = typename Filter::AdditionalFieldStorage; -}; - -template -struct VTKM_DEPRECATED(1.9) DeduceFilterFieldTypes -{ - using PList = typename DerivedPolicy::FieldTypeList; - using TypeList = vtkm::ListIntersect; -}; - -template -struct VTKM_DEPRECATED(1.9) DeduceFilterFieldStorage -{ - using PList = typename DerivedPolicy::StorageList; - using StorageList = vtkm::ListAppend; -}; - -} -} - -#endif //vtk_m_filter_FilterTraits_h diff --git a/vtkm/filter/GenerateIds.h b/vtkm/filter/GenerateIds.h deleted file mode 100644 index 01f529968..000000000 --- a/vtkm/filter/GenerateIds.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_GenerateIds_h -#define vtk_m_filter_GenerateIds_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_transform/GenerateIds.h instead of vtkm/filter/GenerateIds.h.") -inline void GenerateIds_deprecated() {} - -inline void GenerateIds_deprecated_warning() -{ - GenerateIds_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_GenerateIds_h diff --git a/vtkm/filter/GhostCellClassify.h b/vtkm/filter/GhostCellClassify.h deleted file mode 100644 index c7b6a2336..000000000 --- a/vtkm/filter/GhostCellClassify.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_GhostCellClassify_h -#define vtk_m_filter_GhostCellClassify_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/mesh_info/GhostCellClassify.h instead of vtkm/filter/GhostCellClassify.h.") -inline void GhostCellClassify_deprecated() {} - -inline void GhostCellClassify_deprecated_warning() -{ - GhostCellClassify_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_GhostCellClassify_h diff --git a/vtkm/filter/GhostCellRemove.h b/vtkm/filter/GhostCellRemove.h deleted file mode 100644 index 4da23781a..000000000 --- a/vtkm/filter/GhostCellRemove.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_GhostCellRemove_h -#define vtk_m_filter_GhostCellRemove_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/GhostCellRemove.h instead of vtkm/filter/GhostCellRemove.h.") -inline void GhostCellRemove_deprecated() {} - -inline void GhostCellRemove_deprecated_warning() -{ - GhostCellRemove_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_GhostCellRemove_h diff --git a/vtkm/filter/Gradient.h b/vtkm/filter/Gradient.h deleted file mode 100644 index 7faf4b53b..000000000 --- a/vtkm/filter/Gradient.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Gradient_h -#define vtk_m_filter_Gradient_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/vector_analysis/Gradient.h instead of vtkm/filter/Gradient.h.") -inline void Gradient_deprecated() {} - -inline void Gradient_deprecated_warning() -{ - Gradient_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Gradient_h diff --git a/vtkm/filter/Histogram.h b/vtkm/filter/Histogram.h deleted file mode 100644 index 9f75ad9f6..000000000 --- a/vtkm/filter/Histogram.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Histogram_h -#define vtk_m_filter_Histogram_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/density_estimate/Histogram.h instead of vtkm/filter/Histogram.h.") -inline void Histogram_deprecated() {} - -inline void Histogram_deprecated_warning() -{ - Histogram_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Histogram_h diff --git a/vtkm/filter/ImageConnectivity.h b/vtkm/filter/ImageConnectivity.h deleted file mode 100644 index 2f56c087c..000000000 --- a/vtkm/filter/ImageConnectivity.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ImageConnectivity_h -#define vtk_m_filter_ImageConnectivity_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/connected_components/ImageConnectivity.h instead of " - "vtkm/filter/ImageConnectivity.h.") -inline void ImageConnectivity_deprecated() {} - -inline void ImageConnectivity_deprecated_warning() -{ - ImageConnectivity_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ImageConnectivity_h diff --git a/vtkm/filter/ImageDifference.h b/vtkm/filter/ImageDifference.h deleted file mode 100644 index 15dd2dd9a..000000000 --- a/vtkm/filter/ImageDifference.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ImageDifference_h -#define vtk_m_filter_ImageDifference_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/image_processing/ImageDifference.h instead of vtkm/filter/ImageDifference.h.") -inline void ImageDifference_deprecated() {} - -inline void ImageDifference_deprecated_warning() -{ - ImageDifference_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ImageDifference_h diff --git a/vtkm/filter/ImageMedian.h b/vtkm/filter/ImageMedian.h deleted file mode 100644 index 377c68d96..000000000 --- a/vtkm/filter/ImageMedian.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ImageMedian_h -#define vtk_m_filter_ImageMedian_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/image_processing/ImageMedian.h instead of vtkm/filter/ImageMedian.h.") -inline void ImageMedian_deprecated() {} - -inline void ImageMedian_deprecated_warning() -{ - ImageMedian_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ImageMedian_h diff --git a/vtkm/filter/Instantiations.h b/vtkm/filter/Instantiations.h deleted file mode 100644 index 27c3e42c4..000000000 --- a/vtkm/filter/Instantiations.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_Instantiations_h -#define vtk_m_filter_Instantiations_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/internal/Instantiations.h instead of vtkm/filter/Instantiations.h") -inline void Instantiations_deprecated() {} - -inline void Instantiations_deprecated_warning() -{ - Instantiations_deprecated(); -} - -} // namespace vtkm -} // namespace filter - -#endif //vtk_m_filter_Instantiations_h diff --git a/vtkm/filter/Lagrangian.h b/vtkm/filter/Lagrangian.h deleted file mode 100644 index 3ab00a305..000000000 --- a/vtkm/filter/Lagrangian.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Lagrangian_h -#define vtk_m_filter_Lagrangian_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/Lagrangian.h instead of vtkm/filter/Lagrangian.h") -inline void Lagrangian_deprecated() {} - -inline void Lagrangian_deprecated_warning() -{ - Lagrangian_deprecated(); -} - -} -} - -#endif //vtk_m_filter_Lagrangian_h diff --git a/vtkm/filter/LagrangianStructures.h b/vtkm/filter/LagrangianStructures.h deleted file mode 100644 index a423bd146..000000000 --- a/vtkm/filter/LagrangianStructures.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_LagrangianStructures_h -#define vtk_m_filter_LagrangianStructures_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/flow/LagrangianStructures.h instead of vtkm/filter/LagrangianStructures.h") -inline void LagrangianStructures_deprecated() {} - -inline void LagrangianStructures_deprecated_warning() -{ - LagrangianStructures_deprecated(); -} - -} -} - -#endif //vtk_m_filter_LagrangnianStructures_h diff --git a/vtkm/filter/MIRFilter.h b/vtkm/filter/MIRFilter.h deleted file mode 100644 index 8550d6152..000000000 --- a/vtkm/filter/MIRFilter.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_MIRFilter_h -#define vtk_m_filter_MIRFilter_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/contour/MIRFilter.h instead of vtkm/filter/MIRFilter.h.") -inline void MIRFilter_deprecated() {} - -inline void MIRFilter_deprecated_warning() -{ - MIRFilter_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_MIRFilter_h diff --git a/vtkm/filter/Mask.h b/vtkm/filter/Mask.h deleted file mode 100644 index a58c82a98..000000000 --- a/vtkm/filter/Mask.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Mask_h -#define vtk_m_filter_Mask_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/entity_extraction/Mask.h instead of vtkm/filter/Mask.h.") -inline void Mask_deprecated() {} - -inline void Mask_deprecated_warning() -{ - Mask_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Mask_h diff --git a/vtkm/filter/MaskPoints.h b/vtkm/filter/MaskPoints.h deleted file mode 100644 index 6547a3d2b..000000000 --- a/vtkm/filter/MaskPoints.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_MaskPoints_h -#define vtk_m_filter_MaskPoints_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/MaskPoints.h instead of vtkm/filter/MaskPoints.h.") -inline void MaskPoints_deprecated() {} - -inline void MaskPoints_deprecated_warning() -{ - MaskPoints_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_MaskPoints_h diff --git a/vtkm/filter/MeshQuality.h b/vtkm/filter/MeshQuality.h deleted file mode 100644 index 61ab2ffb1..000000000 --- a/vtkm/filter/MeshQuality.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_MeshQuality_h -#define vtk_m_filter_MeshQuality_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/mesh_info/MeshQuality.h instead of vtkm/filter/MeshQuality.h.") -inline void MeshQuality_deprecated() {} - -inline void MeshQuality_deprecated_warning() -{ - MeshQuality_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_MeshQuality_h diff --git a/vtkm/filter/NDEntropy.h b/vtkm/filter/NDEntropy.h deleted file mode 100644 index c54b51350..000000000 --- a/vtkm/filter/NDEntropy.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_NDEntropy_h -#define vtk_m_filter_NDEntropy_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/density_estimate/NDEntropy.h instead of vtkm/filter/NDEntropy.h.") -inline void NDEntropy_deprecated() {} - -inline void NDEntropy_deprecated_warning() -{ - NDEntropy_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_NDEntropy_h diff --git a/vtkm/filter/NDHistogram.h b/vtkm/filter/NDHistogram.h deleted file mode 100644 index 8f0e37abf..000000000 --- a/vtkm/filter/NDHistogram.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_NDHistogram_h -#define vtk_m_filter_NDHistogram_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/density_estimate/NDHistogram.h instead of vtkm/filter/NDHistogram.h.") -inline void NDHistogram_deprecated() {} - -inline void NDHistogram_deprecated_warning() -{ - NDHistogram_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_NDHistogram_h diff --git a/vtkm/filter/NewFilter.h b/vtkm/filter/NewFilter.h deleted file mode 100644 index 1b2458cda..000000000 --- a/vtkm/filter/NewFilter.h +++ /dev/null @@ -1,503 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_NewFilter_h -#define vtk_m_filter_NewFilter_h - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace vtkm -{ -namespace filter -{ -/// \brief base class for all filters. -/// -/// This is the base class for all filters. To add a new filter, one can subclass this (or any of -/// the existing subclasses e.g. FilterField, FilterParticleAdvection, etc.) and implement relevant -/// methods. -/// -/// \section FilterUsage Usage -/// -/// To execute a filter, one typically calls the `auto result = filter.Execute(input)`. Typical -/// usage is as follows: -/// -/// \code{cpp} -/// -/// // create the concrete subclass (e.g. Contour). -/// vtkm::filter::contour::Contour contour; -/// -/// // select fields to map to the output, if different from default which is to map all input -/// // fields. -/// contour.SetFieldToPass({"var1", "var2"}); -/// -/// // execute the filter on vtkm::cont::DataSet. -/// vtkm::cont::DataSet dsInput = ... -/// auto outputDS = contour.Execute(dsInput); -/// -/// // or, execute on a vtkm::cont::PartitionedDataSet -/// vtkm::cont::PartitionedDataSet mbInput = ... -/// auto outputMB = contour.Execute(mbInput); -/// \endcode -/// -/// `Execute` methods take in the input DataSet or PartitionedDataSet to process and return the -/// result. The type of the result is same as the input type, thus `Execute(DataSet&)` returns -/// a DataSet while `Execute(PartitionedDataSet&)` returns a PartitionedDataSet. -/// -/// `Execute` simply calls the pure virtual function `DoExecute(DataSet&)` which is the main -/// extension point of the Filter interface. Filter developer needs to override -/// `DoExecute(DataSet)` to implement the business logic of filtering operations on a single -/// DataSet. -/// -/// The default implementation of `Execute(PartitionedDataSet&)` is merely provided for -/// convenience. Internally, it calls `DoExecutePartitions(PartitionedDataSet)` to iterate DataSets -/// of a PartitionedDataSet and pass each individual DataSets to `DoExecute(DataSet&)`, -/// possibly in a multi-threaded setting. Developer of `DoExecute(DataSet&)` needs to indicate -/// the thread-safeness of `DoExecute(DataSet&)` by overriding the `CanThread()` virtual method -/// which by default returns `true`. -/// -/// In the case that filtering on a PartitionedDataSet can not be simply implemented as a -/// for-each loop on the component DataSets, filter implementor needs to override the -/// `DoExecutePartitions(PartitionedDataSet&)`. See the implementation of -/// `FilterParticleAdvection::Execute(PartitionedDataSet&)` for an example. -/// -/// \section FilterSubclassing Subclassing -/// -/// In many uses cases, one subclasses one of the immediate subclasses of this class such as -/// FilterField, FilterParticleAdvection, etc. Those may impose additional constraints on the -/// methods to implement in the subclasses. Here, we describes the things to consider when directly -/// subclassing vtkm::filter::NewFilter. -/// -/// \subsection FilterExecution Execute -/// -/// A concrete subclass of Filter must provide `DoExecute` implementation that provides the meat -/// for the filter i.e. the implementation for the filter's data processing logic. There are two -/// signatures available; which one to implement depends on the nature of the filter. -/// -/// Let's consider simple filters that do not need to do anything special to handle -/// PartitionedDataSet e.g. clip, contour, etc. These are the filters where executing the filter -/// on a PartitionedDataSet simply means executing the filter on one partition at a time and -/// packing the output for each iteration info the result PartitionedDataSet. For such filters, -/// one must implement the following signature. -/// -/// \code{cpp} -/// -/// vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input); -/// -/// \endcode -/// -/// The role of this method is to execute on the input dataset and generate the result and return -/// it. If there are any errors, the subclass must throw an exception -/// (e.g. `vtkm::cont::ErrorFilterExecution`). -/// -/// In this simple case, the NewFilter superclass handles iterating over multiple partitions in the -/// input PartitionedDataSet and calling `DoExecute(DataSet&)` iteratively. -/// -/// The aforementioned approach is also suitable for filters that need special handling for -/// PartitionedDataSets that requires certain cross DataSet operations (usually scatter/gather -/// and reduction on DataSets) before and/or after the per DataSet operation. This can be done by -/// overriding `DoExecutePartitions(PartitionedDataSet&)` while calling to the base class -/// `DoExecutePartitions(PartitionedDataSet&) as helper function for iteration on DataSets. -/// -/// \code{cpp} -/// vtkm::cont::PartitionedDataSet FooFilter::DoExecutePartitions( -/// const vtkm::cont::PartitionedDataSet& input) -/// { -/// // Do pre execute stuff, e.g. scattering to each DataSet -/// auto output = this->NewFilter::DoExecutePartitions(input); -/// // Do post execute stuff, e.g gather/reduce from DataSets -/// return output; -/// } -/// \endcode -/// -/// For more complex filters, like streamlines, particle tracking, where the processing of -/// PartitionedDataSets cannot be modelled as mapping and reduction operation on DataSet, one -/// needs fully implement `DoExecutePartitions(PartitionedDataSet&)`. Now the subclass is given -/// full control over the execution, including any mapping of fields to output (described in next -/// sub-section). -/// -/// \subsection Creating results and mapping fields -/// -/// For subclasses that map input fields into output fields, the implementation of its -/// `DoExecute(DataSet&)` should create the `DataSet` to be returned with a call to -/// `NewFilter::CreateResult` or a similar method in a subclass (such as -/// `NewFilterField::CreateResultField`). -/// -/// \code{cpp} -/// VTKM_CONT DataSet SomeFilter::DoExecute(const vtkm::cont::DataSet& input) -/// { -/// vtkm::cont::UnknownCellSet outCellSet; -/// outCellSet = ... // Generation of the new CellSet -/// -/// // Mapper is a callable object (function object, lambda, etc.) that takes an input Field -/// // and maps it to an output Field and then add the output Field to the output DataSet -/// auto mapper = [](auto& outputDs, const auto& inputField) { -/// auto outputField = ... // Business logic for mapping input field to output field -/// output.AddField(outputField); -/// }; -/// // This passes coordinate systems directly from input to output. If the points of -/// // the cell set change at all, they will have to be mapped by hand. -/// return this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper); -/// } -/// \endcode -/// -/// In addition to creating a new `DataSet` filled with the proper cell structure and coordinate -/// systems, `CreateResult` iterates through each `FieldToPass` in the input DataSet and calls the -/// FieldMapper to map the input Field to output Field. For simple filters that just pass on input -/// fields to the output DataSet without any computation, an overload of -/// `CreateResult(const vtkm::cont::DataSet& input)` is also -/// provided as a convenience that uses the default mapper which trivially adds input Field to -/// output DataSet (via a shallow copy). -/// -/// \subsection FilterThreadSafety CanThread -/// -/// By default, the implementation of `DoExecute(DataSet&)` should model a *pure function*, i.e. it -/// does not have any mutable shared state. This makes it thread-safe by default and allows -/// the default implementation of `DoExecutePartitions(PartitionedDataSet&)` to be simply a parallel -/// for-each, thus facilitates multi-threaded execution without any lock. -/// -/// Many legacy (VTKm 1.x) filter implementations needed to store states between the mesh generation -/// phase and field mapping phase of filter execution, for example, parameters for field -/// interpolation. The shared mutable states were mostly stored as mutable data members of the -/// filter class (either in terms of ArrayHandle or some kind of Worket). The new filter interface, -/// by combining the two phases into a single call to `DoExecute(DataSet&)`, we have eliminated most -/// of the cases that require such shared mutable states. New implementations of filters that -/// require passing information between these two phases can now use local variables within the -/// `DoExecute(DataSet&)`. For example: -/// -/// \code{cpp} -/// struct SharedState; // shared states between mesh generation and field mapping. -/// VTKM_CONT DataSet ThreadSafeFilter::DoExecute(const vtkm::cont::DataSet& input) -/// { -/// // Mutable states that was a data member of the filter is now a local variable. -/// // Each invocation of Execute(DataSet) in the multi-threaded execution of -/// // Execute(PartitionedDataSet&) will have a copy of `states` on each thread's stack -/// // thus making it thread-safe. -/// SharedStates states; -/// -/// vtkm::cont::DataSet output; -/// output = ... // Generation of the new DataSet and store interpolation parameters in `states` -/// -/// // Lambda capture of `states`, effectively passing the shared states to the Mapper. -/// auto mapper = [&states](auto& outputDs, const auto& inputField) { -/// auto outputField = ... // Use `states` for mapping input field to output field -/// output.AddField(outputField); -/// }; -/// this->MapFieldsOntoOutput(input, output, mapper); -/// -/// return output; -/// } -/// \endcode -/// -/// In the rare cases that filter implementation can not be made thread-safe, the implementation -/// needs to override the `CanThread()` virtual method to return `false`. The default -/// `Execute(PartitionedDataSet&)` implementation will fallback to a serial for loop execution. -/// -/// \subsection FilterThreadScheduling DoExecute -/// The default multi-threaded execution of `Execute(PartitionedDataSet&)` uses a simple FIFO queue -/// of DataSet and pool of *worker* threads. Implementation of Filter subclass can override the -/// `DoExecutePartitions(PartitionedDataSet)` virtual method to provide implementation specific -/// scheduling policy. The default number of *worker* threads in the pool are determined by the -/// `DetermineNumberOfThreads()` virtual method using several backend dependent heuristic. -/// Implementations of Filter subclass can also override -/// `DetermineNumberOfThreads()` to provide implementation specific heuristic. -/// -class VTKM_FILTER_CORE_EXPORT NewFilter -{ -public: - VTKM_CONT - virtual ~NewFilter(); - - VTKM_CONT - virtual bool CanThread() const; - - VTKM_CONT - void SetThreadsPerCPU(vtkm::Id numThreads) { this->NumThreadsPerCPU = numThreads; } - VTKM_CONT - void SetThreadsPerGPU(vtkm::Id numThreads) { this->NumThreadsPerGPU = numThreads; } - - VTKM_CONT - vtkm::Id GetThreadsPerCPU() const { return this->NumThreadsPerCPU; } - VTKM_CONT - vtkm::Id GetThreadsPerGPU() const { return this->NumThreadsPerGPU; } - - VTKM_CONT - bool GetRunMultiThreadedFilter() const - { - return this->CanThread() && this->RunFilterWithMultipleThreads; - } - - VTKM_CONT - void SetRunMultiThreadedFilter(bool val) - { - if (this->CanThread()) - this->RunFilterWithMultipleThreads = val; - else - { - std::string msg = - "Multi threaded filter not supported for " + std::string(typeid(*this).name()); - VTKM_LOG_S(vtkm::cont::LogLevel::Info, msg); - } - } - - ///@{ - /// \brief Specify which fields get passed from input to output. - /// - /// After a filter successfully executes and returns a new data set, fields are mapped from - /// input to output. Depending on what operation the filter does, this could be a simple shallow - /// copy of an array, or it could be a computed operation. You can control which fields are - /// passed (and equivalently which are not) with this parameter. - /// - /// By default, all fields are passed during execution. - /// - VTKM_CONT - void SetFieldsToPass(const vtkm::filter::FieldSelection& fieldsToPass) - { - this->FieldsToPass = fieldsToPass; - } - - VTKM_CONT - void SetFieldsToPass(const vtkm::filter::FieldSelection& fieldsToPass, - vtkm::filter::FieldSelection::Mode mode) - { - this->FieldsToPass = fieldsToPass; - this->FieldsToPass.SetMode(mode); - } - - VTKM_CONT - void SetFieldsToPass( - const std::string& fieldname, - vtkm::cont::Field::Association association, - vtkm::filter::FieldSelection::Mode mode = vtkm::filter::FieldSelection::Mode::Select) - { - this->SetFieldsToPass({ fieldname, association }, mode); - } - - VTKM_CONT - const vtkm::filter::FieldSelection& GetFieldsToPass() const { return this->FieldsToPass; } - VTKM_CONT - vtkm::filter::FieldSelection& GetFieldsToPass() { return this->FieldsToPass; } - ///@} - - ///@{ - /// Executes the filter on the input and produces a result dataset. - /// - /// On success, this the dataset produced. On error, vtkm::cont::ErrorExecution will be thrown. - VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input); - ///@} - - ///@{ - /// Executes the filter on the input PartitionedDataSet and produces a result PartitionedDataSet. - /// - /// On success, this the dataset produced. On error, vtkm::cont::ErrorExecution will be thrown. - VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input); - ///@} - - // FIXME: Is this actually materialize? Are there different kinds of Invoker? - /// Specify the vtkm::cont::Invoker to be used to execute worklets by - /// this filter instance. Overriding the default allows callers to control - /// which device adapters a filter uses. - void SetInvoker(vtkm::cont::Invoker inv) { this->Invoke = inv; } - -protected: - vtkm::cont::Invoker Invoke; - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output data set with the same cell - /// structure and coordinate system as the input and pass all fields (as requested - /// by the `Filter` state). - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed into - /// `DoExecute`). The returned `DataSet` is filled with the cell set, coordinate system, and - /// fields of `inDataSet` (as selected by the `FieldsToPass` state of the filter). - /// - VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet) const; - - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output PartitionedDataSet with the - /// same partitions and pass all PartitionedDataSet fields (as requested by the - /// `Filter` state). - /// - /// \param[in] input The input data set being modified (usually the one passed into - /// `DoExecute`). - /// \param[in] resultPartitions The output data created by the filter. Fields from the input are - /// passed onto the return result partition as requested by the `Filter` state. - /// - VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult( - const vtkm::cont::PartitionedDataSet& input, - const vtkm::cont::PartitionedDataSet& resultPartitions) const; - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output PartitionedDataSet with the - /// same partitions and pass all PartitionedDataSet fields (as requested by the - /// `Filter` state). - /// - /// \param[in] input The input data set being modified (usually the one passed into - /// `DoExecute`). - /// \param[in] resultPartitions The output data created by the filter. Fields from the input are - /// passed onto the return result partition as requested by the `Filter` state. - /// \param[in] fieldMapper A function or functor that takes a `PartitionedDataSet` as its first - /// argument and a `Field` as its second argument. The `PartitionedDataSet` is the data being - /// created and will eventually be returned by `CreateResult`. The `Field` comes from `input`. - /// - - template - VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult( - const vtkm::cont::PartitionedDataSet& input, - const vtkm::cont::PartitionedDataSet& resultPartitions, - FieldMapper&& fieldMapper) const - { - vtkm::cont::PartitionedDataSet output(resultPartitions.GetPartitions()); - this->MapFieldsOntoOutput(input, output, fieldMapper); - return output; - } - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output data set with the given `CellSet`. You must - /// also provide a field mapper function, which is a function that takes the output `DataSet` - /// being created and a `Field` from the input and then applies any necessary transformations to - /// the field array and adds it to the `DataSet`. - /// - /// This form of `CreateResult` returns a `DataSet` with _no_ coordinate systems. The calling - /// program must add any necessary `CoordinateSystem`s. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultCellSet The `CellSet` of the output will be set to this. - /// \param[in] fieldMapper A function or functor that takes a `DataSet` as its first - /// argument and a `Field` as its second argument. The `DataSet` is the data being - /// created and will eventually be returned by `CreateResult`. The `Field` comes from - /// `inDataSet`. The function should map the `Field` to match `resultCellSet` and then - /// add the resulting field to the `DataSet`. If the mapping is not possible, then - /// the function should do nothing. - /// - template - VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownCellSet& resultCellSet, - FieldMapper&& fieldMapper) const - { - vtkm::cont::DataSet outDataSet; - outDataSet.SetCellSet(resultCellSet); - this->MapFieldsOntoOutput(inDataSet, outDataSet, fieldMapper); - return outDataSet; - } - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output data set with the given `CellSet` - /// and set of `CoordinateSystem`s. You must also provide a field mapper function, which - /// is a function that takes the output `DataSet` being created and a `Field` from the - /// input and then applies any necessary transformations to the field array and adds it - /// to the `DataSet`. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultCellSet The `CellSet` of the output will be set to this. - /// \param[in] resultCoordSystems These `CoordinateSystem`s will be added to the output. - /// \param[in] fieldMapper A function or functor that takes a `DataSet` as its first - /// argument and a `Field` as its second argument. The `DataSet` is the data being - /// created and will eventually be returned by `CreateResult`. The `Field` comes from - /// `inDataSet`. The function should map the `Field` to match `resultCellSet` and then - /// add the resulting field to the `DataSet`. If the mapping is not possible, then - /// the function should do nothing. - /// - template - VTKM_CONT vtkm::cont::DataSet CreateResult( - const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownCellSet& resultCellSet, - const std::vector& resultCoordSystems, - FieldMapper&& fieldMapper) const - { - vtkm::cont::DataSet outDataSet = this->CreateResult(inDataSet, resultCellSet, fieldMapper); - for (auto&& cs : resultCoordSystems) - { - outDataSet.AddCoordinateSystem(cs); - } - return outDataSet; - } - - /// \brief Create the output data set for `DoExecute`. - /// - /// This form of `CreateResult` will create an output data set with the given `CellSet` - /// and `CoordinateSystem`. You must also provide a field mapper function, which is a - /// function that takes the output `DataSet` being created and a `Field` from the input - /// and then applies any necessary transformations to the field array and adds it to - /// the `DataSet`. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultCellSet The `CellSet` of the output will be set to this. - /// \param[in] resultCoordSystem This `CoordinateSystem` will be added to the output. - /// \param[in] fieldMapper A function or functor that takes a `DataSet` as its first - /// argument and a `Field` as its second argument. The `DataSet` is the data being - /// created and will eventually be returned by `CreateResult`. The `Field` comes from - /// `inDataSet`. The function should map the `Field` to match `resultCellSet` and then - /// add the resulting field to the `DataSet`. If the mapping is not possible, then - /// the function should do nothing. - /// - template - VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::UnknownCellSet& resultCellSet, - const vtkm::cont::CoordinateSystem& resultCoordSystem, - FieldMapper&& fieldMapper) const - { - return this->CreateResult(inDataSet, - resultCellSet, - std::vector{ resultCoordSystem }, - fieldMapper); - } - - VTKM_CONT virtual vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) = 0; - VTKM_CONT virtual vtkm::cont::PartitionedDataSet DoExecutePartitions( - const vtkm::cont::PartitionedDataSet& inData); - -private: - template - VTKM_CONT void MapFieldsOntoOutput(const DataSetType& input, - DataSetType& output, - FieldMapper&& fieldMapper) const - { - for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc) - { - auto field = input.GetField(cc); - if (this->GetFieldsToPass().IsFieldSelected(field)) - { - fieldMapper(output, field); - } - } - } - - VTKM_CONT - virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input); - - - vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All; - bool RunFilterWithMultipleThreads = false; - vtkm::Id NumThreadsPerCPU = 4; - vtkm::Id NumThreadsPerGPU = 8; -}; -} -} // namespace vtkm::filter - -#endif diff --git a/vtkm/filter/NewFilterField.h b/vtkm/filter/NewFilterField.h deleted file mode 100644 index 0c5f8ba9c..000000000 --- a/vtkm/filter/NewFilterField.h +++ /dev/null @@ -1,298 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_NewFilterField_h -#define vtk_m_filter_NewFilterField_h - -#include - -namespace vtkm -{ -namespace filter -{ - -class VTKM_FILTER_CORE_EXPORT NewFilterField : public vtkm::filter::NewFilter -{ -public: - NewFilterField() { this->SetActiveCoordinateSystem(0); } - - VTKM_CONT - void SetOutputFieldName(const std::string& name) { this->OutputFieldName = name; } - - VTKM_CONT - const std::string& GetOutputFieldName() const { return this->OutputFieldName; } - - ///@{ - /// Choose the field to operate on. Note, if - /// `this->UseCoordinateSystemAsField` is true, then the active field is not used. - VTKM_CONT - void SetActiveField( - const std::string& name, - vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) - { - this->SetActiveField(0, name, association); - } - - void SetActiveField( - vtkm::IdComponent index, - const std::string& name, - vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) - { - auto index_st = static_cast(index); - ResizeIfNeeded(index_st); - this->ActiveFieldNames[index_st] = name; - this->ActiveFieldAssociation[index_st] = association; - } - - VTKM_CONT const std::string& GetActiveFieldName(vtkm::IdComponent index = 0) const - { - VTKM_ASSERT((index >= 0) && - (index < static_cast(this->ActiveFieldNames.size()))); - return this->ActiveFieldNames[index]; - } - - VTKM_CONT vtkm::cont::Field::Association GetActiveFieldAssociation( - vtkm::IdComponent index = 0) const - { - return this->ActiveFieldAssociation[index]; - } - ///@} - - ///@{ - /// Select the coordinate system coord_idx to make active to use when processing the input - /// DataSet. This is used primarily by the Filter to select the coordinate system - /// to use as a field when \c UseCoordinateSystemAsField is true. - VTKM_CONT - void SetActiveCoordinateSystem(vtkm::Id coord_idx) - { - this->SetActiveCoordinateSystem(0, coord_idx); - } - - VTKM_CONT - void SetActiveCoordinateSystem(vtkm::IdComponent index, vtkm::Id coord_idx) - { - auto index_st = static_cast(index); - ResizeIfNeeded(index_st); - this->ActiveCoordinateSystemIndices[index_st] = coord_idx; - } - - VTKM_CONT - vtkm::Id GetActiveCoordinateSystemIndex() const - { - return this->GetActiveCoordinateSystemIndex(0); - } - - VTKM_CONT - vtkm::Id GetActiveCoordinateSystemIndex(vtkm::IdComponent index) const - { - auto index_st = static_cast(index); - return this->ActiveCoordinateSystemIndices[index_st]; - } - ///@} - - ///@{ - /// To simply use the active coordinate system as the field to operate on, set - /// UseCoordinateSystemAsField to true. - VTKM_CONT - void SetUseCoordinateSystemAsField(bool val) { SetUseCoordinateSystemAsField(0, val); } - - VTKM_CONT - void SetUseCoordinateSystemAsField(vtkm::IdComponent index, bool val) - { - auto index_st = static_cast(index); - this->ResizeIfNeeded(index_st); - this->UseCoordinateSystemAsField[index] = val; - } - - VTKM_CONT - bool GetUseCoordinateSystemAsField(vtkm::IdComponent index = 0) const - { - VTKM_ASSERT((index >= 0) && - (index < static_cast(this->ActiveFieldNames.size()))); - return this->UseCoordinateSystemAsField[index]; - } - ///@} - -protected: - VTKM_CONT - const vtkm::cont::Field& GetFieldFromDataSet(const vtkm::cont::DataSet& input) const - { - return this->GetFieldFromDataSet(0, input); - } - - VTKM_CONT - const vtkm::cont::Field& GetFieldFromDataSet(vtkm::IdComponent index, - const vtkm::cont::DataSet& input) const - { - if (this->UseCoordinateSystemAsField[index]) - { - return input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex(index)); - } - else - { - return input.GetField(this->GetActiveFieldName(index), - this->GetActiveFieldAssociation(index)); - } - } - - template - VTKM_CONT void CastAndCallScalarField(const vtkm::cont::UnknownArrayHandle& fieldArray, - Functor&& functor, - Args&&... args) const - { - fieldArray - .CastAndCallForTypesWithFloatFallback( - std::forward(functor), std::forward(args)...); - } - - template - VTKM_CONT void CastAndCallScalarField(const vtkm::cont::Field& field, - Functor&& functor, - Args&&... args) const - { - this->CastAndCallScalarField( - field.GetData(), std::forward(functor), std::forward(args)...); - } - - -private: - template - struct ScalarToVec - { - template - using type = vtkm::Vec; - }; - -protected: - template - VTKM_CONT void CastAndCallVecField(const vtkm::cont::UnknownArrayHandle& fieldArray, - Functor&& functor, - Args&&... args) const - { - using VecList = - vtkm::ListTransform::template type>; - fieldArray.CastAndCallForTypesWithFloatFallback( - std::forward(functor), std::forward(args)...); - } - - template - VTKM_CONT void CastAndCallVecField(const vtkm::cont::Field& field, - Functor&& functor, - Args&&... args) const - { - this->CastAndCallVecField( - field.GetData(), std::forward(functor), std::forward(args)...); - } - - /// \brief Create the output data set for `DoExecute` - /// - /// This form of `CreateResult` will create an output data set with the same cell - /// structure and coordinate system as the input and pass all fields (as requested - /// by the `Filter` state). Additionally, it will add the provided field to the - /// result. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultField A `Field` that is added to the returned `DataSet`. - /// - VTKM_CONT vtkm::cont::DataSet CreateResultField(const vtkm::cont::DataSet& inDataSet, - const vtkm::cont::Field& resultField) const; - - /// \brief Create the output data set for `DoExecute` - /// - /// This form of `CreateResult` will create an output data set with the same cell - /// structure and coordinate system as the input and pass all fields (as requested - /// by the `Filter` state). Additionally, it will add a field matching the provided - /// specifications to the result. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. - /// \param[in] resultFieldAssociation The association of the field (e.g. point or cell) - /// added to the returned `DataSet`. - /// \param[in] resultFieldArray An array containing the data for the field added to the - /// returned `DataSet`. - /// - VTKM_CONT vtkm::cont::DataSet CreateResultField( - const vtkm::cont::DataSet& inDataSet, - const std::string& resultFieldName, - vtkm::cont::Field::Association resultFieldAssociation, - const vtkm::cont::UnknownArrayHandle& resultFieldArray) const - { - return this->CreateResultField( - inDataSet, vtkm::cont::Field{ resultFieldName, resultFieldAssociation, resultFieldArray }); - } - - /// \brief Create the output data set for `DoExecute` - /// - /// This form of `CreateResult` will create an output data set with the same cell - /// structure and coordinate system as the input and pass all fields (as requested - /// by the `Filter` state). Additionally, it will add a point field matching the - /// provided specifications to the result. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. - /// \param[in] resultFieldArray An array containing the data for the field added to the - /// returned `DataSet`. - /// - VTKM_CONT vtkm::cont::DataSet CreateResultFieldPoint( - const vtkm::cont::DataSet& inDataSet, - const std::string& resultFieldName, - const vtkm::cont::UnknownArrayHandle& resultFieldArray) const - { - return this->CreateResultField(inDataSet, - vtkm::cont::Field{ resultFieldName, - vtkm::cont::Field::Association::Points, - resultFieldArray }); - } - - /// \brief Create the output data set for `DoExecute` - /// - /// This form of `CreateResult` will create an output data set with the same cell - /// structure and coordinate system as the input and pass all fields (as requested - /// by the `Filter` state). Additionally, it will add a cell field matching the - /// provided specifications to the result. - /// - /// \param[in] inDataSet The input data set being modified (usually the one passed - /// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet` - /// (as selected by the `FieldsToPass` state of the filter). - /// \param[in] resultFieldName The name of the field added to the returned `DataSet`. - /// \param[in] resultFieldArray An array containing the data for the field added to the - /// returned `DataSet`. - /// - VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell( - const vtkm::cont::DataSet& inDataSet, - const std::string& resultFieldName, - const vtkm::cont::UnknownArrayHandle& resultFieldArray) const - { - return this->CreateResultField(inDataSet, - vtkm::cont::Field{ resultFieldName, - vtkm::cont::Field::Association::Cells, - resultFieldArray }); - } - -private: - void ResizeIfNeeded(size_t index_st); - - std::string OutputFieldName; - - std::vector ActiveFieldNames; - std::vector ActiveFieldAssociation; - std::vector UseCoordinateSystemAsField; - std::vector ActiveCoordinateSystemIndices; -}; -} // namespace filter -} // namespace vtkm - -#endif // vtk_m_filter_NewFilterField_h diff --git a/vtkm/filter/ParticleAdvection.h b/vtkm/filter/ParticleAdvection.h deleted file mode 100644 index b395c0f91..000000000 --- a/vtkm/filter/ParticleAdvection.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ParticleAdvection_h -#define vtk_m_filter_ParticleAdvection_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/flow/ParticleAdvection.h instead of vtkm/filter/ParticleAdvection.h") -inline void ParticleAdvection_deprecated() {} - -inline void ParticleAdvection_deprecated_warning() -{ - ParticleAdvection_deprecated(); -} - -} -} - -#endif //vtk_m_filter_ParticleAdvection_h diff --git a/vtkm/filter/ParticleDensityCloudInCell.h b/vtkm/filter/ParticleDensityCloudInCell.h deleted file mode 100644 index 01aa90829..000000000 --- a/vtkm/filter/ParticleDensityCloudInCell.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ParticleDensityCloudInCell_h -#define vtk_m_filter_ParticleDensityCloudInCell_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/density_estimate/ParticleDensityCloudInCell.h instead of " - "vtkm/filter/ParticleDensityCloudInCell.h.") -inline void ParticleDensityCloudInCell_deprecated() {} - -inline void ParticleDensityCloudInCell_deprecated_warning() -{ - ParticleDensityCloudInCell_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ParticleDensityCloudInCell_h diff --git a/vtkm/filter/ParticleDensityNearestGridPoint.h b/vtkm/filter/ParticleDensityNearestGridPoint.h deleted file mode 100644 index cec7c7e44..000000000 --- a/vtkm/filter/ParticleDensityNearestGridPoint.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ParticleDensityNearestGridPoint_h -#define vtk_m_filter_ParticleDensityNearestGridPoint_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.h instead of " - "vtkm/filter/ParticleDensityNearestGridPoint.h.") -inline void ParticleDensityNearestGridPoint_deprecated() {} - -inline void ParticleDensityNearestGridPoint_deprecated_warning() -{ - ParticleDensityNearestGridPoint_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ParticleDensityNearestGridPoint_h diff --git a/vtkm/filter/PathParticle.h b/vtkm/filter/PathParticle.h deleted file mode 100644 index 064948881..000000000 --- a/vtkm/filter/PathParticle.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_PathParticle_h -#define vtk_m_filter_PathParticle_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/PathParticle.h instead of vtkm/filter/PathParticle.h") -inline void PathParticle_deprecated() {} - -inline void PathParticle_deprecated_warning() -{ - PathParticle_deprecated(); -} - -} -} - -#endif //vtk_m_filter_PathParticle_h diff --git a/vtkm/filter/Pathline.h b/vtkm/filter/Pathline.h deleted file mode 100644 index 03c5df89b..000000000 --- a/vtkm/filter/Pathline.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Pathline_h -#define vtk_m_filter_Pathline_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/Pathline.h instead of vtkm/filter/Pathline.h") -inline void Pathline_deprecated() {} - -inline void Pathline_deprecated_warning() -{ - Pathline_deprecated(); -} - -} -} - -#endif //vtk_m_filter_Pathline_h diff --git a/vtkm/filter/PointAverage.h b/vtkm/filter/PointAverage.h deleted file mode 100644 index 874782c0c..000000000 --- a/vtkm/filter/PointAverage.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_PointAverage_h -#define vtk_m_filter_PointAverage_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_conversion/PointAverage.h instead of vtkm/filter/PointAverage.h.") -inline void PointAverage_deprecated() {} - -inline void PointAverage_deprecated_warning() -{ - PointAverage_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_PointAverage_h diff --git a/vtkm/filter/PointElevation.h b/vtkm/filter/PointElevation.h deleted file mode 100644 index b11b1a928..000000000 --- a/vtkm/filter/PointElevation.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_PointElevation_h -#define vtk_m_filter_PointElevation_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_transform/PointElevation.h instead of vtkm/filter/PointElevation.h.") -inline void PointElevation_deprecated() {} - -inline void PointElevation_deprecated_warning() -{ - PointElevation_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_PointElevation_h diff --git a/vtkm/filter/PointTransform.h b/vtkm/filter/PointTransform.h deleted file mode 100644 index 5cb5c5a69..000000000 --- a/vtkm/filter/PointTransform.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_PointTransform_h -#define vtk_m_filter_PointTransform_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/field_transform/PointTransform.h instead of vtkm/filter/PointTransform.h.") -inline void PointTransform_deprecated() {} - -inline void PointTransform_deprecated_warning() -{ - PointTransform_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_PointTransform_h diff --git a/vtkm/filter/PolicyBase.h b/vtkm/filter/PolicyBase.h deleted file mode 100644 index 2b3b539f6..000000000 --- a/vtkm/filter/PolicyBase.h +++ /dev/null @@ -1,486 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_PolicyBase_h -#define vtk_m_filter_PolicyBase_h - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace vtkm -{ -namespace filter -{ - -template -struct VTKM_DEPRECATED(1.9) PolicyBase -{ - using FieldTypeList = vtkm::ListUniversal; - using StorageList = VTKM_DEFAULT_STORAGE_LIST; - - using StructuredCellSetList = VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED; - using UnstructuredCellSetList = VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED; - using AllCellSetList = VTKM_DEFAULT_CELL_SET_LIST; -}; - -namespace internal -{ - -namespace detail -{ - -// Given a base type, forms a list of all types with the same Vec structure but with the -// base component replaced with each of the basic C types. -template -struct AllCastingTypes -{ - using VTraits = vtkm::VecTraits; - - using type = vtkm::List, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType, - typename VTraits::template ReplaceBaseComponentType>; -}; - -// Provides a transform template that builds a cast from an array of some source type to a -// cast array to a specific target type. -template -struct CastArrayTransform -{ - template - using Transform = vtkm::cont::ArrayHandleCast>; -}; - -// Provides a predicate for a particular storage that resolves to std::true_type if a given -// type cannot be used with the storage. -template -struct ArrayValidPredicate -{ - template - using Predicate = vtkm::cont::internal::IsInvalidArrayHandle; -}; - -template -struct AllCastArraysForStorageImpl; - -template -struct ValidCastingTypes -{ - using type = vtkm::ListRemoveIf::type, - ArrayValidPredicate::template Predicate>; -}; - -template -struct AllCastArraysForStorageImpl -{ - using SourceTypes = typename ValidCastingTypes::type; - using CastArrays = - vtkm::ListTransform::template Transform>; - using type = vtkm::ListAppend>, CastArrays>; -}; - -template -struct AllCastArraysForStorageImpl -{ - using SourceTypes = typename ValidCastingTypes::type; - using type = - vtkm::ListTransform::template Transform>; -}; - -// Special cases for known storage with limited type support. -template <> -struct AllCastArraysForStorageImpl -{ - using type = vtkm::List; -}; -template -struct AllCastArraysForStorageImpl, - vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag, - false> -{ - using type = vtkm::List, - vtkm::cont::ArrayHandle>>; -}; -template -struct AllCastArraysForStorageImpl -{ - using type = vtkm::ListEmpty; -}; - -template -struct AllCastArraysForStorageImpl, - vtkm::cont::StorageTagCartesianProduct, - true> -{ - using type = vtkm::List, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle>>; -}; -template -struct AllCastArraysForStorageImpl, - false> -{ - using type = vtkm::ListEmpty; -}; - -#ifdef VTKM_ADD_XGC_DEFAULT_TYPES -template -struct AllCastArraysForStorageImpl, vtkm::cont::StorageTagXGCCoordinates, true> -{ - using type = vtkm::List>; -}; -template -struct AllCastArraysForStorageImpl -{ - using type = vtkm::ListEmpty; -}; -#endif - -// Given a target type and storage of an array handle, provides a list this array handle plus all -// array handles that can be cast to the target type wrapped in an ArrayHandleCast that does so. -template -struct AllCastArraysForStorage -{ - using type = typename AllCastArraysForStorageImpl< - TargetT, - Storage, - vtkm::cont::internal::IsValidArrayHandle::value>::type; -}; - -// Provides a transform template that converts a storage type to a list of all arrays that come -// from that storage type and can be cast to a target type (wrapped in an ArrayHandleCast as -// appropriate). -template -struct AllCastArraysTransform -{ - template - using Transform = typename AllCastArraysForStorage::type; -}; - -// Given a target type and a list of storage types, provides a joined list of all possible arrays -// of any of these storage cast to the target type. -template -struct AllCastArraysForStorageList -{ - VTKM_IS_LIST(StorageList); - using listOfLists = - vtkm::ListTransform::template Transform>; - using type = vtkm::ListApply; -}; - -} // detail - -template -using ArrayHandleMultiplexerForStorageList = vtkm::cont::ArrayHandleMultiplexerFromList< - typename detail::AllCastArraysForStorageList::type>; - -} // namespace internal - -//----------------------------------------------------------------------------- -/// \brief Get an array from a `Field` that is not the active field. -/// -/// Use this form for getting a `Field` when you don't know the type and it is not -/// (necessarily) the "active" field of the filter. It is generally used for arrays -/// passed to the `DoMapField` method of filters. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::UncertainArrayHandle< - typename std::conditional< - std::is_same::value, - VTKM_DEFAULT_TYPE_LIST, - typename DerivedPolicy::FieldTypeList>::type, - typename DerivedPolicy::StorageList> ApplyPolicyFieldNotActive(const vtkm::cont::Field& field, - vtkm::filter::PolicyBase< - DerivedPolicy>) -{ - // Policies are on their way out, but until they are we want to respect them. In the mean - // time, respect the policy if it is defined. - using TypeList = typename std::conditional< - std::is_same::value, - VTKM_DEFAULT_TYPE_LIST, - typename DerivedPolicy::FieldTypeList>::type; - return field.GetData().ResetTypes(TypeList{}, typename DerivedPolicy::StorageList{}); -} - -//----------------------------------------------------------------------------- -/// \brief Get an `ArrayHandle` of a specific type from a `Field`. -/// -/// Use this form of `ApplyPolicy` when you know what the value type of a field is or -/// (more likely) there is a type you are going to cast it to anyway. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT internal::ArrayHandleMultiplexerForStorageList< - T, - vtkm::ListAppend::AdditionalFieldStorage, - typename DerivedPolicy:: - StorageList>> ApplyPolicyFieldOfType(const vtkm::cont::Field& field, - vtkm::filter::PolicyBase, - const FilterType&) -{ - using ArrayHandleMultiplexerType = internal::ArrayHandleMultiplexerForStorageList< - T, - vtkm::ListAppend>; - return field.GetData().AsArrayHandle(); -} - -//----------------------------------------------------------------------------- -/// \brief Get an array from a `Field` that follows the types of an active field. -/// -/// Use this form for getting a `Field` to build the types that are appropriate for -/// the active field of this filter. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::UncertainArrayHandle< - typename vtkm::filter::DeduceFilterFieldTypes< - DerivedPolicy, - typename vtkm::filter::FilterTraits::InputFieldTypeList>::TypeList, - typename vtkm::filter::DeduceFilterFieldStorage< - DerivedPolicy, - typename vtkm::filter::FilterTraits::AdditionalFieldStorage>:: - StorageList> ApplyPolicyFieldActive(const vtkm::cont::Field& field, - vtkm::filter::PolicyBase, - vtkm::filter::FilterTraits) -{ - using FilterTypes = typename vtkm::filter::FilterTraits::InputFieldTypeList; - using TypeList = - typename vtkm::filter::DeduceFilterFieldTypes::TypeList; - using FilterStorage = typename vtkm::filter::FilterTraits::AdditionalFieldStorage; - using StorageList = - typename vtkm::filter::DeduceFilterFieldStorage::StorageList; - return field.GetData().ResetTypes(TypeList{}, StorageList{}); -} - -//----------------------------------------------------------------------------- -/// \brief Ge a cell set from a `UnknownCellSet` object. -/// -/// Adjusts the types of `CellSet`s to support those types specified in a policy. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::UncertainCellSet< - vtkm::ListAppend> ApplyPolicyCellSet(const vtkm::cont::UnknownCellSet& cellset, - vtkm::filter::PolicyBase, - const vtkm::filter::Filter&) -{ - using CellSetList = vtkm::ListAppend; - return cellset.ResetCellSetList(CellSetList()); -} - -template -VTKM_DEPRECATED(1.6, "ApplyPolicyCellSet now takes the filter as an argument.") -VTKM_CONT vtkm::cont::UncertainCellSet ApplyPolicyCellSet( - const vtkm::cont::UnknownCellSet& cellset, - vtkm::filter::PolicyBase) -{ - using CellSetList = typename DerivedPolicy::AllCellSetList; - return cellset.ResetCellSetList(CellSetList()); -} - -//----------------------------------------------------------------------------- -/// \brief Get a structured cell set from a `UnknownCellSet` object. -/// -/// Adjusts the types of `CellSet`s to support those structured cell set types -/// specified in a policy. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::UncertainCellSet> ApplyPolicyCellSetStructured(const vtkm::cont::UnknownCellSet& cellset, - vtkm::filter::PolicyBase, - const vtkm::filter::Filter&) -{ - using CellSetList = vtkm::ListAppend; - return cellset.ResetCellSetList(CellSetList()); -} - -template -VTKM_DEPRECATED(1.6, "ApplyPolicyCellSetStructured now takes the filter as an argument.") -VTKM_CONT vtkm::cont:: - UncertainCellSet ApplyPolicyCellSetStructured( - const vtkm::cont::UnknownCellSet& cellset, - vtkm::filter::PolicyBase) -{ - using CellSetList = typename DerivedPolicy::StructuredCellSetList; - return cellset.ResetCellSetList(CellSetList()); -} - -//----------------------------------------------------------------------------- -/// \brief Get an unstructured cell set from a `UnknownCellSet` object. -/// -/// Adjusts the types of `CellSet`s to support those unstructured cell set types -/// specified in a policy. -/// -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::UncertainCellSet> ApplyPolicyCellSetUnstructured(const vtkm::cont::UnknownCellSet& - cellset, - vtkm::filter::PolicyBase< - DerivedPolicy>, - const vtkm::filter::Filter< - DerivedFilter>&) -{ - using CellSetList = vtkm::ListAppend; - return cellset.ResetCellSetList(CellSetList()); -} - -template -VTKM_DEPRECATED(1.6, "ApplyPolicyCellSetUnstructured now takes the filter as an argument.") -VTKM_CONT vtkm::cont:: - UncertainCellSet ApplyPolicyCellSetUnstructured( - const vtkm::cont::UnknownCellSet& cellset, - vtkm::filter::PolicyBase) -{ - using CellSetList = typename DerivedPolicy::UnstructuredCellSetList; - return cellset.ResetCellSetList(CellSetList()); -} - -//----------------------------------------------------------------------------- -VTKM_DEPRECATED_SUPPRESS_BEGIN -template -VTKM_DEPRECATED(1.6, "MakeSerializableField is no longer needed.") -VTKM_CONT - vtkm::cont::SerializableField MakeSerializableField( - vtkm::filter::PolicyBase) -{ - return {}; -} - -template -VTKM_DEPRECATED(1.6, "MakeSerializableField is no longer needed.") -VTKM_CONT - vtkm::cont::SerializableField MakeSerializableField( - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase) -{ - return vtkm::cont::SerializableField{ field }; -} -VTKM_DEPRECATED_SUPPRESS_END - -template -VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.") -VTKM_CONT vtkm::cont::SerializableDataSet< - typename DerivedPolicy::FieldTypeList, - typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(vtkm::filter:: - PolicyBase) -{ - return {}; -} - -// TODO: Make DataSet serializable (issue #725). -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::SerializableDataSet< - typename DerivedPolicy::FieldTypeList, - vtkm::ListAppend< - typename DerivedFilter::SupportedCellSets, - typename DerivedPolicy::AllCellSetList>> MakeSerializableDataSet(vtkm::filter:: - PolicyBase, - const vtkm::filter::Filter< - DerivedFilter>&) -{ - return {}; -} - -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::SerializableDataSet< - VTKM_DEFAULT_TYPE_LIST, - typename DerivedFilter::SupportedCellSets> MakeSerializableDataSet(const vtkm::filter:: - Filter&) -{ - return {}; -} - -template -VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.") -VTKM_CONT vtkm::cont::SerializableDataSet< - typename DerivedPolicy::FieldTypeList, - typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(const vtkm::cont::DataSet& - dataset, - vtkm::filter::PolicyBase< - DerivedPolicy>) -{ - return vtkm::cont::SerializableDataSet{ dataset }; -} - -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::SerializableDataSet< - typename DerivedPolicy::FieldTypeList, - vtkm::ListAppend< - typename DerivedFilter::SupportedCellSets, - typename DerivedPolicy:: - AllCellSetList>> MakeSerializableDataSet(const vtkm::cont::DataSet& dataset, - vtkm::filter::PolicyBase, - const vtkm::filter::Filter&) -{ - return vtkm::cont::SerializableDataSet>{ - dataset - }; -} - -template -VTKM_DEPRECATED(1.9) -VTKM_CONT vtkm::cont::SerializableDataSet< - VTKM_DEFAULT_TYPE_LIST, - typename DerivedFilter::SupportedCellSets> MakeSerializableDataSet(const vtkm::cont::DataSet& - dataset, - const vtkm::filter::Filter< - DerivedFilter>&) -{ - return vtkm::cont::SerializableDataSet{ dataset }; -} -} -} // vtkm::filter - -#endif //vtk_m_filter_PolicyBase_h diff --git a/vtkm/filter/PolicyDefault.h b/vtkm/filter/PolicyDefault.h deleted file mode 100644 index 985a384b5..000000000 --- a/vtkm/filter/PolicyDefault.h +++ /dev/null @@ -1,28 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_filter_PolicyDefault_h -#define vtk_m_filter_PolicyDefault_h - -#include - -namespace vtkm -{ -namespace filter -{ - -struct VTKM_DEPRECATED(1.9) PolicyDefault : vtkm::filter::PolicyBase -{ - // Inherit defaults from PolicyBase -}; -} -} - -#endif //vtk_m_filter_PolicyDefault_h diff --git a/vtkm/filter/Probe.h b/vtkm/filter/Probe.h deleted file mode 100644 index d0ba730ca..000000000 --- a/vtkm/filter/Probe.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Probe_h -#define vtk_m_filter_Probe_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.") -inline void Probe_deprecated() {} - -inline void Probe_deprecated_warning() -{ - Probe_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Probe_h diff --git a/vtkm/filter/Slice.h b/vtkm/filter/Slice.h deleted file mode 100644 index d263d2a76..000000000 --- a/vtkm/filter/Slice.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Slice_h -#define vtk_m_filter_Slice_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/contour/Slice.h instead of vtkm/filter/Slice.h.") -inline void Slice_deprecated() {} - -inline void Slice_deprecated_warning() -{ - Slice_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Slice_h diff --git a/vtkm/filter/SplitSharpEdges.h b/vtkm/filter/SplitSharpEdges.h deleted file mode 100644 index 24d59bd14..000000000 --- a/vtkm/filter/SplitSharpEdges.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_SplitSharpEdges_h -#define vtk_m_filter_SplitSharpEdges_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/geometry_refinement/SplitSharpEdges.h instead of vtkm/filter/SplitSharpEdges.h.") -inline void SplitSharpEdges_deprecated() {} - -inline void SplitSharpEdges_deprecated_warning() -{ - SplitSharpEdges_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_SplitSharpEdges_h diff --git a/vtkm/filter/StreamSurface.h b/vtkm/filter/StreamSurface.h deleted file mode 100644 index 362c38e91..000000000 --- a/vtkm/filter/StreamSurface.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_StreamSurface_h -#define vtk_m_filter_StreamSurface_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/StreamSurface.h instead of vtkm/filter/StreamSurface.h") -inline void StreamSurface_deprecated() {} - -inline void StreamSurface_deprecated_warning() -{ - StreamSurface_deprecated(); -} - -} -} - -#endif //vtk_m_filter_StreamSurface_h diff --git a/vtkm/filter/Streamline.h b/vtkm/filter/Streamline.h deleted file mode 100644 index 39356dac3..000000000 --- a/vtkm/filter/Streamline.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Streamline_h -#define vtk_m_filter_Streamline_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/Streamline.h instead of vtkm/filter/Streamline.h") -inline void Streamline_deprecated() {} - -inline void Streamline_deprecated_warning() -{ - Streamline_deprecated(); -} - -} -} - -#endif //vtk_m_filter_Streamline_h diff --git a/vtkm/filter/SurfaceNormals.h b/vtkm/filter/SurfaceNormals.h deleted file mode 100644 index b72508ea4..000000000 --- a/vtkm/filter/SurfaceNormals.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_SurfaceNormals_h -#define vtk_m_filter_SurfaceNormals_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/vector_analysis/SurfaceNormals.h instead of vtkm/filter/SurfaceNormals.h.") -inline void SurfaceNormals_deprecated() {} - -inline void SurfaceNormals_deprecated_warning() -{ - SurfaceNormals_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_SurfaceNormals_h diff --git a/vtkm/filter/Tetrahedralize.h b/vtkm/filter/Tetrahedralize.h deleted file mode 100644 index cc01be273..000000000 --- a/vtkm/filter/Tetrahedralize.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Tetrahedralize_h -#define vtk_m_filter_Tetrahedralize_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/geometry_refinement/Tetrahedralize.h instead of vtkm/filter/Tetrahedralize.h.") -inline void Tetrahedralize_deprecated() {} - -inline void Tetrahedralize_deprecated_warning() -{ - Tetrahedralize_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Tetrahedralize_h diff --git a/vtkm/filter/Threshold.h b/vtkm/filter/Threshold.h deleted file mode 100644 index a14385451..000000000 --- a/vtkm/filter/Threshold.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Threshold_h -#define vtk_m_filter_Threshold_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/entity_extraction/Threshold.h instead of vtkm/filter/Threshold.h.") -inline void Threshold_deprecated() {} - -inline void Threshold_deprecated_warning() -{ - Threshold_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Threshold_h diff --git a/vtkm/filter/ThresholdPoints.h b/vtkm/filter/ThresholdPoints.h deleted file mode 100644 index 73839e19f..000000000 --- a/vtkm/filter/ThresholdPoints.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ThresholdPoints_h -#define vtk_m_filter_ThresholdPoints_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/entity_extraction/ThresholdPoints.h instead of vtkm/filter/ThresholdPoints.h.") -inline void ThresholdPoints_deprecated() {} - -inline void ThresholdPoints_deprecated_warning() -{ - ThresholdPoints_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ThresholdPoints_h diff --git a/vtkm/filter/Triangulate.h b/vtkm/filter/Triangulate.h deleted file mode 100644 index c79d94ff8..000000000 --- a/vtkm/filter/Triangulate.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Triangulate_h -#define vtk_m_filter_Triangulate_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/geometry_refinement/Triangulate.h instead of vtkm/filter/Triangulate.h.") -inline void Triangulate_deprecated() {} - -inline void Triangulate_deprecated_warning() -{ - Triangulate_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Triangulate_h diff --git a/vtkm/filter/Tube.h b/vtkm/filter/Tube.h deleted file mode 100644 index 588ba57f7..000000000 --- a/vtkm/filter/Tube.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_Tube_h -#define vtk_m_filter_Tube_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, "Use vtkm/filter/geometry_refinement/Tube.h instead of vtkm/filter/Tube.h.") -inline void Tube_deprecated() {} - -inline void Tube_deprecated_warning() -{ - Tube_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_Tube_h diff --git a/vtkm/filter/VectorMagnitude.h b/vtkm/filter/VectorMagnitude.h deleted file mode 100644 index e28311dd3..000000000 --- a/vtkm/filter/VectorMagnitude.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_VectorMagnitude_h -#define vtk_m_filter_VectorMagnitude_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/vector_analysis/VectorMagnitude.h instead of vtkm/filter/VectorMagnitude.h.") -inline void VectorMagnitude_deprecated() {} - -inline void VectorMagnitude_deprecated_warning() -{ - VectorMagnitude_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_VectorMagnitude_h diff --git a/vtkm/filter/VertexClustering.h b/vtkm/filter/VertexClustering.h deleted file mode 100644 index e672fba63..000000000 --- a/vtkm/filter/VertexClustering.h +++ /dev/null @@ -1,35 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_VertexClustering_h -#define vtk_m_filter_VertexClustering_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/geometry_refinement/VertexClustering.h instead of " - "vtkm/filter/VertexClustering.h.") -inline void VertexClustering_deprecated() {} - -inline void VertexClustering_deprecated_warning() -{ - VertexClustering_deprecated(); -} - - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_VertexClustering_h diff --git a/vtkm/filter/WarpScalar.h b/vtkm/filter/WarpScalar.h deleted file mode 100644 index 4d4d27cf5..000000000 --- a/vtkm/filter/WarpScalar.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_WarpScalar_h -#define vtk_m_filter_WarpScalar_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/field_transform/WarpScalar.h instead of vtkm/filter/WarpScalar.h.") -inline void WarpScalar_deprecated() {} - -inline void WarpScalar_deprecated_warning() -{ - WarpScalar_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_WarpScalar_h diff --git a/vtkm/filter/WarpVector.h b/vtkm/filter/WarpVector.h deleted file mode 100644 index 5a24d3aa1..000000000 --- a/vtkm/filter/WarpVector.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_WarpVector_h -#define vtk_m_filter_WarpVector_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/field_transform/WarpVector.h instead of vtkm/filter/WarpVector.h.") -inline void WarpVector_deprecated() {} - -inline void WarpVector_deprecated_warning() -{ - WarpVector_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_WarpVector_h diff --git a/vtkm/filter/ZFPCompressor1D.h b/vtkm/filter/ZFPCompressor1D.h deleted file mode 100644 index 453bdfd56..000000000 --- a/vtkm/filter/ZFPCompressor1D.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPCompressor1D_h -#define vtk_m_filter_ZFPCompressor1D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/zfp/ZFPCompressor1D.h instead of vtkm/filter/ZFPCompressor1D.h.") -inline void ZFPCompressor1D_deprecated() {} - -inline void ZFPCompressor1D_deprecated_warning() -{ - ZFPCompressor1D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPCompressor1D_h diff --git a/vtkm/filter/ZFPCompressor2D.h b/vtkm/filter/ZFPCompressor2D.h deleted file mode 100644 index ce07f14eb..000000000 --- a/vtkm/filter/ZFPCompressor2D.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPCompressor2D_h -#define vtk_m_filter_ZFPCompressor2D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/zfp/ZFPCompressor2D.h instead of vtkm/filter/ZFPCompressor2D.h.") -inline void ZFPCompressor2D_deprecated() {} - -inline void ZFPCompressor2D_deprecated_warning() -{ - ZFPCompressor2D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPCompressor2D_h diff --git a/vtkm/filter/ZFPCompressor3D.h b/vtkm/filter/ZFPCompressor3D.h deleted file mode 100644 index 8ba525048..000000000 --- a/vtkm/filter/ZFPCompressor3D.h +++ /dev/null @@ -1,33 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPCompressor3D_h -#define vtk_m_filter_ZFPCompressor3D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED(1.8, - "Use vtkm/filter/zfp/ZFPCompressor3D.h instead of vtkm/filter/ZFPCompressor3D.h.") -inline void ZFPCompressor3D_deprecated() {} - -inline void ZFPCompressor3D_deprecated_warning() -{ - ZFPCompressor3D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPCompressor3D_h diff --git a/vtkm/filter/ZFPDecompressor1D.h b/vtkm/filter/ZFPDecompressor1D.h deleted file mode 100644 index 49636d9ec..000000000 --- a/vtkm/filter/ZFPDecompressor1D.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPDecompressor1D_h -#define vtk_m_filter_ZFPDecompressor1D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/zfp/ZFPDecompressor1D.h instead of vtkm/filter/ZFPDecompressor1D.h.") -inline void ZFPDecompressor1D_deprecated() {} - -inline void ZFPDecompressor1D_deprecated_warning() -{ - ZFPDecompressor1D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPDecompressor1D_h diff --git a/vtkm/filter/ZFPDecompressor2D.h b/vtkm/filter/ZFPDecompressor2D.h deleted file mode 100644 index 30d798ec8..000000000 --- a/vtkm/filter/ZFPDecompressor2D.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPDecompressor2D_h -#define vtk_m_filter_ZFPDecompressor2D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/zfp/ZFPDecompressor2D.h instead of vtkm/filter/ZFPDecompressor2D.h.") -inline void ZFPDecompressor2D_deprecated() {} - -inline void ZFPDecompressor2D_deprecated_warning() -{ - ZFPDecompressor2D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPDecompressor2D_h diff --git a/vtkm/filter/ZFPDecompressor3D.h b/vtkm/filter/ZFPDecompressor3D.h deleted file mode 100644 index a46350959..000000000 --- a/vtkm/filter/ZFPDecompressor3D.h +++ /dev/null @@ -1,34 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_ZFPDecompressor3D_h -#define vtk_m_filter_ZFPDecompressor3D_h - -#include -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED( - 1.8, - "Use vtkm/filter/zfp/ZFPDecompressor3D.h instead of vtkm/filter/ZFPDecompressor3D.h.") -inline void ZFPDecompressor3D_deprecated() {} - -inline void ZFPDecompressor3D_deprecated_warning() -{ - ZFPDecompressor3D_deprecated(); -} - -} -} // namespace vtkm::filter - -#endif //vtk_m_filter_ZFPDecompressor3D_h diff --git a/vtkm/filter/clean_grid/CMakeLists.txt b/vtkm/filter/clean_grid/CMakeLists.txt index 81c141ee4..1a22ede7c 100644 --- a/vtkm/filter/clean_grid/CMakeLists.txt +++ b/vtkm/filter/clean_grid/CMakeLists.txt @@ -19,12 +19,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_clean_grid PRIVATE vtkm_worklet PUBLIC vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_clean_grid) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/clean_grid/CleanGrid.cxx b/vtkm/filter/clean_grid/CleanGrid.cxx index bf0a068dc..47cf0bf90 100644 --- a/vtkm/filter/clean_grid/CleanGrid.cxx +++ b/vtkm/filter/clean_grid/CleanGrid.cxx @@ -98,16 +98,9 @@ vtkm::cont::DataSet CleanGrid::GenerateOutput(const vtkm::cont::DataSet& inData, { using VecId = std::size_t; const auto activeCoordIndex = static_cast(this->GetActiveCoordinateSystemIndex()); - const auto numCoordSystems = static_cast(inData.GetNumberOfCoordinateSystems()); - - std::vector outputCoordinateSystems(numCoordSystems); // Start with a shallow copy of the coordinate systems - for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex) - { - outputCoordinateSystems[coordSystemIndex] = - inData.GetCoordinateSystem(static_cast(coordSystemIndex)); - } + vtkm::cont::CoordinateSystem activeCoordSystem = inData.GetCoordinateSystem(activeCoordIndex); // Optionally adjust the cell set indices to remove all unused points if (this->GetCompactPointFields()) @@ -118,19 +111,14 @@ vtkm::cont::DataSet CleanGrid::GenerateOutput(const vtkm::cont::DataSet& inData, outputCellSet = worklets.PointCompactor.MapCellSet(outputCellSet); - for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex) - { - outputCoordinateSystems[coordSystemIndex] = - vtkm::cont::CoordinateSystem(outputCoordinateSystems[coordSystemIndex].GetName(), - worklets.PointCompactor.MapPointFieldDeep( - outputCoordinateSystems[coordSystemIndex].GetData())); - } + activeCoordSystem = vtkm::cont::CoordinateSystem( + activeCoordSystem.GetName(), + worklets.PointCompactor.MapPointFieldDeep(activeCoordSystem.GetData())); } // Optionally find and merge coincident points if (this->GetMergePoints()) { - vtkm::cont::CoordinateSystem activeCoordSystem = outputCoordinateSystems[activeCoordIndex]; vtkm::Bounds bounds = activeCoordSystem.GetBounds(); vtkm::Float64 delta = this->GetTolerance(); @@ -144,20 +132,6 @@ vtkm::cont::DataSet CleanGrid::GenerateOutput(const vtkm::cont::DataSet& inData, worklets.PointMerger.Run(delta, this->GetFastMerge(), bounds, coordArray); activeCoordSystem = vtkm::cont::CoordinateSystem(activeCoordSystem.GetName(), coordArray); - for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex) - { - if (coordSystemIndex == activeCoordIndex) - { - outputCoordinateSystems[coordSystemIndex] = activeCoordSystem; - } - else - { - outputCoordinateSystems[coordSystemIndex] = vtkm::cont::CoordinateSystem( - outputCoordinateSystems[coordSystemIndex].GetName(), - worklets.PointMerger.MapPointField(outputCoordinateSystems[coordSystemIndex].GetData())); - } - } - outputCellSet = worklets.PointMerger.MapCellSet(outputCellSet); } @@ -178,7 +152,7 @@ vtkm::cont::DataSet CleanGrid::GenerateOutput(const vtkm::cont::DataSet& inData, auto mapper = [&](auto& outDataSet, const auto& f) { DoMapField(outDataSet, f, *this, worklets); }; - return this->CreateResult(inData, outputCellSet, outputCoordinateSystems, mapper); + return this->CreateResultCoordinateSystem(inData, outputCellSet, activeCoordSystem, mapper); } vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::DataSet& inData) diff --git a/vtkm/filter/clean_grid/CleanGrid.h b/vtkm/filter/clean_grid/CleanGrid.h index 2e8fec952..1349b4dbf 100644 --- a/vtkm/filter/clean_grid/CleanGrid.h +++ b/vtkm/filter/clean_grid/CleanGrid.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_clean_grid_CleanGrid_h #define vtk_m_filter_clean_grid_CleanGrid_h -#include +#include #include namespace vtkm @@ -37,7 +37,7 @@ struct SharedStates; /// \todo Add a feature to merge points that are coincident or within a /// tolerance. /// -class VTKM_FILTER_CLEAN_GRID_EXPORT CleanGrid : public vtkm::filter::NewFilterField +class VTKM_FILTER_CLEAN_GRID_EXPORT CleanGrid : public vtkm::filter::FilterField { public: /// When the CompactPointFields flag is true, the filter will identify any @@ -97,12 +97,6 @@ private: }; } // namespace clean_grid -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::clean_grid::CleanGrid.") CleanGrid - : public vtkm::filter::clean_grid::CleanGrid -{ - using clean_grid::CleanGrid::CleanGrid; -}; - } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/clean_grid/testing/UnitTestCleanGrid.cxx b/vtkm/filter/clean_grid/testing/UnitTestCleanGrid.cxx index 2145a34ce..740e6d9dc 100644 --- a/vtkm/filter/clean_grid/testing/UnitTestCleanGrid.cxx +++ b/vtkm/filter/clean_grid/testing/UnitTestCleanGrid.cxx @@ -76,7 +76,7 @@ void TestPointMerging() //filter for uniform data always does point merging vtkm::cont::ArrayHandle newcoords; vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords); - baseData.GetCoordinateSystem().SetData(newcoords); + baseData.AddPointField(baseData.GetCoordinateSystemName(), newcoords); vtkm::filter::contour::Contour marchingCubes; marchingCubes.SetIsoValue(0.05); diff --git a/vtkm/filter/clean_grid/vtkm.module b/vtkm/filter/clean_grid/vtkm.module new file mode 100644 index 000000000..e6d125c88 --- /dev/null +++ b/vtkm/filter/clean_grid/vtkm.module @@ -0,0 +1,12 @@ +NAME + vtkm_filter_clean_grid +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_clean_grid + vtkm_filter_contour diff --git a/vtkm/filter/clean_grid/worklet/RemoveUnusedPoints.h b/vtkm/filter/clean_grid/worklet/RemoveUnusedPoints.h index f5ee58804..c841b33ef 100644 --- a/vtkm/filter/clean_grid/worklet/RemoveUnusedPoints.h +++ b/vtkm/filter/clean_grid/worklet/RemoveUnusedPoints.h @@ -21,12 +21,6 @@ #include #include -// For support of deprecated features. -#include -VTKM_DEPRECATED_SUPPRESS_BEGIN -#include -VTKM_DEPRECATED_SUPPRESS_END - namespace vtkm { namespace worklet @@ -226,18 +220,6 @@ private: (*this)(inArray, outArray, self); outHolder = vtkm::cont::UnknownArrayHandle{ outArray }; } - - VTKM_DEPRECATED_SUPPRESS_BEGIN - template - VTKM_CONT void operator()(const vtkm::cont::ArrayHandle& inArray, - vtkm::cont::VariantArrayHandleCommon& outHolder, - const RemoveUnusedPoints& self) const - { - vtkm::cont::ArrayHandle outArray; - (*this)(inArray, outArray, self); - outHolder = vtkm::cont::VariantArrayHandleCommon{ outArray }; - } - VTKM_DEPRECATED_SUPPRESS_END }; public: @@ -284,25 +266,6 @@ public: vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this); return outArray; } - - VTKM_DEPRECATED_SUPPRESS_BEGIN - template - VTKM_CONT void MapPointFieldDeep(const vtkm::cont::VariantArrayHandleBase& inArray, - OutArrayHandle& outArray) const - { - vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this); - } - - template - VTKM_CONT vtkm::cont::VariantArrayHandleBase MapPointFieldDeep( - const vtkm::cont::VariantArrayHandleBase& inArray) const - { - vtkm::cont::VariantArrayHandleBase outArray; - vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this); - - return outArray; - } - VTKM_DEPRECATED_SUPPRESS_END ///@} const vtkm::worklet::ScatterCounting& GetPointScatter() const { return *this->PointScatter; } diff --git a/vtkm/filter/connected_components/CMakeLists.txt b/vtkm/filter/connected_components/CMakeLists.txt index 0d56b1766..1d69bbede 100644 --- a/vtkm/filter/connected_components/CMakeLists.txt +++ b/vtkm/filter/connected_components/CMakeLists.txt @@ -27,8 +27,3 @@ target_link_libraries(vtkm_filter_connected_components PRIVATE vtkm_worklet PUBL target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_connected_components) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/connected_components/CellSetConnectivity.h b/vtkm/filter/connected_components/CellSetConnectivity.h index efb95ee58..44d6e4e2d 100644 --- a/vtkm/filter/connected_components/CellSetConnectivity.h +++ b/vtkm/filter/connected_components/CellSetConnectivity.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_connected_components_CellSetConnectivity_h #define vtk_m_filter_connected_components_CellSetConnectivity_h -#include +#include #include namespace vtkm @@ -28,8 +28,7 @@ namespace connected_components /// number of components and assigns each component a unique integer. /// The result of the filter is a cell field of type vtkm::Id with the default name of 'component'. /// Each entry in the cell field will be a number that identifies to which component the cell belongs. -class VTKM_FILTER_CONNECTED_COMPONENTS_EXPORT CellSetConnectivity - : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONNECTED_COMPONENTS_EXPORT CellSetConnectivity : public vtkm::filter::FilterField { public: VTKM_CONT CellSetConnectivity() { this->SetOutputFieldName("component"); } @@ -41,12 +40,6 @@ private: } // namespace connected_components -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::connected_components::CellSetConnectivity.") - CellSetConnectivity : public vtkm::filter::connected_components::CellSetConnectivity -{ - using connected_components::CellSetConnectivity::CellSetConnectivity; -}; - } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/connected_components/ImageConnectivity.h b/vtkm/filter/connected_components/ImageConnectivity.h index 6ab5f216b..ba2d0d6cf 100644 --- a/vtkm/filter/connected_components/ImageConnectivity.h +++ b/vtkm/filter/connected_components/ImageConnectivity.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_connected_components_ImageConnectivity_h #define vtk_m_filter_connected_components_ImageConnectivity_h -#include +#include #include /// \brief Groups connected points that have the same field value @@ -30,8 +30,7 @@ namespace filter { namespace connected_components { -class VTKM_FILTER_CONNECTED_COMPONENTS_EXPORT ImageConnectivity - : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONNECTED_COMPONENTS_EXPORT ImageConnectivity : public vtkm::filter::FilterField { public: VTKM_CONT ImageConnectivity() { this->SetOutputFieldName("component"); } @@ -42,12 +41,6 @@ private: }; } // namespace connected_components -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::connected_components::ImageConnectivity.") - ImageConnectivity : public vtkm::filter::connected_components::ImageConnectivity -{ - using connected_components::ImageConnectivity::ImageConnectivity; -}; - } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/connected_components/testing/UnitTestCellSetConnectivityFilter.cxx b/vtkm/filter/connected_components/testing/UnitTestCellSetConnectivityFilter.cxx index 247832b89..06ec20443 100644 --- a/vtkm/filter/connected_components/testing/UnitTestCellSetConnectivityFilter.cxx +++ b/vtkm/filter/connected_components/testing/UnitTestCellSetConnectivityFilter.cxx @@ -24,8 +24,8 @@ class TestCellSetConnectivity public: static void TestTangleIsosurface() { - vtkm::Id3 dims(4, 4, 4); - vtkm::source::Tangle tangle(dims); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions({ 4, 4, 4 }); vtkm::cont::DataSet dataSet = tangle.Execute(); vtkm::filter::contour::Contour filter; diff --git a/vtkm/filter/connected_components/vtkm.module b/vtkm/filter/connected_components/vtkm.module new file mode 100644 index 000000000..f1463dca9 --- /dev/null +++ b/vtkm/filter/connected_components/vtkm.module @@ -0,0 +1,12 @@ +NAME + vtkm_filter_connected_components +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_contour + vtkm_filter_connected_components + vtkm_source diff --git a/vtkm/filter/contour/CMakeLists.txt b/vtkm/filter/contour/CMakeLists.txt index 1a59cc4f0..351d55546 100644 --- a/vtkm/filter/contour/CMakeLists.txt +++ b/vtkm/filter/contour/CMakeLists.txt @@ -38,10 +38,6 @@ set_property(TARGET PROPERTY UNITY_BUILD_MODE GROUP ) -target_link_libraries(vtkm_filter_contour - PRIVATE vtkm_worklet - PUBLIC vtkm_filter_core vtkm_filter_vector_analysis vtkm_filter_mesh_info) - if (VTKm_ENABLE_MPI) target_link_libraries(vtkm_filter_contour PUBLIC MPI::MPI_CXX) endif () @@ -51,8 +47,3 @@ target_link_libraries(vtkm_filter PUBLIC INTERFACE ) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/contour/ClipWithField.h b/vtkm/filter/contour/ClipWithField.h index 7087a9aa3..ff11a3d0e 100644 --- a/vtkm/filter/contour/ClipWithField.h +++ b/vtkm/filter/contour/ClipWithField.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_contour_ClipWithField_h #define vtk_m_filter_contour_ClipWithField_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace contour /// value are considered outside, and will be discarded. All points that are greater /// are kept. /// The resulting geometry will not be water tight. -class VTKM_FILTER_CONTOUR_EXPORT ClipWithField : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONTOUR_EXPORT ClipWithField : public vtkm::filter::FilterField { public: VTKM_CONT @@ -45,11 +45,6 @@ private: bool Invert = false; }; } // namespace contour -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::ClipWithField.") ClipWithField - : public vtkm::filter::contour::ClipWithField -{ - using contour::ClipWithField::ClipWithField; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/ClipWithImplicitFunction.h b/vtkm/filter/contour/ClipWithImplicitFunction.h index a0dfbb9a8..e469c04c8 100644 --- a/vtkm/filter/contour/ClipWithImplicitFunction.h +++ b/vtkm/filter/contour/ClipWithImplicitFunction.h @@ -12,7 +12,7 @@ #include -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace contour /// Clip a dataset using a given implicit function value, such as vtkm::Sphere /// or vtkm::Frustum. /// The resulting geometry will not be water tight. -class VTKM_FILTER_CONTOUR_EXPORT ClipWithImplicitFunction : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONTOUR_EXPORT ClipWithImplicitFunction : public vtkm::filter::FilterField { public: void SetImplicitFunction(const vtkm::ImplicitFunctionGeneral& func) { this->Function = func; } @@ -46,11 +46,6 @@ private: bool Invert = false; }; } // namespace contour -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::ClipWithImplicitFunction.") - ClipWithImplicitFunction : public vtkm::filter::contour::ClipWithImplicitFunction -{ - using contour::ClipWithImplicitFunction::ClipWithImplicitFunction; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/Contour.cxx b/vtkm/filter/contour/Contour.cxx index d16778bc9..4dbb51149 100644 --- a/vtkm/filter/contour/Contour.cxx +++ b/vtkm/filter/contour/Contour.cxx @@ -144,8 +144,8 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& inDataSet) resolveFieldType); auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - vtkm::cont::DataSet output = this->CreateResult( - inDataSet, outputCells, vtkm::cont::CoordinateSystem{ "coordinates", vertices }, mapper); + vtkm::cont::DataSet output = this->CreateResultCoordinateSystem( + inDataSet, outputCells, inputCoords.GetName(), vertices, mapper); if (this->GenerateNormals) { diff --git a/vtkm/filter/contour/Contour.h b/vtkm/filter/contour/Contour.h index 257cdbff9..6ef69d9d2 100644 --- a/vtkm/filter/contour/Contour.h +++ b/vtkm/filter/contour/Contour.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_contour_Contour_h #define vtk_m_filter_contour_Contour_h -#include +#include #include namespace vtkm @@ -27,7 +27,7 @@ namespace contour /// Multiple contour values must be specified to generate the isosurfaces. /// @warning /// This filter is currently only supports 3D volumes. -class VTKM_FILTER_CONTOUR_EXPORT Contour : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONTOUR_EXPORT Contour : public vtkm::filter::FilterField { public: void SetNumberOfIsoValues(vtkm::Id num) @@ -128,11 +128,6 @@ protected: vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override; }; } // namespace contour -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::Contour.") Contour - : public vtkm::filter::contour::Contour -{ - using contour::Contour::Contour; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/MIRFilter.cxx b/vtkm/filter/contour/MIRFilter.cxx index dcac6fb44..ea2e18dfc 100644 --- a/vtkm/filter/contour/MIRFilter.cxx +++ b/vtkm/filter/contour/MIRFilter.cxx @@ -335,7 +335,8 @@ VTKM_CONT vtkm::cont::DataSet MIRFilter::DoExecute(const vtkm::cont::DataSet& in auto mapper = [&](auto& outDataSet, const auto& f) { this->DoMapField(outDataSet, f, filterCellInterp, MIRWeights, MIRIDs); }; - auto output = this->CreateResult(input, saved.GetCellSet(), saved.GetCoordinateSystems(), mapper); + auto output = this->CreateResultCoordinateSystem( + input, saved.GetCellSet(), saved.GetCoordinateSystem(), mapper); output.AddField(saved.GetField(this->GetOutputFieldName())); return output; diff --git a/vtkm/filter/contour/MIRFilter.h b/vtkm/filter/contour/MIRFilter.h index cd1c1c53e..2cc2dcee4 100644 --- a/vtkm/filter/contour/MIRFilter.h +++ b/vtkm/filter/contour/MIRFilter.h @@ -11,7 +11,7 @@ #ifndef vtkm_m_filter_contour_MIRFilter_h #define vtkm_m_filter_contour_MIRFilter_h -#include +#include #include namespace vtkm @@ -48,7 +48,7 @@ namespace contour /// total error % of the entire dataset is less than the specified amount (defaults to 1.0, returns after first iteration). Finally, /// the error scaling and scaling decay allows for setting how much the cell VFs should react to the delta between target and calculated cell VFs. /// the error scaling will decay by the decay variable every iteration (multiplicitively). -class VTKM_FILTER_CONTOUR_EXPORT MIRFilter : public vtkm::filter::NewFilterField +class VTKM_FILTER_CONTOUR_EXPORT MIRFilter : public vtkm::filter::FilterField { public: /// @brief Sets the name of the offset/position cellset field in the dataset passed to the filter @@ -87,11 +87,6 @@ private: vtkm::Float64 error_scaling = vtkm::Float64(0.0); }; } // namespace contour -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::MIRFilter.") MIRFilter - : public vtkm::filter::contour::MIRFilter -{ - using contour::MIRFilter::MIRFilter; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/Slice.h b/vtkm/filter/contour/Slice.h index 10244bc1b..c2bb4c18d 100644 --- a/vtkm/filter/contour/Slice.h +++ b/vtkm/filter/contour/Slice.h @@ -37,11 +37,6 @@ private: vtkm::ImplicitFunctionGeneral Function; }; } // namespace contour -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::Slice.") Slice - : public vtkm::filter::contour::Slice -{ - using contour::Slice::Slice; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/testing/CMakeLists.txt b/vtkm/filter/contour/testing/CMakeLists.txt index 4b1b5ced6..843140bed 100644 --- a/vtkm/filter/contour/testing/CMakeLists.txt +++ b/vtkm/filter/contour/testing/CMakeLists.txt @@ -18,29 +18,15 @@ set(unit_tests_device UnitTestMIRFilter.cxx # Algorithm used, needs device compiler ) -set(libraries - vtkm_filter_clean_grid - vtkm_filter_contour - vtkm_filter_field_transform - vtkm_filter_geometry_refinement - vtkm_io - vtkm_source -) - if (VTKm_ENABLE_RENDERING) - list(APPEND libraries - vtkm_rendering_testing - vtkm_rendering) - list(APPEND unit_tests RenderTestContourFilter.cxx RenderTestSliceFilter.cxx - ) + ) endif() vtkm_unit_tests( SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device} - LIBRARIES ${libraries} USE_VTKM_JOB_POOL ) diff --git a/vtkm/filter/contour/testing/RenderTestContourFilter.cxx b/vtkm/filter/contour/testing/RenderTestContourFilter.cxx index 9d037e049..d20f804aa 100644 --- a/vtkm/filter/contour/testing/RenderTestContourFilter.cxx +++ b/vtkm/filter/contour/testing/RenderTestContourFilter.cxx @@ -110,8 +110,8 @@ void TestContourFilterTangle() { std::cout << "Generate Image for Contour filter on a uniform tangle grid" << std::endl; - vtkm::Id3 dims(4, 4, 4); - vtkm::source::Tangle tangle(dims); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions({ 4, 4, 4 }); vtkm::cont::DataSet dataSet = tangle.Execute(); vtkm::filter::contour::Contour contour; diff --git a/vtkm/filter/contour/testing/RenderTestSliceFilter.cxx b/vtkm/filter/contour/testing/RenderTestSliceFilter.cxx index 35a3cddcb..8778440c3 100644 --- a/vtkm/filter/contour/testing/RenderTestSliceFilter.cxx +++ b/vtkm/filter/contour/testing/RenderTestSliceFilter.cxx @@ -24,7 +24,8 @@ void TestSliceStructuredPointsPlane() { std::cout << "Generate Image for Slice by plane on structured points" << std::endl; - vtkm::source::Wavelet wavelet(vtkm::Id3(-8), vtkm::Id3(8)); + vtkm::source::Wavelet wavelet; + wavelet.SetExtent(vtkm::Id3(-8), vtkm::Id3(8)); auto ds = wavelet.Execute(); vtkm::Plane plane(vtkm::Plane::Vector{ 1, 1, 1 }); @@ -45,7 +46,8 @@ void TestSliceStructuredPointsSphere() { std::cout << "Generate Image for Slice by sphere on structured points" << std::endl; - vtkm::source::Wavelet wavelet(vtkm::Id3(-8), vtkm::Id3(8)); + vtkm::source::Wavelet wavelet; + wavelet.SetExtent(vtkm::Id3(-8), vtkm::Id3(8)); auto ds = wavelet.Execute(); vtkm::Sphere sphere(8.5f); @@ -66,7 +68,8 @@ void TestSliceUnstructuredGridPlane() { std::cout << "Generate Image for Slice by plane on unstructured grid" << std::endl; - vtkm::source::Wavelet wavelet(vtkm::Id3(-8), vtkm::Id3(8)); + vtkm::source::Wavelet wavelet; + wavelet.SetExtent(vtkm::Id3(-8), vtkm::Id3(8)); auto ds = wavelet.Execute(); vtkm::filter::geometry_refinement::Tetrahedralize tetrahedralize; ds = tetrahedralize.Execute(ds); @@ -89,7 +92,8 @@ void TestSliceUnstructuredGridCylinder() { std::cout << "Generate Image for Slice by cylinder on unstructured grid" << std::endl; - vtkm::source::Wavelet wavelet(vtkm::Id3(-8), vtkm::Id3(8)); + vtkm::source::Wavelet wavelet; + wavelet.SetExtent(vtkm::Id3(-8), vtkm::Id3(8)); auto ds = wavelet.Execute(); vtkm::filter::geometry_refinement::Tetrahedralize tetrahedralize; ds = tetrahedralize.Execute(ds); diff --git a/vtkm/filter/contour/testing/UnitTestClipWithFieldFilter.cxx b/vtkm/filter/contour/testing/UnitTestClipWithFieldFilter.cxx index bef6f0975..3e854f9d0 100644 --- a/vtkm/filter/contour/testing/UnitTestClipWithFieldFilter.cxx +++ b/vtkm/filter/contour/testing/UnitTestClipWithFieldFilter.cxx @@ -63,7 +63,7 @@ void TestClipExplicit() VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems in the output dataset"); - VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); auto temp = outputData.GetField("scalars").GetData(); diff --git a/vtkm/filter/contour/testing/UnitTestClipWithImplicitFunctionFilter.cxx b/vtkm/filter/contour/testing/UnitTestClipWithImplicitFunctionFilter.cxx index 36feba3e4..d8f0e834b 100644 --- a/vtkm/filter/contour/testing/UnitTestClipWithImplicitFunctionFilter.cxx +++ b/vtkm/filter/contour/testing/UnitTestClipWithImplicitFunctionFilter.cxx @@ -62,7 +62,7 @@ void TestClipStructured(vtkm::Float64 offset) VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems in the output dataset"); - VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 8, "Wrong number of cells in the output dataset"); @@ -98,7 +98,7 @@ void TestClipStructuredInverted() clip.SetFieldsToPass("scalars"); auto outputData = clip.Execute(ds); - VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 4, "Wrong number of cells in the output dataset"); diff --git a/vtkm/filter/contour/testing/UnitTestContourFilter.cxx b/vtkm/filter/contour/testing/UnitTestContourFilter.cxx index d99445d68..61e41e5c6 100644 --- a/vtkm/filter/contour/testing/UnitTestContourFilter.cxx +++ b/vtkm/filter/contour/testing/UnitTestContourFilter.cxx @@ -30,8 +30,8 @@ public: { std::cout << "Testing Contour filter on a uniform grid" << std::endl; - vtkm::Id3 dims(4, 4, 4); - vtkm::source::Tangle tangle(dims); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions({ 4, 4, 4 }); vtkm::filter::field_transform::GenerateIds genIds; genIds.SetUseFloat(true); genIds.SetGeneratePointIds(false); @@ -50,7 +50,7 @@ public: VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems in the output dataset"); //since normals is on we have one field - VTKM_TEST_ASSERT(result.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(result.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); } @@ -61,7 +61,7 @@ public: const bool isMapped = result.HasField("tangle"); VTKM_TEST_ASSERT(isMapped, "mapping should pass"); - VTKM_TEST_ASSERT(result.GetNumberOfFields() == 3, + VTKM_TEST_ASSERT(result.GetNumberOfFields() == 4, "Wrong number of fields in the output dataset"); //verify the cellvar result diff --git a/vtkm/filter/contour/vtkm.module b/vtkm/filter/contour/vtkm.module new file mode 100644 index 000000000..56fe5b405 --- /dev/null +++ b/vtkm/filter/contour/vtkm.module @@ -0,0 +1,21 @@ +NAME + vtkm_filter_contour +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core + vtkm_filter_vector_analysis + vtkm_filter_mesh_info +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_clean_grid + vtkm_filter_contour + vtkm_filter_field_transform + vtkm_filter_geometry_refinement + vtkm_io + vtkm_source +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing + vtkm_rendering diff --git a/vtkm/filter/contour/worklet/MIR.h b/vtkm/filter/contour/worklet/MIR.h index 542f11da6..f3d794e79 100644 --- a/vtkm/filter/contour/worklet/MIR.h +++ b/vtkm/filter/contour/worklet/MIR.h @@ -271,8 +271,8 @@ public: { for (vtkm::IdComponent iter = pointCount - 1; iter >= 0; iter--) { - if (static_cast(prevVals[valPositionStart + iter]) <= - static_cast(newVals[valPositionStart + iter])) + if (static_cast(prevVals.Get(valPositionStart + iter)) <= + static_cast(newVals.Get(valPositionStart + iter))) { caseId++; } @@ -548,11 +548,12 @@ public: // need to swap the weight of the point to be A-C / ((D-C) - (B-A)), // where A and C are edge0 mats 1 and 2, and B and D are edge1 mats 1 and 2. ei.Weight = vtkm::Float64(1) + - ((static_cast(curScalars[valPositionStart + edge[0]] - - newScalars[valPositionStart + edge[0]])) / - static_cast( - curScalars[valPositionStart + edge[1]] - curScalars[valPositionStart + edge[0]] + - newScalars[valPositionStart + edge[0]] - newScalars[valPositionStart + edge[1]])); + ((static_cast(curScalars.Get(valPositionStart + edge[0]) - + newScalars.Get(valPositionStart + edge[0]))) / + static_cast(curScalars.Get(valPositionStart + edge[1]) - + curScalars.Get(valPositionStart + edge[0]) + + newScalars.Get(valPositionStart + edge[0]) - + newScalars.Get(valPositionStart + edge[1]))); inCellEdgeReverseConnectivity.Set(inCellEdgeInterpIndex, inCellInterpPointIndex); inCellEdgeInterpolation.Set(inCellEdgeInterpIndex, ei); @@ -609,11 +610,12 @@ public: } ei.Weight = vtkm::Float64(1) + - ((static_cast(curScalars[valPositionStart + edge[0]] - - newScalars[valPositionStart + edge[0]])) / - static_cast( - curScalars[valPositionStart + edge[1]] - curScalars[valPositionStart + edge[0]] + - newScalars[valPositionStart + edge[0]] - newScalars[valPositionStart + edge[1]])); + ((static_cast(curScalars.Get(valPositionStart + edge[0]) - + newScalars.Get(valPositionStart + edge[0]))) / + static_cast(curScalars.Get(valPositionStart + edge[1]) - + curScalars.Get(valPositionStart + edge[0]) + + newScalars.Get(valPositionStart + edge[0]) - + newScalars.Get(valPositionStart + edge[1]))); //Add to set of new edge points //Add reverse connectivity; edgePointReverseConnectivity.Set(edgeIndex, connectivityIndex++); diff --git a/vtkm/filter/contour/worklet/contour/MarchingCells.h b/vtkm/filter/contour/worklet/contour/MarchingCells.h index 292ec8557..4f25997e1 100644 --- a/vtkm/filter/contour/worklet/contour/MarchingCells.h +++ b/vtkm/filter/contour/worklet/contour/MarchingCells.h @@ -103,7 +103,7 @@ public: vtkm::IdComponent caseNumber = 0; for (vtkm::IdComponent j = 0; j < numVerticesPerCell; ++j) { - caseNumber |= (fieldIn[j] > isovalues[i]) << j; + caseNumber |= (fieldIn[j] > isovalues.Get(i)) << j; } sum += classifyTable.GetNumTriangles(shape.Id, caseNumber); @@ -239,7 +239,7 @@ public: for (i = 0; i < numIsoValues; ++i) { - const FieldType ivalue = isovalues[i]; + const FieldType ivalue = isovalues.Get(i); // Compute the Marching Cubes case number for this cell. We need to iterate // the isovalues until the sum >= our visit index. But we need to make // sure the caseNumber is correct before stopping @@ -275,7 +275,8 @@ public: outputPointId + triVertex, vtkm::Id2(indices[edgeVertices.first], indices[edgeVertices.second])); - vtkm::FloatDefault interpolant = static_cast(isovalues[i] - fieldValue0) / + vtkm::FloatDefault interpolant = + static_cast(isovalues.Get(i) - fieldValue0) / static_cast(fieldValue1 - fieldValue0); metaData.InterpWeightsPortal.Set(outputPointId + triVertex, interpolant); @@ -448,10 +449,8 @@ public: vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom); const auto& boundary = tpn.GetBoundaryState(); - auto pointPortal = pointCoordinates.GetPortal(); - auto fieldPortal = inputField.GetPortal(); - vtkm::exec::FieldNeighborhood points(pointPortal, boundary); - vtkm::exec::FieldNeighborhood field(fieldPortal, boundary); + vtkm::exec::FieldNeighborhood points(pointCoordinates, boundary); + vtkm::exec::FieldNeighborhood field(inputField, boundary); vtkm::worklet::gradient::StructuredPointGradient gradient; gradient(boundary, points, field, normal); @@ -530,10 +529,8 @@ public: vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom); const auto& boundary = tpn.GetBoundaryState(); - auto pointPortal = pointCoordinates.GetPortal(); - auto fieldPortal = inputField.GetPortal(); - vtkm::exec::FieldNeighborhood points(pointPortal, boundary); - vtkm::exec::FieldNeighborhood field(fieldPortal, boundary); + vtkm::exec::FieldNeighborhood points(pointCoordinates, boundary); + vtkm::exec::FieldNeighborhood field(inputField, boundary); vtkm::worklet::gradient::StructuredPointGradient gradient; NormalType grad1; diff --git a/vtkm/filter/density_estimate/CMakeLists.txt b/vtkm/filter/density_estimate/CMakeLists.txt index 05209da58..bac3f2a06 100644 --- a/vtkm/filter/density_estimate/CMakeLists.txt +++ b/vtkm/filter/density_estimate/CMakeLists.txt @@ -39,12 +39,6 @@ set_property(TARGET PROPERTY UNITY_BUILD_MODE GROUP ) -target_link_libraries(vtkm_filter_density_estimate PRIVATE vtkm_worklet PUBLIC vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_density_estimate) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/density_estimate/Entropy.h b/vtkm/filter/density_estimate/Entropy.h index 60e709caf..b97e78575 100644 --- a/vtkm/filter/density_estimate/Entropy.h +++ b/vtkm/filter/density_estimate/Entropy.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_density_estimate_Entropy_h #define vtk_m_filter_density_estimate_Entropy_h -#include +#include #include namespace vtkm @@ -24,7 +24,7 @@ namespace density_estimate /// /// Construct a histogram which is used to compute the entropy with a default of 10 bins /// -class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT Entropy : public vtkm::filter::NewFilterField +class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT Entropy : public vtkm::filter::FilterField { public: //currently the Entropy filter only works on scalar data. @@ -45,11 +45,6 @@ private: vtkm::Id NumberOfBins = 10; }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::Entropy.") Entropy - : public vtkm::filter::density_estimate::Entropy -{ - using density_estimate::Entropy::Entropy; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/density_estimate/Histogram.cxx b/vtkm/filter/density_estimate/Histogram.cxx index 050a8bf1e..1c3969c84 100644 --- a/vtkm/filter/density_estimate/Histogram.cxx +++ b/vtkm/filter/density_estimate/Histogram.cxx @@ -225,7 +225,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet Histogram::DoExecutePartitions( const vtkm::cont::PartitionedDataSet& input) { this->PreExecute(input); - auto result = this->NewFilter::DoExecutePartitions(input); + auto result = this->Filter::DoExecutePartitions(input); this->PostExecute(input, result); return result; } diff --git a/vtkm/filter/density_estimate/Histogram.h b/vtkm/filter/density_estimate/Histogram.h index afd175e8e..5f7c9193a 100644 --- a/vtkm/filter/density_estimate/Histogram.h +++ b/vtkm/filter/density_estimate/Histogram.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_density_estimate_Histogram_h #define vtk_m_filter_density_estimate_Histogram_h -#include +#include #include namespace vtkm @@ -24,7 +24,7 @@ namespace density_estimate /// /// Construct a histogram with a default of 10 bins. /// -class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT Histogram : public vtkm::filter::NewFilterField +class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT Histogram : public vtkm::filter::FilterField { public: //Construct a histogram with a default of 10 bins @@ -79,11 +79,6 @@ private: bool InExecutePartitions = false; }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::Histogram.") Histogram - : public vtkm::filter::density_estimate::Histogram -{ - using density_estimate::Histogram::Histogram; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/density_estimate/NDEntropy.h b/vtkm/filter/density_estimate/NDEntropy.h index 8639de57f..efb5e2b62 100644 --- a/vtkm/filter/density_estimate/NDEntropy.h +++ b/vtkm/filter/density_estimate/NDEntropy.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_density_estimate_NDEntropy_h #define vtk_m_filter_density_estimate_NDEntropy_h -#include +#include #include namespace vtkm @@ -23,7 +23,7 @@ namespace density_estimate /// /// This filter calculate the entropy of input N-Dims fields. /// -class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT NDEntropy : public vtkm::filter::NewFilterField +class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT NDEntropy : public vtkm::filter::FilterField { public: VTKM_CONT @@ -36,11 +36,6 @@ private: std::vector FieldNames; }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::NDEntropy.") NDEntropy - : public vtkm::filter::density_estimate::NDEntropy -{ - using density_estimate::NDEntropy::NDEntropy; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/density_estimate/NDHistogram.h b/vtkm/filter/density_estimate/NDHistogram.h index 86d60be27..ee63ff4e5 100644 --- a/vtkm/filter/density_estimate/NDHistogram.h +++ b/vtkm/filter/density_estimate/NDHistogram.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_density_estimate_NDHistogram_h #define vtk_m_filter_density_estimate_NDHistogram_h -#include +#include #include namespace vtkm @@ -31,7 +31,7 @@ namespace density_estimate /// The first three numbers are binIDs for FieldA, FieldB and FieldC. Frequency[i] stores /// the frequency for this bin (FieldA[i], FieldB[i], FieldC[i]). /// -class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT NDHistogram : public vtkm::filter::NewFilterField +class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT NDHistogram : public vtkm::filter::FilterField { public: VTKM_CONT @@ -56,11 +56,6 @@ private: std::vector DataRanges; //Min Max of the field }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::NDHistogram.") NDHistogram - : public vtkm::filter::density_estimate::NDHistogram -{ - using density_estimate::NDHistogram::NDHistogram; -}; } // namespace filter } // namespace vtm diff --git a/vtkm/filter/density_estimate/ParticleDensityBase.h b/vtkm/filter/density_estimate/ParticleDensityBase.h index 4ad69b04f..dd7544d4d 100644 --- a/vtkm/filter/density_estimate/ParticleDensityBase.h +++ b/vtkm/filter/density_estimate/ParticleDensityBase.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_density_estimate_ParticleDensityBase_h #define vtk_m_filter_density_estimate_ParticleDensityBase_h -#include +#include #include namespace vtkm @@ -20,7 +20,7 @@ namespace filter { namespace density_estimate { -class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityBase : public vtkm::filter::NewFilterField +class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityBase : public vtkm::filter::FilterField { protected: ParticleDensityBase() = default; diff --git a/vtkm/filter/density_estimate/ParticleDensityCloudInCell.cxx b/vtkm/filter/density_estimate/ParticleDensityCloudInCell.cxx index 3a5b7ce94..94e184e42 100644 --- a/vtkm/filter/density_estimate/ParticleDensityCloudInCell.cxx +++ b/vtkm/filter/density_estimate/ParticleDensityCloudInCell.cxx @@ -72,21 +72,6 @@ namespace filter { namespace density_estimate { -VTKM_CONT ParticleDensityCloudInCell::ParticleDensityCloudInCell(const vtkm::Id3& dimension, - const vtkm::Vec3f& origin, - const vtkm::Vec3f& spacing) -{ - this->SetDimension(dimension); - this->SetOrigin(origin); - this->SetSpacing(spacing); -} - -VTKM_CONT ParticleDensityCloudInCell::ParticleDensityCloudInCell(const Id3& dimension, - const vtkm::Bounds& bounds) -{ - this->SetDimension(dimension); - this->SetBounds(bounds); -} VTKM_CONT vtkm::cont::DataSet ParticleDensityCloudInCell::DoExecute(const cont::DataSet& input) { diff --git a/vtkm/filter/density_estimate/ParticleDensityCloudInCell.h b/vtkm/filter/density_estimate/ParticleDensityCloudInCell.h index 0383b5e9d..10e02c192 100644 --- a/vtkm/filter/density_estimate/ParticleDensityCloudInCell.h +++ b/vtkm/filter/density_estimate/ParticleDensityCloudInCell.h @@ -11,7 +11,6 @@ #ifndef vtk_m_filter_density_estimate_ParticleDensityCIC_h #define vtk_m_filter_density_estimate_ParticleDensityCIC_h -#include #include namespace vtkm @@ -43,23 +42,10 @@ public: ParticleDensityCloudInCell() = default; - VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.") - ParticleDensityCloudInCell(const vtkm::Id3& dimension, - const vtkm::Vec3f& origin, - const vtkm::Vec3f& spacing); - - VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.") - ParticleDensityCloudInCell(const Id3& dimension, const vtkm::Bounds& bounds); - private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::ParticleDensityCloudInCell.") - ParticleDensityCloudInCell : public vtkm::filter::density_estimate::ParticleDensityCloudInCell -{ - using density_estimate::ParticleDensityCloudInCell::ParticleDensityCloudInCell; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.cxx b/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.cxx index 4b8f41235..c51242b4a 100644 --- a/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.cxx +++ b/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.cxx @@ -54,23 +54,6 @@ namespace filter { namespace density_estimate { -VTKM_CONT ParticleDensityNearestGridPoint::ParticleDensityNearestGridPoint( - const vtkm::Id3& dimension, - const vtkm::Vec3f& origin, - const vtkm::Vec3f& spacing) -{ - this->SetDimension(dimension); - this->SetOrigin(origin); - this->SetSpacing(spacing); -} - -VTKM_CONT ParticleDensityNearestGridPoint::ParticleDensityNearestGridPoint( - const Id3& dimension, - const vtkm::Bounds& bounds) -{ - this->SetDimension(dimension); - this->SetBounds(bounds); -} VTKM_CONT vtkm::cont::DataSet ParticleDensityNearestGridPoint::DoExecute( const vtkm::cont::DataSet& input) @@ -100,7 +83,7 @@ VTKM_CONT vtkm::cont::DataSet ParticleDensityNearestGridPoint::DoExecute( // We create an ArrayHandle and pass it to the Worklet as AtomicArrayInOut. // However, the ArrayHandle needs to be allocated and initialized first. vtkm::cont::ArrayHandle density; - density.AllocateAndFill(uniform.GetNumberOfPoints(), 0); + density.AllocateAndFill(uniform.GetNumberOfCells(), 0); this->Invoke(vtkm::worklet::NGPWorklet{}, coords, concrete, locator, density); diff --git a/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.h b/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.h index a44ebdb6c..c064080d9 100644 --- a/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.h +++ b/vtkm/filter/density_estimate/ParticleDensityNearestGridPoint.h @@ -42,24 +42,10 @@ public: ParticleDensityNearestGridPoint() = default; - VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.") - ParticleDensityNearestGridPoint(const vtkm::Id3& dimension, - const vtkm::Vec3f& origin, - const vtkm::Vec3f& spacing); - - VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.") - ParticleDensityNearestGridPoint(const vtkm::Id3& dimension, const vtkm::Bounds& bounds); - private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace density_estimate -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::density_estimate::ParticleDensityNearestGridPoint.") - ParticleDensityNearestGridPoint - : public vtkm::filter::density_estimate::ParticleDensityNearestGridPoint -{ - using density_estimate::ParticleDensityNearestGridPoint::ParticleDensityNearestGridPoint; -}; } // namespace filter } // namespace vtkm #endif //vtk_m_filter_density_estimate_ParticleDensityNGP_h diff --git a/vtkm/filter/density_estimate/testing/UnitTestEntropyFilter.cxx b/vtkm/filter/density_estimate/testing/UnitTestEntropyFilter.cxx index 7e3f06f15..569b4f78a 100644 --- a/vtkm/filter/density_estimate/testing/UnitTestEntropyFilter.cxx +++ b/vtkm/filter/density_estimate/testing/UnitTestEntropyFilter.cxx @@ -20,8 +20,8 @@ namespace void TestEntropy() { ///// make a data set ///// - vtkm::Id3 dims(32, 32, 32); - vtkm::source::Tangle tangle(dims); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions({ 32, 32, 32 }); vtkm::cont::DataSet dataSet = tangle.Execute(); vtkm::filter::density_estimate::Entropy entropyFilter; diff --git a/vtkm/filter/density_estimate/vtkm.module b/vtkm/filter/density_estimate/vtkm.module new file mode 100644 index 000000000..2bdced389 --- /dev/null +++ b/vtkm/filter/density_estimate/vtkm.module @@ -0,0 +1,11 @@ +NAME + vtkm_filter_density_estimate +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_density_estimate + vtkm_source diff --git a/vtkm/filter/entity_extraction/CMakeLists.txt b/vtkm/filter/entity_extraction/CMakeLists.txt index cd350b19f..68ae81317 100644 --- a/vtkm/filter/entity_extraction/CMakeLists.txt +++ b/vtkm/filter/entity_extraction/CMakeLists.txt @@ -37,12 +37,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_entity_extraction PRIVATE vtkm_worklet vtkm_filter_clean_grid PUBLIC vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_entity_extraction) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/entity_extraction/ExternalFaces.cxx b/vtkm/filter/entity_extraction/ExternalFaces.cxx index d5711c6da..9c2d4a527 100644 --- a/vtkm/filter/entity_extraction/ExternalFaces.cxx +++ b/vtkm/filter/entity_extraction/ExternalFaces.cxx @@ -60,7 +60,7 @@ vtkm::cont::DataSet ExternalFaces::GenerateOutput(const vtkm::cont::DataSet& inp // New Design: We are still using the old MapFieldOntoOutput to demonstrate the transition this->MapFieldOntoOutput(result, f); }; - return this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper); + return this->CreateResult(input, outCellSet, mapper); } //----------------------------------------------------------------------------- diff --git a/vtkm/filter/entity_extraction/ExternalFaces.h b/vtkm/filter/entity_extraction/ExternalFaces.h index 79f6d03b4..ad7ea9991 100644 --- a/vtkm/filter/entity_extraction/ExternalFaces.h +++ b/vtkm/filter/entity_extraction/ExternalFaces.h @@ -11,7 +11,7 @@ #ifndef vtkm_filter_entity_extraction_ExternalFaces_h #define vtkm_filter_entity_extraction_ExternalFaces_h -#include +#include #include namespace vtkm @@ -32,7 +32,7 @@ namespace entity_extraction /// @warning /// This filter is currently only supports propagation of point properties /// -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExternalFaces : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExternalFaces : public vtkm::filter::FilterField { public: ExternalFaces(); @@ -76,11 +76,6 @@ private: std::unique_ptr Worklet; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::ExternalFaces.") ExternalFaces - : public vtkm::filter::entity_extraction::ExternalFaces -{ - using entity_extraction::ExternalFaces::ExternalFaces; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/ExtractGeometry.cxx b/vtkm/filter/entity_extraction/ExtractGeometry.cxx index 9361c115f..4e2d0229d 100644 --- a/vtkm/filter/entity_extraction/ExtractGeometry.cxx +++ b/vtkm/filter/entity_extraction/ExtractGeometry.cxx @@ -70,7 +70,7 @@ vtkm::cont::DataSet ExtractGeometry::DoExecute(const vtkm::cont::DataSet& input) // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - return this->CreateResult(input, outCells, input.GetCoordinateSystems(), mapper); + return this->CreateResult(input, outCells, mapper); } } // namespace entity_extraction diff --git a/vtkm/filter/entity_extraction/ExtractGeometry.h b/vtkm/filter/entity_extraction/ExtractGeometry.h index 0afbd0d11..468f3c84b 100644 --- a/vtkm/filter/entity_extraction/ExtractGeometry.h +++ b/vtkm/filter/entity_extraction/ExtractGeometry.h @@ -12,7 +12,7 @@ #define vtk_m_fulter_entity_extraction_ExtractGeometry_h #include -#include +#include #include namespace vtkm @@ -36,7 +36,7 @@ namespace entity_extraction /// This differs from Clip in that Clip will subdivide boundary cells into new /// cells, while this filter will not, producing a more 'crinkly' output. /// -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractGeometry : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractGeometry : public vtkm::filter::FilterField { public: // Set the volume of interest to extract @@ -81,11 +81,6 @@ private: vtkm::ImplicitFunctionGeneral Function; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::ExtractGeometry.") ExtractGeometry - : public vtkm::filter::entity_extraction::ExtractGeometry -{ - using entity_extraction::ExtractGeometry::ExtractGeometry; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/ExtractPoints.cxx b/vtkm/filter/entity_extraction/ExtractPoints.cxx index 4f0c95d50..25648b383 100644 --- a/vtkm/filter/entity_extraction/ExtractPoints.cxx +++ b/vtkm/filter/entity_extraction/ExtractPoints.cxx @@ -59,8 +59,7 @@ vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& input) // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); }; - vtkm::cont::DataSet output = - this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper); + vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper); // compact the unused points in the output dataset if (this->CompactPoints) diff --git a/vtkm/filter/entity_extraction/ExtractPoints.h b/vtkm/filter/entity_extraction/ExtractPoints.h index 9b2a454c1..3af0f13be 100644 --- a/vtkm/filter/entity_extraction/ExtractPoints.h +++ b/vtkm/filter/entity_extraction/ExtractPoints.h @@ -13,11 +13,7 @@ #include -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#include -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -#include +#include #include namespace vtkm @@ -35,7 +31,7 @@ namespace entity_extraction /// Note that while any geometry type can be provided as input, the output is /// represented by an explicit representation of points using /// vtkm::cont::CellSetSingleType -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractPoints : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractPoints : public vtkm::filter::FilterField { public: /// When CompactPoints is set, instead of copying the points and point fields @@ -69,11 +65,6 @@ private: bool CompactPoints = false; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::ExtractPoints.") ExtractPoints - : public vtkm::filter::entity_extraction::ExtractPoints -{ - using entity_extraction::ExtractPoints::ExtractPoints; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/ExtractStructured.cxx b/vtkm/filter/entity_extraction/ExtractStructured.cxx index 399ab9b3e..a1962fb51 100644 --- a/vtkm/filter/entity_extraction/ExtractStructured.cxx +++ b/vtkm/filter/entity_extraction/ExtractStructured.cxx @@ -15,27 +15,45 @@ namespace { -VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result, +VTKM_CONT void DoMapField(vtkm::cont::DataSet& result, const vtkm::cont::Field& field, const vtkm::cont::ArrayHandle& CellFieldMap, - const vtkm::cont::ArrayHandle& PointFieldMap) + const vtkm::cont::ArrayHandle& PointFieldMap, + const vtkm::worklet::ExtractStructured& worklet) { if (field.IsPointField()) { - return vtkm::filter::MapFieldPermutation(field, PointFieldMap, result); + vtkm::cont::UnknownArrayHandle array = field.GetData(); + using UniformCoordinatesArrayHandle = + vtkm::worklet::ExtractStructured::UniformCoordinatesArrayHandle; + using RectilinearCoordinatesArrayHandle = + vtkm::worklet::ExtractStructured::RectilinearCoordinatesArrayHandle; + if (array.CanConvert()) + { + // Special case that is more efficient for uniform coordinate arrays. + UniformCoordinatesArrayHandle newCoords = + worklet.MapCoordinatesUniform(array.AsArrayHandle()); + result.AddField(vtkm::cont::Field(field.GetName(), field.GetAssociation(), newCoords)); + } + else if (array.CanConvert()) + { + // Special case that is more efficient for uniform coordinate arrays. + RectilinearCoordinatesArrayHandle newCoords = + worklet.MapCoordinatesRectilinear(array.AsArrayHandle()); + result.AddField(vtkm::cont::Field(field.GetName(), field.GetAssociation(), newCoords)); + } + else + { + vtkm::filter::MapFieldPermutation(field, PointFieldMap, result); + } } else if (field.IsCellField()) { - return vtkm::filter::MapFieldPermutation(field, CellFieldMap, result); + vtkm::filter::MapFieldPermutation(field, CellFieldMap, result); } else if (field.IsWholeDataSetField()) { result.AddField(field); - return true; - } - else - { - return false; } } } // anonymous namespace @@ -50,7 +68,6 @@ namespace entity_extraction vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& input) { const vtkm::cont::UnknownCellSet& cells = input.GetCellSet(); - const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem(); vtkm::worklet::ExtractStructured worklet; auto cellset = worklet.Run(cells.ResetCellSetList(), @@ -59,9 +76,6 @@ vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& inpu this->IncludeBoundary, this->IncludeOffset); - auto coords = worklet.MapCoordinates(coordinates); - vtkm::cont::CoordinateSystem outputCoordinates(coordinates.GetName(), coords); - // Create map arrays for mapping fields. Could potentially save some time to first check to see // if these arrays would be used. auto CellFieldMap = @@ -70,9 +84,9 @@ vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& inpu worklet.ProcessPointField(vtkm::cont::ArrayHandleIndex(input.GetNumberOfPoints())); auto mapper = [&](auto& result, const auto& f) { - DoMapField(result, f, CellFieldMap, PointFieldMap); + DoMapField(result, f, CellFieldMap, PointFieldMap, worklet); }; - return this->CreateResult(input, cellset, outputCoordinates, mapper); + return this->CreateResult(input, cellset, mapper); } } // namespace entity_extraction diff --git a/vtkm/filter/entity_extraction/ExtractStructured.h b/vtkm/filter/entity_extraction/ExtractStructured.h index d00d8d558..b4f1599d2 100644 --- a/vtkm/filter/entity_extraction/ExtractStructured.h +++ b/vtkm/filter/entity_extraction/ExtractStructured.h @@ -12,7 +12,7 @@ #define vtk_m_filter_entity_extraction_ExtractStructured_h #include -#include +#include #include namespace vtkm @@ -37,7 +37,7 @@ namespace entity_extraction /// for image processing, subsampling large volumes to reduce data size, or /// extracting regions of a volume with interesting data. /// -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractStructured : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ExtractStructured : public vtkm::filter::FilterField { public: // Set the bounding box for the volume of interest @@ -92,12 +92,6 @@ private: }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, - "Use vtkm::filter::entity_extraction::ExtractStructured.") ExtractStructured - : public vtkm::filter::entity_extraction::ExtractStructured -{ - using entity_extraction::ExtractStructured::ExtractStructured; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/GhostCellRemove.cxx b/vtkm/filter/entity_extraction/GhostCellRemove.cxx index 778626ded..1d6a8ffb7 100644 --- a/vtkm/filter/entity_extraction/GhostCellRemove.cxx +++ b/vtkm/filter/entity_extraction/GhostCellRemove.cxx @@ -317,7 +317,9 @@ VTKM_CONT GhostCellRemove::GhostCellRemove() VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(const vtkm::cont::DataSet& input) { const vtkm::cont::UnknownCellSet& cells = input.GetCellSet(); - const auto& field = this->GetFieldFromDataSet(input); + const vtkm::cont::Field& field = + (this->GetUseGhostCellsAsField() ? input.GetGhostCellField() + : this->GetFieldFromDataSet(input)); vtkm::cont::ArrayHandle fieldArray; vtkm::cont::ArrayCopyShallowIfPossible(field.GetData(), fieldArray); @@ -365,7 +367,7 @@ VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(const vtkm::cont::DataS } auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper); + return this->CreateResult(input, cellOut, mapper); } } diff --git a/vtkm/filter/entity_extraction/GhostCellRemove.h b/vtkm/filter/entity_extraction/GhostCellRemove.h index 11fbdb718..29fcd161f 100644 --- a/vtkm/filter/entity_extraction/GhostCellRemove.h +++ b/vtkm/filter/entity_extraction/GhostCellRemove.h @@ -12,7 +12,7 @@ #define vtk_m_filter_entity_extraction_GhostCellRemove_h #include -#include +#include #include namespace vtkm @@ -23,7 +23,7 @@ namespace entity_extraction { /// \brief Removes ghost cells /// -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT GhostCellRemove : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT GhostCellRemove : public vtkm::filter::FilterField { public: VTKM_CONT @@ -44,6 +44,11 @@ public: VTKM_CONT bool GetRemoveAllGhost() const { return this->RemoveAll; } + VTKM_CONT + bool GetUseGhostCellsAsField() const { return this->UseGhostCellsAsField; } + VTKM_CONT + void SetUseGhostCellsAsField(bool flag) { this->UseGhostCellsAsField = flag; } + VTKM_CONT bool GetRemoveByType() const { return !this->RemoveAll; } VTKM_CONT @@ -53,17 +58,13 @@ private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; + bool UseGhostCellsAsField = true; bool RemoveAll = false; bool RemoveField = false; vtkm::UInt8 RemoveVals = 0; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::GhostCellRemove.") GhostCellRemove - : public vtkm::filter::entity_extraction::GhostCellRemove -{ - using entity_extraction::GhostCellRemove::GhostCellRemove; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/Mask.cxx b/vtkm/filter/entity_extraction/Mask.cxx index 44dc79b19..b7f89d467 100644 --- a/vtkm/filter/entity_extraction/Mask.cxx +++ b/vtkm/filter/entity_extraction/Mask.cxx @@ -51,7 +51,7 @@ VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet& input) // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper); + return this->CreateResult(input, cellOut, mapper); } } // namespace entity_extraction } // namespace filter diff --git a/vtkm/filter/entity_extraction/Mask.h b/vtkm/filter/entity_extraction/Mask.h index 4e7117d10..ea3f91be2 100644 --- a/vtkm/filter/entity_extraction/Mask.h +++ b/vtkm/filter/entity_extraction/Mask.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_entity_extraction_Mask_h #define vtk_m_filter_entity_extraction_Mask_h -#include +#include #include namespace vtkm @@ -23,7 +23,7 @@ namespace entity_extraction /// \brief Subselect cells using a stride /// /// Extract only every Nth cell where N is equal to a stride value -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT Mask : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT Mask : public vtkm::filter::FilterField { public: // When CompactPoints is set, instead of copying the points and point fields @@ -47,11 +47,6 @@ private: bool CompactPoints = false; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::Mask.") Mask - : public vtkm::filter::entity_extraction::Mask -{ - using entity_extraction::Mask::Mask; -}; } // namespace filter } // namespace vtk diff --git a/vtkm/filter/entity_extraction/MaskPoints.cxx b/vtkm/filter/entity_extraction/MaskPoints.cxx index 564656f3e..7b8f977d7 100644 --- a/vtkm/filter/entity_extraction/MaskPoints.cxx +++ b/vtkm/filter/entity_extraction/MaskPoints.cxx @@ -56,8 +56,7 @@ VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(const vtkm::cont::DataSet& i // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); }; - vtkm::cont::DataSet output = - this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper); + vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper); // compact the unused points in the output dataset if (this->CompactPoints) diff --git a/vtkm/filter/entity_extraction/MaskPoints.h b/vtkm/filter/entity_extraction/MaskPoints.h index 682e16346..8c0c13803 100644 --- a/vtkm/filter/entity_extraction/MaskPoints.h +++ b/vtkm/filter/entity_extraction/MaskPoints.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_entity_extraction_MaskPoints_h #define vtk_m_filter_entity_extraction_MaskPoints_h -#include +#include #include namespace vtkm @@ -23,7 +23,7 @@ namespace entity_extraction /// \brief Subselect points using a stride /// /// Extract only every Nth point where N is equal to a stride value -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT MaskPoints : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT MaskPoints : public vtkm::filter::FilterField { public: // When CompactPoints is set, instead of copying the points and point fields @@ -46,11 +46,6 @@ private: bool CompactPoints = true; }; } // namespace eneity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::MaskPoints.") MaskPoints - : public vtkm::filter::entity_extraction::MaskPoints -{ - using entity_extraction::MaskPoints::MaskPoints; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/Threshold.cxx b/vtkm/filter/entity_extraction/Threshold.cxx index 8a86c5a8a..1d3c5765a 100644 --- a/vtkm/filter/entity_extraction/Threshold.cxx +++ b/vtkm/filter/entity_extraction/Threshold.cxx @@ -148,7 +148,7 @@ vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input) vtkm::ListForEach(callWithArrayBaseComponent, vtkm::TypeListScalarAll{}); auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper); + return this->CreateResult(input, cellOut, mapper); } } // namespace entity_extraction } // namespace filter diff --git a/vtkm/filter/entity_extraction/Threshold.h b/vtkm/filter/entity_extraction/Threshold.h index bd3faed1d..3542249cb 100644 --- a/vtkm/filter/entity_extraction/Threshold.h +++ b/vtkm/filter/entity_extraction/Threshold.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_entity_extraction_Threshold_h #define vtk_m_filter_entity_extraction_Threshold_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace entity_extraction /// The output of this filter is an permutation of the input dataset. /// /// You can threshold either on point or cell fields -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT Threshold : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT Threshold : public vtkm::filter::FilterField { public: VTKM_CONT @@ -103,11 +103,6 @@ private: bool Invert = false; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::Threshold.") Threshold - : public vtkm::filter::entity_extraction::Threshold -{ - using entity_extraction::Threshold::Threshold; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/ThresholdPoints.cxx b/vtkm/filter/entity_extraction/ThresholdPoints.cxx index 173e4af3d..ecceddc0a 100644 --- a/vtkm/filter/entity_extraction/ThresholdPoints.cxx +++ b/vtkm/filter/entity_extraction/ThresholdPoints.cxx @@ -174,8 +174,7 @@ VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(const vtkm::cont::DataS // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); }; - vtkm::cont::DataSet output = - this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper); + vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper); // compact the unused points in the output dataset if (this->CompactPoints) diff --git a/vtkm/filter/entity_extraction/ThresholdPoints.h b/vtkm/filter/entity_extraction/ThresholdPoints.h index 0fd7f8777..fa38df409 100644 --- a/vtkm/filter/entity_extraction/ThresholdPoints.h +++ b/vtkm/filter/entity_extraction/ThresholdPoints.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_entity_extraction_ThresholdPoints_h #define vtk_m_filter_entity_extraction_ThresholdPoints_h -#include +#include #include namespace vtkm @@ -20,7 +20,7 @@ namespace filter { namespace entity_extraction { -class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ThresholdPoints : public vtkm::filter::NewFilterField +class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT ThresholdPoints : public vtkm::filter::FilterField { public: // When CompactPoints is set, instead of copying the points and point fields @@ -62,11 +62,6 @@ private: bool CompactPoints = false; }; } // namespace entity_extraction -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::ThresholdPoints.") ThresholdPoints - : public vtkm::filter::entity_extraction::ThresholdPoints -{ - using entity_extraction::ThresholdPoints::ThresholdPoints; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/entity_extraction/testing/UnitTestGhostCellRemove.cxx b/vtkm/filter/entity_extraction/testing/UnitTestGhostCellRemove.cxx index c05912251..42ac24b7f 100644 --- a/vtkm/filter/entity_extraction/testing/UnitTestGhostCellRemove.cxx +++ b/vtkm/filter/entity_extraction/testing/UnitTestGhostCellRemove.cxx @@ -84,6 +84,7 @@ vtkm::cont::DataSet MakeUniform(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK, int numLayers, + std::string& ghostName, bool addMidGhost = false) { vtkm::cont::DataSet ds; @@ -94,8 +95,14 @@ vtkm::cont::DataSet MakeUniform(vtkm::Id numI, ds = vtkm::cont::DataSetBuilderUniform::Create(vtkm::Id3(numI + 1, numJ + 1, numK + 1)); auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost); - ds.AddGhostCellField(ghosts); - + if (ghostName == "default") + { + ds.SetGhostCellField(ghosts); + } + else + { + ds.SetGhostCellField(ghostName, ghosts); + } return ds; } @@ -103,6 +110,7 @@ vtkm::cont::DataSet MakeRectilinear(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK, int numLayers, + std::string& ghostName, bool addMidGhost = false) { vtkm::cont::DataSet ds; @@ -128,7 +136,14 @@ vtkm::cont::DataSet MakeRectilinear(vtkm::Id numI, auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost); - ds.AddGhostCellField(ghosts); + if (ghostName == "default") + { + ds.SetGhostCellField(ghosts); + } + else + { + ds.SetGhostCellField(ghostName, ghosts); + } return ds; } @@ -164,11 +179,15 @@ static void MakeExplicitCells(const CellSetType& cellSet, } } -vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK, int numLayers) +vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, + vtkm::Id numJ, + vtkm::Id numK, + int numLayers, + std::string& ghostName) { using CoordType = vtkm::Vec3f_32; - vtkm::cont::DataSet dsUniform = MakeUniform(numI, numJ, numK, numLayers); + vtkm::cont::DataSet dsUniform = MakeUniform(numI, numJ, numK, numLayers, ghostName); auto coordData = dsUniform.GetCoordinateSystem(0).GetDataAsMultiplexer(); vtkm::Id numPts = coordData.GetNumberOfValues(); @@ -205,7 +224,14 @@ vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK, in auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers); - ds.AddGhostCellField(ghosts); + if (ghostName == "default") + { + ds.SetGhostCellField(ghosts); + } + else + { + ds.SetGhostCellField(ghostName, ghosts); + } return ds; } @@ -235,70 +261,74 @@ void TestGhostCellRemove() std::vector dsTypes = { "uniform", "rectilinear", "explicit" }; for (auto& dsType : dsTypes) { - vtkm::cont::DataSet ds; - if (dsType == "uniform") - ds = MakeUniform(nx, ny, nz, layer); - else if (dsType == "rectilinear") - ds = MakeRectilinear(nx, ny, nz, layer); - else if (dsType == "explicit") - ds = MakeExplicit(nx, ny, nz, layer); - - std::vector removeType = { "all", "byType" }; - for (auto& rt : removeType) + std::vector nameTypes = { "default", "user-specified" }; + for (auto& nameType : nameTypes) { - vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval; - ghostCellRemoval.RemoveGhostField(); + vtkm::cont::DataSet ds; + if (dsType == "uniform") + ds = MakeUniform(nx, ny, nz, layer, nameType); + else if (dsType == "rectilinear") + ds = MakeRectilinear(nx, ny, nz, layer, nameType); + else if (dsType == "explicit") + ds = MakeExplicit(nx, ny, nz, layer, nameType); - if (rt == "all") - ghostCellRemoval.RemoveAllGhost(); - else if (rt == "byType") - ghostCellRemoval.RemoveByType(vtkm::CellClassification::Ghost); - - auto output = ghostCellRemoval.Execute(ds); - vtkm::Id numCells = output.GetNumberOfCells(); - - //Validate the output. - - vtkm::Id numCellsReq = (nx - 2 * layer) * (ny - 2 * layer); - if (nz != 0) - numCellsReq *= (nz - 2 * layer); - - VTKM_TEST_ASSERT(numCellsReq == numCells, "Wrong number of cells in output"); - if (dsType == "uniform" || dsType == "rectilinear") + std::vector removeType = { "all", "byType" }; + for (auto& rt : removeType) { - if (nz == 0) + vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval; + ghostCellRemoval.RemoveGhostField(); + + if (rt == "all") + ghostCellRemoval.RemoveAllGhost(); + else if (rt == "byType") + ghostCellRemoval.RemoveByType(vtkm::CellClassification::Ghost); + + auto output = ghostCellRemoval.Execute(ds); + vtkm::Id numCells = output.GetNumberOfCells(); + + //Validate the output. + + vtkm::Id numCellsReq = (nx - 2 * layer) * (ny - 2 * layer); + if (nz != 0) + numCellsReq *= (nz - 2 * layer); + + VTKM_TEST_ASSERT(numCellsReq == numCells, "Wrong number of cells in output"); + if (dsType == "uniform" || dsType == "rectilinear") { - VTKM_TEST_ASSERT(output.GetCellSet().CanConvert>(), - "Wrong cell type for explicit conversion"); + if (nz == 0) + { + VTKM_TEST_ASSERT(output.GetCellSet().CanConvert>(), + "Wrong cell type for explicit conversion"); + } + else if (nz > 0) + { + VTKM_TEST_ASSERT(output.GetCellSet().CanConvert>(), + "Wrong cell type for explicit conversion"); + } } - else if (nz > 0) + else { - VTKM_TEST_ASSERT(output.GetCellSet().CanConvert>(), + VTKM_TEST_ASSERT(output.GetCellSet().IsType>(), "Wrong cell type for explicit conversion"); } } - else + + // For structured, test the case where we have a ghost in the 'middle' of the cells. + // This will produce an explicit cellset. + if (dsType == "uniform" || dsType == "rectilinear") { + if (dsType == "uniform") + ds = MakeUniform(nx, ny, nz, layer, nameType, true); + else if (dsType == "rectilinear") + ds = MakeRectilinear(nx, ny, nz, layer, nameType, true); + + vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval; + ghostCellRemoval.RemoveGhostField(); + auto output = ghostCellRemoval.Execute(ds); VTKM_TEST_ASSERT(output.GetCellSet().IsType>(), "Wrong cell type for explicit conversion"); } } - - // For structured, test the case where we have a ghost in the 'middle' of the cells. - // This will produce an explicit cellset. - if (dsType == "uniform" || dsType == "rectilinear") - { - if (dsType == "uniform") - ds = MakeUniform(nx, ny, nz, layer, true); - else if (dsType == "rectilinear") - ds = MakeRectilinear(nx, ny, nz, layer, true); - - vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval; - ghostCellRemoval.RemoveGhostField(); - auto output = ghostCellRemoval.Execute(ds); - VTKM_TEST_ASSERT(output.GetCellSet().IsType>(), - "Wrong cell type for explicit conversion"); - } } } } diff --git a/vtkm/filter/entity_extraction/testing/UnitTestThresholdFilter.cxx b/vtkm/filter/entity_extraction/testing/UnitTestThresholdFilter.cxx index 8ace0db57..9ade1efb0 100644 --- a/vtkm/filter/entity_extraction/testing/UnitTestThresholdFilter.cxx +++ b/vtkm/filter/entity_extraction/testing/UnitTestThresholdFilter.cxx @@ -49,7 +49,7 @@ public: if (returnAllInRange) { - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; @@ -61,7 +61,7 @@ public: } else { - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; @@ -105,7 +105,7 @@ public: if (returnAllInRange) { - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; @@ -119,7 +119,7 @@ public: } else { - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; @@ -150,7 +150,7 @@ public: threshold.SetFieldsToPass("cellvar"); auto output = threshold.Execute(dataset); - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; @@ -180,7 +180,7 @@ public: threshold.SetFieldsToPass("cellvar"); auto output = threshold.Execute(dataset); - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); vtkm::cont::ArrayHandle cellFieldArray; diff --git a/vtkm/filter/entity_extraction/testing/UnitTestThresholdPointsFilter.cxx b/vtkm/filter/entity_extraction/testing/UnitTestThresholdPointsFilter.cxx index 2a7b7eeaa..3c751b99b 100644 --- a/vtkm/filter/entity_extraction/testing/UnitTestThresholdPointsFilter.cxx +++ b/vtkm/filter/entity_extraction/testing/UnitTestThresholdPointsFilter.cxx @@ -97,7 +97,7 @@ public: thresholdPoints.SetActiveField("pointvar"); thresholdPoints.SetFieldsToPass("pointvar"); auto output = thresholdPoints.Execute(dataset); - VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1, + VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2, "Wrong number of fields in the output dataset"); VTKM_TEST_ASSERT(test_equal(output.GetNumberOfCells(), 0), "Wrong result for ThresholdPoints"); } diff --git a/vtkm/filter/entity_extraction/vtkm.module b/vtkm/filter/entity_extraction/vtkm.module new file mode 100644 index 000000000..3a5796efb --- /dev/null +++ b/vtkm/filter/entity_extraction/vtkm.module @@ -0,0 +1,13 @@ +NAME + vtkm_filter_entity_extraction +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core + vtkm_filter_clean_grid +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_clean_grid + vtkm_filter_entity_extraction diff --git a/vtkm/filter/entity_extraction/worklet/ExtractStructured.h b/vtkm/filter/entity_extraction/worklet/ExtractStructured.h index 50b46aef8..f312422cd 100644 --- a/vtkm/filter/entity_extraction/worklet/ExtractStructured.h +++ b/vtkm/filter/entity_extraction/worklet/ExtractStructured.h @@ -415,7 +415,6 @@ public: return output; } -private: using UniformCoordinatesArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates; using RectilinearCoordinatesArrayHandle = @@ -424,7 +423,8 @@ private: vtkm::cont::ArrayHandle>; - UniformCoordinatesArrayHandle MapCoordinatesUniform(const UniformCoordinatesArrayHandle& coords) + UniformCoordinatesArrayHandle MapCoordinatesUniform( + const UniformCoordinatesArrayHandle& coords) const { using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates; using CoordType = CoordsArray::ValueType; @@ -444,7 +444,7 @@ private: } RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear( - const RectilinearCoordinatesArrayHandle& coords) + const RectilinearCoordinatesArrayHandle& coords) const { // For structured datasets, the cellsets are of different types based on // its dimensionality, but the coordinates are always 3 dimensional. @@ -479,41 +479,6 @@ private: return vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]); } - struct MapCoordinatesFunctor - { - template - VTKM_CONT void operator()(const vtkm::cont::ArrayHandle& coords, - ExtractStructured& self, - vtkm::cont::UnknownArrayHandle& output) const - { - output = self.ProcessPointField(coords); - } - - VTKM_CONT void operator()(const UniformCoordinatesArrayHandle::Superclass& coords, - ExtractStructured& self, - vtkm::cont::UnknownArrayHandle& output) const - { - output = self.MapCoordinatesUniform(coords); - } - - VTKM_CONT void operator()(const RectilinearCoordinatesArrayHandle::Superclass& coords, - ExtractStructured& self, - vtkm::cont::UnknownArrayHandle& output) const - { - output = self.MapCoordinatesRectilinear(coords); - } - }; - - friend MapCoordinatesFunctor; - -public: - vtkm::cont::UnknownArrayHandle MapCoordinates(const vtkm::cont::CoordinateSystem& coordinates) - { - vtkm::cont::UnknownArrayHandle output; - vtkm::cont::CastAndCall(coordinates, MapCoordinatesFunctor{}, *this, output); - return output; - } - public: template vtkm::cont::ArrayHandle ProcessPointField( diff --git a/vtkm/filter/field_conversion/CMakeLists.txt b/vtkm/filter/field_conversion/CMakeLists.txt index c667a9c92..35c2b5384 100644 --- a/vtkm/filter/field_conversion/CMakeLists.txt +++ b/vtkm/filter/field_conversion/CMakeLists.txt @@ -23,12 +23,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_field_conversion PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_field_conversion) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/field_conversion/CellAverage.h b/vtkm/filter/field_conversion/CellAverage.h index 33b1cf02b..d231a41c4 100644 --- a/vtkm/filter/field_conversion/CellAverage.h +++ b/vtkm/filter/field_conversion/CellAverage.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_conversion_CellAverage_h #define vtk_m_filter_field_conversion_CellAverage_h -#include +#include #include namespace vtkm @@ -27,17 +27,12 @@ namespace field_conversion /// The method of transformation is based on averaging the data /// values of all points used by particular cell. /// -class VTKM_FILTER_FIELD_CONVERSION_EXPORT CellAverage : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_CONVERSION_EXPORT CellAverage : public vtkm::filter::FilterField { private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace field_conversion -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_conversion::CellAverage.") CellAverage - : public vtkm::filter::field_conversion::CellAverage -{ - using field_conversion::CellAverage::CellAverage; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_conversion/PointAverage.h b/vtkm/filter/field_conversion/PointAverage.h index d66bc41cc..0258a3b26 100644 --- a/vtkm/filter/field_conversion/PointAverage.h +++ b/vtkm/filter/field_conversion/PointAverage.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_conversion_PointAverage_h #define vtk_m_filter_field_conversion_PointAverage_h -#include +#include #include namespace vtkm @@ -26,17 +26,12 @@ namespace field_conversion /// specified per cell) into point data (i.e., data specified at cell /// points). The method of transformation is based on averaging the data /// values of all cells using a particular point. -class VTKM_FILTER_FIELD_CONVERSION_EXPORT PointAverage : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_CONVERSION_EXPORT PointAverage : public vtkm::filter::FilterField { private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace field_conversion -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_conversion::PointAverage.") PointAverage - : public vtkm::filter::field_conversion::PointAverage -{ - using field_conversion::PointAverage::PointAverage; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_conversion/vtkm.module b/vtkm/filter/field_conversion/vtkm.module new file mode 100644 index 000000000..a641d3790 --- /dev/null +++ b/vtkm/filter/field_conversion/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_filter_field_conversion +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet diff --git a/vtkm/filter/field_transform/CMakeLists.txt b/vtkm/filter/field_transform/CMakeLists.txt index 4b0c21d54..6acb6c550 100644 --- a/vtkm/filter/field_transform/CMakeLists.txt +++ b/vtkm/filter/field_transform/CMakeLists.txt @@ -42,8 +42,3 @@ target_link_libraries(vtkm_filter_field_transform PUBLIC vtkm_worklet vtkm_filte target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_field_transform) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/field_transform/CylindricalCoordinateTransform.cxx b/vtkm/filter/field_transform/CylindricalCoordinateTransform.cxx index 739876232..98a553c0b 100644 --- a/vtkm/filter/field_transform/CylindricalCoordinateTransform.cxx +++ b/vtkm/filter/field_transform/CylindricalCoordinateTransform.cxx @@ -8,6 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ +#include #include #include @@ -18,10 +19,21 @@ namespace filter namespace field_transform { +CylindricalCoordinateTransform::CylindricalCoordinateTransform() +{ + this->SetUseCoordinateSystemAsField(true); +} + vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet) { vtkm::cont::UnknownArrayHandle outArray; + const vtkm::cont::Field& inField = this->GetFieldFromDataSet(inDataSet); + if (!inField.IsPointField()) + { + throw vtkm::cont::ErrorBadValue("CylindricalCoordinateTransform only applies to point data."); + } + auto resolveType = [&](const auto& concrete) { // use std::decay to remove const ref from the decltype of concrete. using T = typename std::decay_t::ValueType; @@ -32,15 +44,21 @@ vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont:: this->Invoke(vtkm::worklet::CylToCar{}, concrete, result); outArray = result; }; - this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType); + this->CastAndCallVecField<3>(inField, resolveType); - vtkm::cont::DataSet outDataSet = - this->CreateResult(inDataSet, - inDataSet.GetCellSet(), - vtkm::cont::CoordinateSystem("coordinates", outArray), - [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { - out.AddField(fieldToPass); - }); + std::string coordinateName = this->GetOutputFieldName(); + if (coordinateName.empty()) + { + coordinateName = inField.GetName(); + } + + vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem( + inDataSet, + inDataSet.GetCellSet(), + vtkm::cont::CoordinateSystem(coordinateName, outArray), + [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { + out.AddField(fieldToPass); + }); return outDataSet; } diff --git a/vtkm/filter/field_transform/CylindricalCoordinateTransform.h b/vtkm/filter/field_transform/CylindricalCoordinateTransform.h index 260300b4a..ed049a09b 100644 --- a/vtkm/filter/field_transform/CylindricalCoordinateTransform.h +++ b/vtkm/filter/field_transform/CylindricalCoordinateTransform.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_transform_CylindricalCoordinateTransform_h #define vtk_m_filter_field_transform_CylindricalCoordinateTransform_h -#include +#include #include namespace vtkm @@ -24,9 +24,11 @@ namespace field_transform /// /// Generate a coordinate transformation on coordinates from a dataset. class VTKM_FILTER_FIELD_TRANSFORM_EXPORT CylindricalCoordinateTransform - : public vtkm::filter::NewFilterField + : public vtkm::filter::FilterField { public: + VTKM_CONT CylindricalCoordinateTransform(); + VTKM_CONT void SetCartesianToCylindrical() { CartesianToCylindrical = true; } VTKM_CONT void SetCylindricalToCartesian() { CartesianToCylindrical = false; } @@ -36,12 +38,6 @@ private: bool CartesianToCylindrical = true; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::CylindricalCoordinateTransform.") - CylindricalCoordinateTransform - : public vtkm::filter::field_transform::CylindricalCoordinateTransform -{ - using field_transform::CylindricalCoordinateTransform::CylindricalCoordinateTransform; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/FieldToColors.h b/vtkm/filter/field_transform/FieldToColors.h index 0c1944995..67cd104f1 100644 --- a/vtkm/filter/field_transform/FieldToColors.h +++ b/vtkm/filter/field_transform/FieldToColors.h @@ -11,9 +11,8 @@ #ifndef vtk_m_filter_field_transform_FieldToColors_h #define vtk_m_filter_field_transform_FieldToColors_h -#include #include -#include +#include #include namespace vtkm @@ -24,7 +23,7 @@ namespace field_transform { /// \brief Convert an arbitrary field to an RGB or RGBA field /// -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT FieldToColors : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT FieldToColors : public vtkm::filter::FilterField { public: VTKM_CONT @@ -35,28 +34,13 @@ public: Scalar, Magnitude, Component, - SCALAR VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Scalar.") = Scalar, - MAGNITUDE VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Magnitude.") = Magnitude, - COMPONENT VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Component.") = Component }; - using FieldToColorsInputMode VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode.") = InputMode; - VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Scalar.") - static constexpr InputMode SCALAR = InputMode::Scalar; - VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Magnitude.") - static constexpr InputMode MAGNITUDE = InputMode::Magnitude; - VTKM_DEPRECATED(1.8, "Use FieldToColors::InputMode::Component.") - static constexpr InputMode COMPONENT = InputMode::Component; enum struct OutputMode { RGB, RGBA }; - using FieldToColorsOutputMode VTKM_DEPRECATED(1.8, "Use FieldToColors::OutputMode.") = OutputMode; - VTKM_DEPRECATED(1.8, "Use FieldToColors::OutputMode::RGB.") - static constexpr OutputMode RGB = OutputMode::RGB; - VTKM_DEPRECATED(1.8, "Use FieldToColors::OutputMode::RGBA.") - static constexpr OutputMode RGBA = OutputMode::RGBA; void SetColorTable(const vtkm::cont::ColorTable& table) { @@ -101,11 +85,6 @@ private: vtkm::Id ModifiedCount = -1; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::FieldToColors.") FieldToColors - : public vtkm::filter::field_transform::FieldToColors -{ - using field_transform::FieldToColors::FieldToColors; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/GenerateIds.h b/vtkm/filter/field_transform/GenerateIds.h index c49a71e99..def7450fa 100644 --- a/vtkm/filter/field_transform/GenerateIds.h +++ b/vtkm/filter/field_transform/GenerateIds.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_field_transform_GenerateIds_h #define vtk_m_filter_field_transform_GenerateIds_h -#include +#include #include namespace vtkm @@ -28,7 +28,7 @@ namespace field_transform /// convenient for adding indices to operations designed for fields and generally /// creating test data. /// -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT GenerateIds : public vtkm::filter::NewFilter +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT GenerateIds : public vtkm::filter::Filter { std::string PointFieldName = "pointids"; std::string CellFieldName = "cellids"; @@ -89,11 +89,6 @@ private: vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::GenerateIds.") GenerateIds - : public vtkm::filter::field_transform::GenerateIds -{ - using field_transform::GenerateIds::GenerateIds; -}; } // namespace vtkm::filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/LogValues.h b/vtkm/filter/field_transform/LogValues.h index d42dc3c0b..ec2fec7a3 100644 --- a/vtkm/filter/field_transform/LogValues.h +++ b/vtkm/filter/field_transform/LogValues.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_field_transform_LogValues_h #define vtk_m_filter_field_transform_LogValues_h -#include +#include #include namespace vtkm @@ -22,9 +22,9 @@ namespace field_transform /// \brief Adds field to a `DataSet` that gives the log values for the user specified field. /// -/// This filter use the ActiveField defined in the NewFilterField to store the log values. +/// This filter use the ActiveField defined in the FilterField to store the log values. /// -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT LogValues : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT LogValues : public vtkm::filter::FilterField { public: enum struct LogBase diff --git a/vtkm/filter/field_transform/PointElevation.h b/vtkm/filter/field_transform/PointElevation.h index 378e5838c..91ae47af3 100644 --- a/vtkm/filter/field_transform/PointElevation.h +++ b/vtkm/filter/field_transform/PointElevation.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_transform_PointElevation_h #define vtk_m_filter_field_transform_PointElevation_h -#include +#include #include namespace vtkm @@ -27,7 +27,7 @@ namespace field_transform /// are generated by computing a projection of each dataset point onto /// a line. The line can be oriented arbitrarily. A typical example is /// to generate scalars based on elevation or height above a plane. -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT PointElevation : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT PointElevation : public vtkm::filter::FilterField { public: VTKM_CONT @@ -60,11 +60,6 @@ private: vtkm::Float64 RangeLow = 0.0, RangeHigh = 1.0; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::PointElevation.") PointElevation - : public vtkm::filter::field_transform::PointElevation -{ - using field_transform::PointElevation::PointElevation; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/PointTransform.cxx b/vtkm/filter/field_transform/PointTransform.cxx index c1babc4d5..0acd6d6de 100644 --- a/vtkm/filter/field_transform/PointTransform.cxx +++ b/vtkm/filter/field_transform/PointTransform.cxx @@ -51,8 +51,9 @@ VTKM_CONT vtkm::cont::DataSet PointTransform::DoExecute(const vtkm::cont::DataSe const auto& field = this->GetFieldFromDataSet(inDataSet); this->CastAndCallVecField<3>(field, resolveType); - vtkm::cont::DataSet outData = this->CreateResultField( - inDataSet, this->GetOutputFieldName(), field.GetAssociation(), outArray); + auto passMapper = [](auto& d, const auto& f) { d.AddField(f); }; + vtkm::cont::DataSet outData = this->CreateResultCoordinateSystem( + inDataSet, inDataSet.GetCellSet(), this->GetOutputFieldName(), outArray, passMapper); if (this->GetChangeCoordinateSystem()) { diff --git a/vtkm/filter/field_transform/PointTransform.h b/vtkm/filter/field_transform/PointTransform.h index 1e339e635..e56d28021 100644 --- a/vtkm/filter/field_transform/PointTransform.h +++ b/vtkm/filter/field_transform/PointTransform.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace field_transform /// \brief /// /// Generate scalar field from a dataset. -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT PointTransform : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT PointTransform : public vtkm::filter::FilterField { public: VTKM_CONT @@ -104,11 +104,6 @@ private: bool ChangeCoordinateSystem = true; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::PointTransform.") PointTransform - : public vtkm::filter::field_transform::PointTransform -{ - using field_transform::PointTransform::PointTransform; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/SphericalCoordinateTransform.cxx b/vtkm/filter/field_transform/SphericalCoordinateTransform.cxx index 1a571dd80..af1730050 100644 --- a/vtkm/filter/field_transform/SphericalCoordinateTransform.cxx +++ b/vtkm/filter/field_transform/SphericalCoordinateTransform.cxx @@ -8,6 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ +#include #include #include @@ -17,10 +18,22 @@ namespace filter { namespace field_transform { + +SphericalCoordinateTransform::SphericalCoordinateTransform() +{ + this->SetUseCoordinateSystemAsField(true); +} + vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet) { vtkm::cont::UnknownArrayHandle outArray; + const vtkm::cont::Field& inField = this->GetFieldFromDataSet(inDataSet); + if (!inField.IsPointField()) + { + throw vtkm::cont::ErrorBadValue("SphericalCoordinateTransform only applies to point data."); + } + auto resolveType = [&](const auto& concrete) { // use std::decay to remove const ref from the decltype of concrete. using T = typename std::decay_t::ValueType; @@ -31,15 +44,21 @@ vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::Da this->Invoke(vtkm::worklet::SphereToCar{}, concrete, result); outArray = result; }; - this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType); + this->CastAndCallVecField<3>(inField, resolveType); - vtkm::cont::DataSet outDataSet = - this->CreateResult(inDataSet, - inDataSet.GetCellSet(), - vtkm::cont::CoordinateSystem("coordinates", outArray), - [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { - out.AddField(fieldToPass); - }); + std::string coordinateName = this->GetOutputFieldName(); + if (coordinateName.empty()) + { + coordinateName = inField.GetName(); + } + + vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem( + inDataSet, + inDataSet.GetCellSet(), + vtkm::cont::CoordinateSystem(coordinateName, outArray), + [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) { + out.AddField(fieldToPass); + }); return outDataSet; } } // namespace field_transform diff --git a/vtkm/filter/field_transform/SphericalCoordinateTransform.h b/vtkm/filter/field_transform/SphericalCoordinateTransform.h index b599ef86d..b8d089e3d 100644 --- a/vtkm/filter/field_transform/SphericalCoordinateTransform.h +++ b/vtkm/filter/field_transform/SphericalCoordinateTransform.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_transform_SphericalCoordinateTransform_h #define vtk_m_filter_field_transform_SphericalCoordinateTransform_h -#include +#include #include namespace vtkm @@ -22,9 +22,11 @@ namespace field_transform { class VTKM_FILTER_FIELD_TRANSFORM_EXPORT SphericalCoordinateTransform - : public vtkm::filter::NewFilterField + : public vtkm::filter::FilterField { public: + VTKM_CONT SphericalCoordinateTransform(); + VTKM_CONT void SetCartesianToSpherical() { CartesianToSpherical = true; } VTKM_CONT void SetSphericalToCartesian() { CartesianToSpherical = false; } @@ -34,11 +36,6 @@ private: bool CartesianToSpherical = true; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::SphericalCoordinateTransform.") - SphericalCoordinateTransform : public vtkm::filter::field_transform::SphericalCoordinateTransform -{ - using field_transform::SphericalCoordinateTransform::SphericalCoordinateTransform; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/field_transform/WarpScalar.h b/vtkm/filter/field_transform/WarpScalar.h index 206428ec1..8512a2452 100644 --- a/vtkm/filter/field_transform/WarpScalar.h +++ b/vtkm/filter/field_transform/WarpScalar.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_transform_WarpScalar_h #define vtk_m_filter_field_transform_WarpScalar_h -#include +#include #include namespace vtkm @@ -28,7 +28,7 @@ namespace field_transform /// It's a VTK-m version of the vtkWarpScalar in VTK. /// Useful for creating carpet or x-y-z plots. /// It doesn't modify the point coordinates, but creates a new point coordinates that have been warped. -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT WarpScalar : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT WarpScalar : public vtkm::filter::FilterField { public: VTKM_CONT @@ -87,11 +87,6 @@ private: vtkm::FloatDefault ScaleAmount; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::WarpScalar.") WarpScalar - : public vtkm::filter::field_transform::WarpScalar -{ - using field_transform::WarpScalar::WarpScalar; -}; } // namespace filter } // namespace vtkm #endif // vtk_m_filter_field_transform_WarpScalar_h diff --git a/vtkm/filter/field_transform/WarpVector.h b/vtkm/filter/field_transform/WarpVector.h index 0e04e148d..6642e6156 100644 --- a/vtkm/filter/field_transform/WarpVector.h +++ b/vtkm/filter/field_transform/WarpVector.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_field_transform_WarpVector_h #define vtk_m_filter_field_transform_WarpVector_h -#include +#include #include namespace vtkm @@ -28,7 +28,7 @@ namespace field_transform /// Useful for showing flow profiles or mechanical deformation. /// This worklet does not modify the input points but generate new point /// coordinate instance that has been warped. -class VTKM_FILTER_FIELD_TRANSFORM_EXPORT WarpVector : public vtkm::filter::NewFilterField +class VTKM_FILTER_FIELD_TRANSFORM_EXPORT WarpVector : public vtkm::filter::FilterField { public: VTKM_CONT @@ -62,11 +62,6 @@ private: vtkm::FloatDefault Scale; }; } // namespace field_transform -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_transform::WarpVector.") WarpVector - : public vtkm::filter::field_transform::WarpVector -{ - using field_transform::WarpVector::WarpVector; -}; } // namespace filter } // namespace vtkm #endif // vtk_m_filter_field_transform_WarpVector_h diff --git a/vtkm/filter/field_transform/testing/UnitTestGenerateIds.cxx b/vtkm/filter/field_transform/testing/UnitTestGenerateIds.cxx index 312dad2df..77228c4c8 100644 --- a/vtkm/filter/field_transform/testing/UnitTestGenerateIds.cxx +++ b/vtkm/filter/field_transform/testing/UnitTestGenerateIds.cxx @@ -77,7 +77,9 @@ void TryGenerateIds( void TestGenerateIds() { - vtkm::cont::DataSet input = vtkm::source::Tangle{ vtkm::Id3(8) }.Execute(); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions({ 8, 8, 8 }); + vtkm::cont::DataSet input = tangle.Execute(); vtkm::filter::field_transform::GenerateIds filter; TryGenerateIds(filter, input); diff --git a/vtkm/filter/field_transform/vtkm.module b/vtkm/filter/field_transform/vtkm.module new file mode 100644 index 000000000..dcb4be454 --- /dev/null +++ b/vtkm/filter/field_transform/vtkm.module @@ -0,0 +1,16 @@ +NAME + vtkm_filter_field_transform +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_field_transform + vtkm_filter_vector_analysis + vtkm_source +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing + vtkm_rendering diff --git a/vtkm/filter/flow/CMakeLists.txt b/vtkm/filter/flow/CMakeLists.txt index 27ebea1ec..500039c86 100644 --- a/vtkm/filter/flow/CMakeLists.txt +++ b/vtkm/filter/flow/CMakeLists.txt @@ -9,10 +9,10 @@ ##============================================================================ set(flow_headers + FilterParticleAdvection.h + FilterParticleAdvectionSteadyState.h + FilterParticleAdvectionUnsteadyState.h FlowTypes.h - NewFilterParticleAdvection.h - NewFilterParticleAdvectionSteadyState.h - NewFilterParticleAdvectionUnsteadyState.h Lagrangian.h LagrangianStructures.h ParticleAdvection.h @@ -24,7 +24,7 @@ set(flow_headers set(flow_sources internal/Messenger.cxx - NewFilterParticleAdvection.cxx + FilterParticleAdvection.cxx ParticleAdvection.cxx Pathline.cxx PathParticle.cxx @@ -34,8 +34,8 @@ set(flow_sources set(flow_device_sources Lagrangian.cxx LagrangianStructures.cxx - NewFilterParticleAdvectionSteadyState.cxx - NewFilterParticleAdvectionUnsteadyState.cxx + FilterParticleAdvectionSteadyState.cxx + FilterParticleAdvectionUnsteadyState.cxx StreamSurface.cxx ) @@ -47,16 +47,7 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_flow PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_flow) -if (VTKm_ENABLE_MPI) - target_link_libraries(vtkm_filter_flow PUBLIC MPI::MPI_CXX) -endif() add_subdirectory(internal) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/flow/NewFilterParticleAdvection.cxx b/vtkm/filter/flow/FilterParticleAdvection.cxx similarity index 88% rename from vtkm/filter/flow/NewFilterParticleAdvection.cxx rename to vtkm/filter/flow/FilterParticleAdvection.cxx index 7916876d2..ea65bfc8a 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvection.cxx +++ b/vtkm/filter/flow/FilterParticleAdvection.cxx @@ -11,7 +11,7 @@ #include #include -#include +#include namespace vtkm { @@ -20,8 +20,7 @@ namespace filter namespace flow { -VTKM_CONT vtkm::cont::DataSet NewFilterParticleAdvection::DoExecute( - const vtkm::cont::DataSet& inData) +VTKM_CONT vtkm::cont::DataSet FilterParticleAdvection::DoExecute(const vtkm::cont::DataSet& inData) { auto out = this->DoExecutePartitions(inData); if (out.GetNumberOfPartitions() != 1) @@ -30,7 +29,7 @@ VTKM_CONT vtkm::cont::DataSet NewFilterParticleAdvection::DoExecute( return out.GetPartition(0); } -VTKM_CONT void NewFilterParticleAdvection::ValidateOptions() const +VTKM_CONT void FilterParticleAdvection::ValidateOptions() const { if (this->GetUseCoordinateSystemAsField()) throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported"); diff --git a/vtkm/filter/flow/NewFilterParticleAdvection.h b/vtkm/filter/flow/FilterParticleAdvection.h similarity index 91% rename from vtkm/filter/flow/NewFilterParticleAdvection.h rename to vtkm/filter/flow/FilterParticleAdvection.h index 048159452..ec160b0a2 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvection.h +++ b/vtkm/filter/flow/FilterParticleAdvection.h @@ -8,11 +8,11 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_flow_NewFilterParticleAdvection_h -#define vtk_m_filter_flow_NewFilterParticleAdvection_h +#ifndef vtk_m_filter_flow_FilterParticleAdvection_h +#define vtk_m_filter_flow_FilterParticleAdvection_h #include -#include +#include #include #include @@ -28,7 +28,7 @@ namespace flow /// Takes as input a vector field and seed locations and advects the seeds /// through the flow field. -class VTKM_FILTER_FLOW_EXPORT NewFilterParticleAdvection : public vtkm::filter::NewFilterField +class VTKM_FILTER_FLOW_EXPORT FilterParticleAdvection : public vtkm::filter::FilterField { public: VTKM_CONT @@ -107,4 +107,4 @@ private: } } // namespace vtkm::filter::flow -#endif // vtk_m_filter_flow_NewFilterParticleAdvection_h +#endif // vtk_m_filter_flow_FilterParticleAdvection_h diff --git a/vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.cxx b/vtkm/filter/flow/FilterParticleAdvectionSteadyState.cxx similarity index 90% rename from vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.cxx rename to vtkm/filter/flow/FilterParticleAdvectionSteadyState.cxx index 70c6c27e9..9ba479d5f 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.cxx +++ b/vtkm/filter/flow/FilterParticleAdvectionSteadyState.cxx @@ -8,7 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include #include #include @@ -26,8 +26,7 @@ namespace VTKM_CONT std::vector CreateDataSetIntegrators( const vtkm::cont::PartitionedDataSet& input, - const vtkm::cont::internal::Variant>& - activeField, + const vtkm::cont::Variant>& activeField, const vtkm::filter::flow::internal::BoundsMap& boundsMap, const vtkm::filter::flow::IntegrationSolverType solverType, const vtkm::filter::flow::VectorFieldType vecFieldType, @@ -63,14 +62,13 @@ CreateDataSetIntegrators( } //anonymous namespace -VTKM_CONT vtkm::cont::PartitionedDataSet NewFilterParticleAdvectionSteadyState::DoExecutePartitions( +VTKM_CONT vtkm::cont::PartitionedDataSet FilterParticleAdvectionSteadyState::DoExecutePartitions( const vtkm::cont::PartitionedDataSet& input) { using DSIType = vtkm::filter::flow::internal::DataSetIntegratorSteadyState; this->ValidateOptions(); - using VariantType = - vtkm::cont::internal::Variant>; + using VariantType = vtkm::cont::Variant>; VariantType variant; if (this->VecFieldType == vtkm::filter::flow::VectorFieldType::VELOCITY_FIELD_TYPE) diff --git a/vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h b/vtkm/filter/flow/FilterParticleAdvectionSteadyState.h similarity index 68% rename from vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h rename to vtkm/filter/flow/FilterParticleAdvectionSteadyState.h index ed0731301..21a9fd910 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h +++ b/vtkm/filter/flow/FilterParticleAdvectionSteadyState.h @@ -8,11 +8,11 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_flow_NewFilterParticleAdvectionSteadyState_h -#define vtk_m_filter_flow_NewFilterParticleAdvectionSteadyState_h +#ifndef vtk_m_filter_flow_FilterParticleAdvectionSteadyState_h +#define vtk_m_filter_flow_FilterParticleAdvectionSteadyState_h +#include #include -#include #include namespace vtkm @@ -21,8 +21,7 @@ namespace filter { namespace flow { -class VTKM_FILTER_FLOW_EXPORT NewFilterParticleAdvectionSteadyState - : public NewFilterParticleAdvection +class VTKM_FILTER_FLOW_EXPORT FilterParticleAdvectionSteadyState : public FilterParticleAdvection { private: VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions( @@ -33,4 +32,4 @@ private: } } // namespace vtkm::filter::flow -#endif // vtk_m_filter_flow_NewFilterParticleAdvectionSteadyState_h +#endif // vtk_m_filter_flow_FilterParticleAdvectionSteadyState_h diff --git a/vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.cxx b/vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.cxx similarity index 91% rename from vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.cxx rename to vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.cxx index b2df0b8e4..78fc123c6 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.cxx +++ b/vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.cxx @@ -8,7 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include #include #include @@ -51,15 +51,14 @@ CreateDataSetIntegrators(const vtkm::cont::PartitionedDataSet& input, } } // anonymous namespace -VTKM_CONT void NewFilterParticleAdvectionUnsteadyState::ValidateOptions() const +VTKM_CONT void FilterParticleAdvectionUnsteadyState::ValidateOptions() const { - this->NewFilterParticleAdvection::ValidateOptions(); + this->FilterParticleAdvection::ValidateOptions(); if (this->Time1 >= this->Time2) throw vtkm::cont::ErrorFilterExecution("PreviousTime must be less than NextTime"); } -VTKM_CONT vtkm::cont::PartitionedDataSet -NewFilterParticleAdvectionUnsteadyState::DoExecutePartitions( +VTKM_CONT vtkm::cont::PartitionedDataSet FilterParticleAdvectionUnsteadyState::DoExecutePartitions( const vtkm::cont::PartitionedDataSet& input) { using DSIType = vtkm::filter::flow::internal::DataSetIntegratorUnsteadyState; diff --git a/vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.h b/vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.h similarity index 77% rename from vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.h rename to vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.h index d1d959329..c77659821 100644 --- a/vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.h +++ b/vtkm/filter/flow/FilterParticleAdvectionUnsteadyState.h @@ -8,10 +8,10 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_flow_NewFilterParticleAdvectionUnsteadyState_h -#define vtk_m_filter_flow_NewFilterParticleAdvectionUnsteadyState_h +#ifndef vtk_m_filter_flow_FilterParticleAdvectionUnsteadyState_h +#define vtk_m_filter_flow_FilterParticleAdvectionUnsteadyState_h -#include +#include #include namespace vtkm @@ -21,8 +21,7 @@ namespace filter namespace flow { -class VTKM_FILTER_FLOW_EXPORT NewFilterParticleAdvectionUnsteadyState - : public NewFilterParticleAdvection +class VTKM_FILTER_FLOW_EXPORT FilterParticleAdvectionUnsteadyState : public FilterParticleAdvection { public: VTKM_CONT void SetPreviousTime(vtkm::FloatDefault t1) { this->Time1 = t1; } @@ -49,4 +48,4 @@ private: } } // namespace vtkm::filter::flow -#endif // vtk_m_filter_flow_NewFilterParticleAdvectionUnsteadyState_h +#endif // vtk_m_filter_flow_FilterParticleAdvectionUnsteadyState_h diff --git a/vtkm/filter/flow/Lagrangian.cxx b/vtkm/filter/flow/Lagrangian.cxx index b1fba866c..fdb3e6c76 100644 --- a/vtkm/filter/flow/Lagrangian.cxx +++ b/vtkm/filter/flow/Lagrangian.cxx @@ -45,10 +45,10 @@ public: template VTKM_EXEC void operator()(const vtkm::Particle& end_point, ValidityType& res) const { - vtkm::Id steps = end_point.NumSteps; + vtkm::Id steps = end_point.GetNumberOfSteps(); if (steps > 0 && res == 1) { - if (bounds.Contains(end_point.Pos)) + if (bounds.Contains(end_point.GetPosition())) { res = 1; } @@ -79,9 +79,9 @@ public: const vtkm::Particle& start_point, DisplacementType& res) const { - res[0] = end_point.Pos[0] - start_point.Pos[0]; - res[1] = end_point.Pos[1] - start_point.Pos[1]; - res[2] = end_point.Pos[2] - start_point.Pos[2]; + res[0] = end_point.GetPosition()[0] - start_point.GetPosition()[0]; + res[1] = end_point.GetPosition()[1] - start_point.GetPosition()[1]; + res[2] = end_point.GetPosition()[2] - start_point.GetPosition()[2]; } }; @@ -262,7 +262,7 @@ VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& i auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& fieldToPass) { MapField(dataset, fieldToPass); }; - outputData = this->CreateResult(input, outCellSet, outCoords, fieldmapper); + outputData = this->CreateResultCoordinateSystem(input, outCellSet, outCoords, fieldmapper); outputData.AddPointField("valid", this->BasisParticlesValidity); outputData.AddPointField("displacement", basisParticlesDisplacement); @@ -289,65 +289,3 @@ VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& i } } } //vtkm::filter::flow - - -//Deprecated filter: vtkm::filter::Lagrangian -namespace vtkm -{ -namespace filter -{ - -static vtkm::Id deprecatedLagrange_Cycle = 0; -static vtkm::cont::ArrayHandle deprecatedLagrange_BasisParticles; -static vtkm::cont::ArrayHandle deprecatedLagrange_BasisParticlesOriginal; -static vtkm::cont::ArrayHandle deprecatedLagrange_BasisParticlesValidity; - - -VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& input) -{ - //Initialize the filter with the static variables - this->SetCycle(deprecatedLagrange_Cycle); - this->SetBasisParticles(deprecatedLagrange_BasisParticles); - this->SetBasisParticlesOriginal(deprecatedLagrange_BasisParticlesOriginal); - this->SetBasisParticleValidity(deprecatedLagrange_BasisParticlesValidity); - - //call the base class - auto output = vtkm::filter::flow::Lagrangian::DoExecute(input); - - //Set the static variables with the current values. - deprecatedLagrange_Cycle = this->GetCycle(); - deprecatedLagrange_BasisParticles = this->GetBasisParticles(); - deprecatedLagrange_BasisParticlesOriginal = this->GetBasisParticlesOriginal(); - deprecatedLagrange_BasisParticlesValidity = this->GetBasisParticleValidity(); - - //The deprecated filter returned a rectilinear grid of points whereas the new version - //returns a uniform grid of points. Convert the coordinates for deprecated users. - if (output.GetNumberOfCoordinateSystems() > 0) - { - vtkm::cont::ArrayHandleUniformPointCoordinates originalCoordinates; - output.GetCoordinateSystem().GetData().AsArrayHandle(originalCoordinates); - vtkm::Id3 dims = originalCoordinates.GetDimensions(); - vtkm::Vec3f origin = originalCoordinates.GetOrigin(); - vtkm::Vec3f spacing = originalCoordinates.GetSpacing(); - - vtkm::cont::ArrayHandle xCoords; - vtkm::cont::ArrayCopy( - vtkm::cont::ArrayHandleCounting(origin[0], spacing[0], dims[0]), xCoords); - - vtkm::cont::ArrayHandle yCoords; - vtkm::cont::ArrayCopy( - vtkm::cont::ArrayHandleCounting(origin[1], spacing[1], dims[1]), yCoords); - - vtkm::cont::ArrayHandle zCoords; - vtkm::cont::ArrayCopy( - vtkm::cont::ArrayHandleCounting(origin[2], spacing[2], dims[2]), zCoords); - - output.GetCoordinateSystem() = vtkm::cont::CoordinateSystem( - "coords", vtkm::cont::make_ArrayHandleCartesianProduct(xCoords, yCoords, zCoords)); - } - - return output; -} - -} -} // namespace vtkm::filter diff --git a/vtkm/filter/flow/Lagrangian.h b/vtkm/filter/flow/Lagrangian.h index 43b415688..09226dacd 100644 --- a/vtkm/filter/flow/Lagrangian.h +++ b/vtkm/filter/flow/Lagrangian.h @@ -12,7 +12,7 @@ #define vtk_m_filter_flow_Lagrangian_h #include -#include +#include #include namespace vtkm @@ -22,7 +22,7 @@ namespace filter namespace flow { -class VTKM_FILTER_FLOW_EXPORT Lagrangian : public vtkm::filter::NewFilterField +class VTKM_FILTER_FLOW_EXPORT Lagrangian : public vtkm::filter::FilterField { public: VTKM_CONT @@ -99,10 +99,9 @@ public: return this->BasisParticlesValidity; } -protected: // make this protected so the deprecated version can override. +private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; -private: vtkm::cont::ArrayHandle BasisParticles; vtkm::cont::ArrayHandle BasisParticlesOriginal; vtkm::cont::ArrayHandle BasisParticlesValidity; @@ -123,29 +122,4 @@ private: } } //vtkm::filter::flow - -//Deprecated Lagrangian filter -namespace vtkm -{ -namespace filter -{ - -class VTKM_FILTER_FLOW_EXPORT VTKM_DEPRECATED( - 1.9, - "Use vtkm::filter::flow::Lagrangian. " - "Note that the new version of the filter no longer relies on global " - "variables to record particle position from one time step to the next. " - "It is important to keep a reference to _the same object_. " - "If you create a new filter object, the seeds will be reinitialized.") Lagrangian - : public vtkm::filter::flow::Lagrangian -{ -private: - VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; -}; - -} -} //vtkm::filter - - - #endif // #define vtk_m_filter_flow_Lagrangian_h diff --git a/vtkm/filter/flow/LagrangianStructures.cxx b/vtkm/filter/flow/LagrangianStructures.cxx index a9f330e07..0a2a57f90 100644 --- a/vtkm/filter/flow/LagrangianStructures.cxx +++ b/vtkm/filter/flow/LagrangianStructures.cxx @@ -57,7 +57,7 @@ public: VTKM_EXEC void operator()(const vtkm::Particle& particle, vtkm::Vec3f& pt) const { - pt = particle.Pos; + pt = particle.GetPosition(); } }; @@ -72,8 +72,8 @@ public: const vtkm::Vec3f& seed, vtkm::Particle& particle) const { - particle.ID = index; - particle.Pos = seed; + particle.SetID(index); + particle.SetPosition(seed); } }; @@ -174,8 +174,8 @@ VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(const vtkm::cont:: auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& field) { MapField(dataset, field); }; - vtkm::cont::DataSet output = - this->CreateResult(input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper); + vtkm::cont::DataSet output = this->CreateResultCoordinateSystem( + input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper); output.AddPointField(this->GetOutputFieldName(), outputField); return output; } diff --git a/vtkm/filter/flow/LagrangianStructures.h b/vtkm/filter/flow/LagrangianStructures.h index d24e64971..142128b49 100644 --- a/vtkm/filter/flow/LagrangianStructures.h +++ b/vtkm/filter/flow/LagrangianStructures.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_flow_LagrangianStructures_h #define vtk_m_filter_flow_LagrangianStructures_h -#include +#include #include #include @@ -22,7 +22,7 @@ namespace filter namespace flow { -class VTKM_FILTER_FLOW_EXPORT LagrangianStructures : public vtkm::filter::NewFilterField +class VTKM_FILTER_FLOW_EXPORT LagrangianStructures : public vtkm::filter::FilterField { public: VTKM_CONT @@ -69,11 +69,6 @@ private: }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::LagrangianStructures.") LagrangianStructures - : vtkm::filter::flow::LagrangianStructures -{ - using vtkm::filter::flow::LagrangianStructures::LagrangianStructures; -}; } } // namespace vtkm diff --git a/vtkm/filter/flow/ParticleAdvection.h b/vtkm/filter/flow/ParticleAdvection.h index e973da730..60eed8248 100644 --- a/vtkm/filter/flow/ParticleAdvection.h +++ b/vtkm/filter/flow/ParticleAdvection.h @@ -11,8 +11,8 @@ #ifndef vtk_m_filter_flow_ParticleAdvection_h #define vtk_m_filter_flow_ParticleAdvection_h +#include #include -#include #include namespace vtkm @@ -28,7 +28,7 @@ namespace flow /// end points for each seed through the vector field. class VTKM_FILTER_FLOW_EXPORT ParticleAdvection - : public vtkm::filter::flow::NewFilterParticleAdvectionSteadyState + : public vtkm::filter::flow::FilterParticleAdvectionSteadyState { public: private: @@ -36,11 +36,6 @@ private: }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::ParticleAdvection.") ParticleAdvection - : vtkm::filter::flow::ParticleAdvection -{ - using vtkm::filter::flow::ParticleAdvection::ParticleAdvection; -}; } } // namespace vtkm::filter::flow diff --git a/vtkm/filter/flow/PathParticle.h b/vtkm/filter/flow/PathParticle.h index b606cdb4f..18e81252f 100644 --- a/vtkm/filter/flow/PathParticle.h +++ b/vtkm/filter/flow/PathParticle.h @@ -11,8 +11,8 @@ #ifndef vtk_m_filter_flow_PathParticle_h #define vtk_m_filter_flow_PathParticle_h +#include #include -#include #include namespace vtkm @@ -28,18 +28,13 @@ namespace flow /// end points for each seed through the vector field. class VTKM_FILTER_FLOW_EXPORT PathParticle - : public vtkm::filter::flow::NewFilterParticleAdvectionUnsteadyState + : public vtkm::filter::flow::FilterParticleAdvectionUnsteadyState { private: VTKM_CONT vtkm::filter::flow::FlowResultType GetResultType() const override; }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::PathParticle.") PathParticle - : vtkm::filter::flow::PathParticle -{ - using vtkm::filter::flow::PathParticle::PathParticle; -}; } } // namespace vtkm::filter::flow diff --git a/vtkm/filter/flow/Pathline.h b/vtkm/filter/flow/Pathline.h index 485b5d591..de8ef6200 100644 --- a/vtkm/filter/flow/Pathline.h +++ b/vtkm/filter/flow/Pathline.h @@ -11,8 +11,8 @@ #ifndef vtk_m_filter_flow_Pathline_h #define vtk_m_filter_flow_Pathline_h +#include #include -#include #include namespace vtkm @@ -28,18 +28,13 @@ namespace flow /// end points for each seed through the vector field. class VTKM_FILTER_FLOW_EXPORT Pathline - : public vtkm::filter::flow::NewFilterParticleAdvectionUnsteadyState + : public vtkm::filter::flow::FilterParticleAdvectionUnsteadyState { private: VTKM_CONT vtkm::filter::flow::FlowResultType GetResultType() const override; }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::Pathline.") Pathline - : vtkm::filter::flow::Pathline -{ - using vtkm::filter::flow::Pathline::Pathline; -}; } } // namespace vtkm::filter::flow diff --git a/vtkm/filter/flow/StreamSurface.h b/vtkm/filter/flow/StreamSurface.h index c06a3f769..1ad27eb63 100644 --- a/vtkm/filter/flow/StreamSurface.h +++ b/vtkm/filter/flow/StreamSurface.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_flow_StreamSurface_h #define vtk_m_filter_flow_StreamSurface_h -#include +#include #include #include @@ -27,7 +27,7 @@ namespace flow /// Takes as input a vector field and seed locations and generates the /// paths taken by the seeds through the vector field. -class VTKM_FILTER_FLOW_EXPORT StreamSurface : public vtkm::filter::NewFilterField +class VTKM_FILTER_FLOW_EXPORT StreamSurface : public vtkm::filter::FilterField { public: VTKM_CONT @@ -58,11 +58,6 @@ private: }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::StreamSurface.") StreamSurface - : vtkm::filter::flow::StreamSurface -{ - using vtkm::filter::flow::StreamSurface::StreamSurface; -}; } } // namespace vtkm::filter::flow diff --git a/vtkm/filter/flow/Streamline.h b/vtkm/filter/flow/Streamline.h index 34a58d693..89f38eaf1 100644 --- a/vtkm/filter/flow/Streamline.h +++ b/vtkm/filter/flow/Streamline.h @@ -11,8 +11,8 @@ #ifndef vtk_m_filter_flow_Streamline_h #define vtk_m_filter_flow_Streamline_h +#include #include -#include #include namespace vtkm @@ -28,18 +28,13 @@ namespace flow /// end points for each seed through the vector field. class VTKM_FILTER_FLOW_EXPORT Streamline - : public vtkm::filter::flow::NewFilterParticleAdvectionSteadyState + : public vtkm::filter::flow::FilterParticleAdvectionSteadyState { private: VTKM_CONT vtkm::filter::flow::FlowResultType GetResultType() const override; }; } -struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::Streamline.") Streamline - : vtkm::filter::flow::Streamline -{ - using vtkm::filter::flow::Streamline::Streamline; -}; } } // namespace vtkm::filter::flow diff --git a/vtkm/filter/flow/internal/AdvectAlgorithm.h b/vtkm/filter/flow/internal/AdvectAlgorithm.h index 33d38d4b5..b2fe6a97a 100644 --- a/vtkm/filter/flow/internal/AdvectAlgorithm.h +++ b/vtkm/filter/flow/internal/AdvectAlgorithm.h @@ -75,7 +75,7 @@ public: for (vtkm::Id i = 0; i < n; i++) { const ParticleType p = portal.Get(i); - std::vector ids = this->BoundsMap.FindBlocks(p.Pos); + std::vector ids = this->BoundsMap.FindBlocks(p.GetPosition()); if (!ids.empty() && this->BoundsMap.FindRank(ids[0]) == this->Rank) { @@ -155,7 +155,7 @@ public: auto bit = blockIds.begin(); while (pit != particles.end() && bit != blockIds.end()) { - this->ParticleBlockIDsMap[pit->ID] = *bit; + this->ParticleBlockIDsMap[pit->GetID()] = *bit; pit++; bit++; } @@ -170,12 +170,12 @@ public: if (this->Active.empty()) return false; - blockId = this->ParticleBlockIDsMap[this->Active.front().ID][0]; + blockId = this->ParticleBlockIDsMap[this->Active.front().GetID()][0]; auto it = this->Active.begin(); while (it != this->Active.end()) { auto p = *it; - if (blockId == this->ParticleBlockIDsMap[p.ID][0]) + if (blockId == this->ParticleBlockIDsMap[p.GetID()][0]) { particles.emplace_back(p); it = this->Active.erase(it); diff --git a/vtkm/filter/flow/internal/DataSetIntegrator.h b/vtkm/filter/flow/internal/DataSetIntegrator.h index 3f2d21881..554288f3b 100644 --- a/vtkm/filter/flow/internal/DataSetIntegrator.h +++ b/vtkm/filter/flow/internal/DataSetIntegrator.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace vtkm { @@ -54,8 +54,8 @@ public: std::vector TermIdx, TermID; }; -using DSIHelperInfoType = vtkm::cont::internal::Variant, - DSIHelperInfo>; +using DSIHelperInfoType = + vtkm::cont::Variant, DSIHelperInfo>; template class DataSetIntegrator @@ -65,14 +65,13 @@ public: using ElectroMagneticFieldNameType = std::pair; protected: - using FieldNameType = - vtkm::cont::internal::Variant; + using FieldNameType = vtkm::cont::Variant; - using RType = vtkm::cont::internal::Variant< - vtkm::worklet::flow::ParticleAdvectionResult, - vtkm::worklet::flow::ParticleAdvectionResult, - vtkm::worklet::flow::StreamlineResult, - vtkm::worklet::flow::StreamlineResult>; + using RType = + vtkm::cont::Variant, + vtkm::worklet::flow::ParticleAdvectionResult, + vtkm::worklet::flow::StreamlineResult, + vtkm::worklet::flow::StreamlineResult>; public: DataSetIntegrator(vtkm::Id id, @@ -128,7 +127,7 @@ protected: DSIHelperInfo& dsiInfo) const; //Data members. - vtkm::cont::internal::Variant FieldName; + vtkm::cont::Variant FieldName; vtkm::Id Id; vtkm::filter::flow::IntegrationSolverType SolverType; @@ -162,32 +161,32 @@ VTKM_CONT inline void DataSetIntegrator::ClassifyParticles( { auto p = portal.Get(i); - if (p.Status.CheckTerminate()) + if (p.GetStatus().CheckTerminate()) { dsiInfo.TermIdx.emplace_back(i); - dsiInfo.TermID.emplace_back(p.ID); + dsiInfo.TermID.emplace_back(p.GetID()); } else { - const auto& it = dsiInfo.ParticleBlockIDsMap.find(p.ID); + const auto& it = dsiInfo.ParticleBlockIDsMap.find(p.GetID()); VTKM_ASSERT(it != dsiInfo.ParticleBlockIDsMap.end()); auto currBIDs = it->second; VTKM_ASSERT(!currBIDs.empty()); std::vector newIDs; - if (p.Status.CheckSpatialBounds() && !p.Status.CheckTookAnySteps()) + if (p.GetStatus().CheckSpatialBounds() && !p.GetStatus().CheckTookAnySteps()) newIDs.assign(std::next(currBIDs.begin(), 1), currBIDs.end()); else - newIDs = dsiInfo.BoundsMap.FindBlocks(p.Pos, currBIDs); + newIDs = dsiInfo.BoundsMap.FindBlocks(p.GetPosition(), currBIDs); //reset the particle status. - p.Status = vtkm::ParticleStatus(); + p.GetStatus() = vtkm::ParticleStatus(); if (newIDs.empty()) //No blocks, we're done. { - p.Status.SetTerminate(); + p.GetStatus().SetTerminate(); dsiInfo.TermIdx.emplace_back(i); - dsiInfo.TermID.emplace_back(p.ID); + dsiInfo.TermID.emplace_back(p.GetID()); } else { @@ -211,12 +210,12 @@ VTKM_CONT inline void DataSetIntegrator::ClassifyParticles( if (dstRank == this->Rank) { dsiInfo.A.emplace_back(p); - dsiInfo.IdMapA[p.ID] = newIDs; + dsiInfo.IdMapA[p.GetID()] = newIDs; } else { dsiInfo.I.emplace_back(p); - dsiInfo.IdMapI[p.ID] = newIDs; + dsiInfo.IdMapI[p.GetID()] = newIDs; } } portal.Set(i, p); diff --git a/vtkm/filter/flow/internal/ParticleMessenger.h b/vtkm/filter/flow/internal/ParticleMessenger.h index 3f010432e..04f9a123d 100644 --- a/vtkm/filter/flow/internal/ParticleMessenger.h +++ b/vtkm/filter/flow/internal/ParticleMessenger.h @@ -174,9 +174,9 @@ void ParticleMessenger::SerialExchange( { for (auto& p : outData) { - const auto& bids = outBlockIDsMap.find(p.ID)->second; + const auto& bids = outBlockIDsMap.find(p.GetID())->second; inData.emplace_back(p); - inDataBlockIDsMap[p.ID] = bids; + inDataBlockIDsMap[p.GetID()] = bids; } } @@ -205,7 +205,7 @@ void ParticleMessenger::Exchange( for (const auto& p : outData) { - const auto& bids = outBlockIDsMap.find(p.ID)->second; + const auto& bids = outBlockIDsMap.find(p.GetID())->second; int dstRank = this->BoundsMap.FindRank(bids[0]); sendData[dstRank].emplace_back(std::make_pair(p, bids)); } @@ -227,7 +227,7 @@ void ParticleMessenger::Exchange( const auto& p = v.first; const auto& bids = v.second; inData.emplace_back(p); - inDataBlockIDsMap[p.ID] = bids; + inDataBlockIDsMap[p.GetID()] = bids; } for (const auto& m : msgData) diff --git a/vtkm/filter/flow/testing/CMakeLists.txt b/vtkm/filter/flow/testing/CMakeLists.txt index ba68f5d75..3c7126ca4 100644 --- a/vtkm/filter/flow/testing/CMakeLists.txt +++ b/vtkm/filter/flow/testing/CMakeLists.txt @@ -21,15 +21,7 @@ set(worklet_unit_tests UnitTestStreamSurfaceWorklet.cxx ) -set(libraries - vtkm_filter_mesh_info - vtkm_filter_flow - vtkm_io - ) - -if (VTKm_ENABLE_RENDERING) - list(APPEND libraries vtkm_filter_geometry_refinement vtkm_rendering vtkm_rendering_testing) - +if (TARGET vtkm_rendering_testing) list(APPEND filter_unit_tests RenderTestStreamline.cxx ) @@ -38,9 +30,8 @@ endif() vtkm_unit_tests( SOURCES ${filter_unit_tests} DEVICE_SOURCES ${worklet_unit_tests} - LIBRARIES ${libraries} USE_VTKM_JOB_POOL -) + ) #add distributed tests i.e.test to run with MPI #if MPI is enabled. @@ -50,9 +41,8 @@ if (VTKm_ENABLE_MPI) UnitTestStreamlineFilterMPI.cxx ) vtkm_unit_tests( - MPI DEVICE_SOURCES ${mpi_unit_tests} - LIBRARIES ${libraries} - ALL_BACKENDS + MPI + DEVICE_SOURCES ${mpi_unit_tests} USE_VTKM_JOB_POOL ) endif() diff --git a/vtkm/filter/flow/testing/UnitTestLagrangianFilter.cxx b/vtkm/filter/flow/testing/UnitTestLagrangianFilter.cxx index cd7699659..ddb850c83 100644 --- a/vtkm/filter/flow/testing/UnitTestLagrangianFilter.cxx +++ b/vtkm/filter/flow/testing/UnitTestLagrangianFilter.cxx @@ -69,7 +69,7 @@ void TestLagrangianFilterMultiStepInterval() "Wrong number of coordinate systems in the output dataset."); VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfPoints() == 512, "Wrong number of basis flows extracted."); - VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfFields() == 2, "Wrong number of fields."); + VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfFields() == 3, "Wrong number of fields."); } else { diff --git a/vtkm/filter/flow/testing/UnitTestParticleMessengerMPI.cxx b/vtkm/filter/flow/testing/UnitTestParticleMessengerMPI.cxx index 480d9551b..a53d31441 100644 --- a/vtkm/filter/flow/testing/UnitTestParticleMessengerMPI.cxx +++ b/vtkm/filter/flow/testing/UnitTestParticleMessengerMPI.cxx @@ -85,13 +85,15 @@ void ValidateReceivedParticles( const auto& reqP = particles[static_cast(sendRank)][i]; const auto& p = recvP[i].first; - VTKM_TEST_ASSERT(p.Pos == reqP.Pos, "Received particle has wrong Position."); - VTKM_TEST_ASSERT(p.Time == reqP.Time, "Received particle has wrong Time."); - VTKM_TEST_ASSERT(p.ID == reqP.ID, "Received particle has wrong ID."); - VTKM_TEST_ASSERT(p.NumSteps == reqP.NumSteps, "Received particle has wrong NumSteps."); + VTKM_TEST_ASSERT(p.GetPosition() == reqP.GetPosition(), + "Received particle has wrong Position."); + VTKM_TEST_ASSERT(p.GetTime() == reqP.GetTime(), "Received particle has wrong Time."); + VTKM_TEST_ASSERT(p.GetID() == reqP.GetID(), "Received particle has wrong ID."); + VTKM_TEST_ASSERT(p.GetNumberOfSteps() == reqP.GetNumberOfSteps(), + "Received particle has wrong NumSteps."); - VTKM_TEST_ASSERT(p.Pos == reqP.Pos && p.Time == reqP.Time && p.ID == reqP.ID && - p.NumSteps == reqP.NumSteps, + VTKM_TEST_ASSERT(p.GetPosition() == reqP.GetPosition() && p.GetTime() == reqP.GetTime() && + p.GetID() == reqP.GetID() && p.GetNumberOfSteps() == reqP.GetNumberOfSteps(), "Received particle has wrong values."); const auto& reqBids = particleBlockIds[static_cast(sendRank)][i]; @@ -153,12 +155,10 @@ void TestParticleMessenger() for (int p = 0; p < nP; p++) { vtkm::Particle particle; - particle.Pos[0] = floatDist(generator); - particle.Pos[1] = floatDist(generator); - particle.Pos[2] = floatDist(generator); - particle.Time = floatDist(generator); - particle.ID = pid++; - particle.NumSteps = nStepsDist(generator); + particle.SetPosition({ floatDist(generator), floatDist(generator), floatDist(generator) }); + particle.SetTime(floatDist(generator)); + particle.SetID(pid++); + particle.SetNumberOfSteps(nStepsDist(generator)); pvec.push_back(particle); std::vector bids(bidDist(generator)); diff --git a/vtkm/filter/flow/testing/UnitTestStreamlineFilter.cxx b/vtkm/filter/flow/testing/UnitTestStreamlineFilter.cxx index c138ddd7c..34116f632 100644 --- a/vtkm/filter/flow/testing/UnitTestStreamlineFilter.cxx +++ b/vtkm/filter/flow/testing/UnitTestStreamlineFilter.cxx @@ -195,7 +195,7 @@ void TestAMRStreamline(bool useSL) ghosts[idx] = vtkm::CellClassification::Normal; idx++; } - dsOuter.AddGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On)); + dsOuter.SetGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On)); //Create a partitioned dataset with 1 inner and 1 outer. vtkm::cont::PartitionedDataSet pds; diff --git a/vtkm/filter/flow/testing/UnitTestStreamlineFilterMPI.cxx b/vtkm/filter/flow/testing/UnitTestStreamlineFilterMPI.cxx index db3d2a89e..4f6aa647a 100644 --- a/vtkm/filter/flow/testing/UnitTestStreamlineFilterMPI.cxx +++ b/vtkm/filter/flow/testing/UnitTestStreamlineFilterMPI.cxx @@ -113,7 +113,7 @@ void TestAMRStreamline(FilterType fType, bool useThreaded) ghosts[idx] = vtkm::CellClassification::Normal; idx++; } - dsOuter.AddGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On)); + dsOuter.SetGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On)); //Create a partitioned dataset with 1 inner and 1 outer. vtkm::cont::PartitionedDataSet pds; diff --git a/vtkm/filter/flow/testing/UnitTestWorkletParticleAdvection.cxx b/vtkm/filter/flow/testing/UnitTestWorkletParticleAdvection.cxx index c33ee6d38..fafcbea42 100644 --- a/vtkm/filter/flow/testing/UnitTestWorkletParticleAdvection.cxx +++ b/vtkm/filter/flow/testing/UnitTestWorkletParticleAdvection.cxx @@ -147,7 +147,7 @@ public: vtkm::Vec3f& pointOut) const { vtkm::VecVariable values; - status = evaluator.Evaluate(pointIn.Pos, pointIn.Time, values); + status = evaluator.Evaluate(pointIn.GetPosition(), pointIn.GetTime(), values); pointOut = values[0]; } }; @@ -228,7 +228,7 @@ void ValidateIntegrator(const IntegratorType& integrator, vtkm::Vec3f result = resultsPortal.Get(index); VTKM_TEST_ASSERT(status.CheckOk(), "Error in evaluator for " + msg); if (status.CheckSpatialBounds()) - VTKM_TEST_ASSERT(result == pointsPortal.Get(index).Pos, + VTKM_TEST_ASSERT(result == pointsPortal.Get(index).GetPosition(), "Error in evaluator result for [OUTSIDE SPATIAL]" + msg); else VTKM_TEST_ASSERT(result == expStepResults[static_cast(index)], @@ -322,7 +322,7 @@ void TestEvaluators() GenerateRandomParticles(pointIns, 38, interiorBounds); for (auto& p : pointIns) - stepResult.push_back(p.Pos + vec * stepSize); + stepResult.push_back(p.GetPosition() + vec * stepSize); vtkm::Range xRange, yRange, zRange; @@ -414,14 +414,16 @@ void TestGhostCellEvaluators() for (vtkm::Id i = 0; i < numSeeds; i++) { const auto& p = posPortal.Get(i); - VTKM_TEST_ASSERT(p.Status.CheckSpatialBounds(), "Particle did not leave the dataset."); - VTKM_TEST_ASSERT(p.Status.CheckInGhostCell(), "Particle did not end up in ghost cell."); + VTKM_TEST_ASSERT(p.GetStatus().CheckSpatialBounds(), "Particle did not leave the dataset."); + VTKM_TEST_ASSERT(p.GetStatus().CheckInGhostCell(), "Particle did not end up in ghost cell."); //Particles that start in a ghost cell should take no steps. - if (p.ID == 0 || p.ID == 1 || p.ID == 2) - VTKM_TEST_ASSERT(p.NumSteps == 0, "Particle in ghost cell should *not* take any steps"); - else if (p.ID == 3) - VTKM_TEST_ASSERT(p.NumSteps == 21, "Wrong number of steps for particle with ghost cells"); + if (p.GetID() == 0 || p.GetID() == 1 || p.GetID() == 2) + VTKM_TEST_ASSERT(p.GetNumberOfSteps() == 0, + "Particle in ghost cell should *not* take any steps"); + else if (p.GetID() == 3) + VTKM_TEST_ASSERT(p.GetNumberOfSteps() == 21, + "Wrong number of steps for particle with ghost cells"); } } } @@ -436,8 +438,8 @@ void ValidateParticleAdvectionResult( auto portal = res.Particles.ReadPortal(); for (vtkm::Id i = 0; i < nSeeds; i++) { - auto stepsTaken = portal.Get(i).NumSteps; - auto status = portal.Get(i).Status; + auto stepsTaken = portal.Get(i).GetNumberOfSteps(); + auto status = portal.Get(i).GetStatus(); VTKM_TEST_ASSERT(stepsTaken <= maxSteps, "Too many steps taken in particle advection"); if (stepsTaken == maxSteps) VTKM_TEST_ASSERT(status.CheckTerminate(), "Particle expected to be terminated"); @@ -456,8 +458,9 @@ void ValidateStreamlineResult(const vtkm::worklet::flow::StreamlineResult(pts.size()); std::vector stepsTaken = { 10, 20, 600 }; for (std::size_t i = 0; i < stepsTaken.size(); i++) - pts2[i].NumSteps = stepsTaken[i]; + pts2[i].SetNumberOfSteps(stepsTaken[i]); for (auto& ds : dataSets) { @@ -644,10 +647,10 @@ void TestParticleStatus() pa.Run(rk4, seedsArray, maxSteps); auto portal = seedsArray.ReadPortal(); - bool tookStep0 = portal.Get(0).Status.CheckTookAnySteps(); - bool tookStep1 = portal.Get(1).Status.CheckTookAnySteps(); - bool isZero0 = portal.Get(0).Status.CheckZeroVelocity(); - bool isZero1 = portal.Get(1).Status.CheckZeroVelocity(); + bool tookStep0 = portal.Get(0).GetStatus().CheckTookAnySteps(); + bool tookStep1 = portal.Get(1).GetStatus().CheckTookAnySteps(); + bool isZero0 = portal.Get(0).GetStatus().CheckZeroVelocity(); + bool isZero1 = portal.Get(1).GetStatus().CheckZeroVelocity(); if (vtkm::Magnitude(vec) > 0) { @@ -662,7 +665,8 @@ void TestParticleStatus() VTKM_TEST_ASSERT(tookStep1 == false, "Particle took a step when it should not have."); VTKM_TEST_ASSERT(isZero0 == true, "Particle in zero velocity when it should not be."); VTKM_TEST_ASSERT(isZero1 == false, "Particle in zero velocity when it should not be."); - VTKM_TEST_ASSERT(portal.Get(0).NumSteps == 1, "Particle should have taken only 1 step."); + VTKM_TEST_ASSERT(portal.Get(0).GetNumberOfSteps() == 1, + "Particle should have taken only 1 step."); } } } @@ -744,14 +748,15 @@ void TestWorkletsBasic() auto portal = res.Particles.ReadPortal(); for (vtkm::Id i = 0; i < res.Particles.GetNumberOfValues(); i++) { - VTKM_TEST_ASSERT(portal.Get(i).Pos == endPts[static_cast(i)], + VTKM_TEST_ASSERT(portal.Get(i).GetPosition() == endPts[static_cast(i)], "Particle advection point is wrong"); - VTKM_TEST_ASSERT(portal.Get(i).NumSteps == maxSteps, + VTKM_TEST_ASSERT(portal.Get(i).GetNumberOfSteps() == maxSteps, "Particle advection NumSteps is wrong"); - VTKM_TEST_ASSERT(vtkm::Abs(portal.Get(i).Time - endT) < stepSize / 100, + VTKM_TEST_ASSERT(vtkm::Abs(portal.Get(i).GetTime() - endT) < stepSize / 100, "Particle advection Time is wrong"); - VTKM_TEST_ASSERT(portal.Get(i).Status.CheckOk(), "Particle advection Status is wrong"); - VTKM_TEST_ASSERT(portal.Get(i).Status.CheckTerminate(), + VTKM_TEST_ASSERT(portal.Get(i).GetStatus().CheckOk(), + "Particle advection Status is wrong"); + VTKM_TEST_ASSERT(portal.Get(i).GetStatus().CheckTerminate(), "Particle advection particle did not terminate"); } } @@ -770,13 +775,14 @@ void TestWorkletsBasic() auto parPortal = res.Particles.ReadPortal(); for (vtkm::Id i = 0; i < res.Particles.GetNumberOfValues(); i++) { - VTKM_TEST_ASSERT(parPortal.Get(i).Pos == endPts[static_cast(i)], + VTKM_TEST_ASSERT(parPortal.Get(i).GetPosition() == endPts[static_cast(i)], "Streamline end point is wrong"); - VTKM_TEST_ASSERT(parPortal.Get(i).NumSteps == maxSteps, "Streamline NumSteps is wrong"); - VTKM_TEST_ASSERT(vtkm::Abs(parPortal.Get(i).Time - endT) < stepSize / 100, + VTKM_TEST_ASSERT(parPortal.Get(i).GetNumberOfSteps() == maxSteps, + "Streamline NumSteps is wrong"); + VTKM_TEST_ASSERT(vtkm::Abs(parPortal.Get(i).GetTime() - endT) < stepSize / 100, "Streamline Time is wrong"); - VTKM_TEST_ASSERT(parPortal.Get(i).Status.CheckOk(), "Streamline Status is wrong"); - VTKM_TEST_ASSERT(parPortal.Get(i).Status.CheckTerminate(), + VTKM_TEST_ASSERT(parPortal.Get(i).GetStatus().CheckOk(), "Streamline Status is wrong"); + VTKM_TEST_ASSERT(parPortal.Get(i).GetStatus().CheckTerminate(), "Streamline particle did not terminate"); } @@ -815,17 +821,19 @@ void ValidateResult(const ResultType& res, auto portal = res.Particles.ReadPortal(); for (vtkm::Id i = 0; i < 3; i++) { - vtkm::Vec3f p = portal.Get(i).Pos; + vtkm::Vec3f p = portal.Get(i).GetPosition(); vtkm::Vec3f e = endPts[static_cast(i)]; VTKM_TEST_ASSERT(vtkm::Magnitude(p - e) <= eps, "Particle advection point is wrong"); - if (portal.Get(i).Status.CheckZeroVelocity()) - VTKM_TEST_ASSERT(portal.Get(i).NumSteps > 0, "Particle advection NumSteps is wrong"); + if (portal.Get(i).GetStatus().CheckZeroVelocity()) + VTKM_TEST_ASSERT(portal.Get(i).GetNumberOfSteps() > 0, + "Particle advection NumSteps is wrong"); else - VTKM_TEST_ASSERT(portal.Get(i).NumSteps == maxSteps, "Particle advection NumSteps is wrong"); - VTKM_TEST_ASSERT(portal.Get(i).Status.CheckOk(), "Particle advection Status is wrong"); - VTKM_TEST_ASSERT(portal.Get(i).Status.CheckTerminate(), + VTKM_TEST_ASSERT(portal.Get(i).GetNumberOfSteps() == maxSteps, + "Particle advection NumSteps is wrong"); + VTKM_TEST_ASSERT(portal.Get(i).GetStatus().CheckOk(), "Particle advection Status is wrong"); + VTKM_TEST_ASSERT(portal.Get(i).GetStatus().CheckTerminate(), "Particle advection particle did not terminate"); } } diff --git a/vtkm/filter/flow/testing/UnitTestWorkletTemporalAdvection.cxx b/vtkm/filter/flow/testing/UnitTestWorkletTemporalAdvection.cxx index 9cb4ddbe3..ee6bd2778 100644 --- a/vtkm/filter/flow/testing/UnitTestWorkletTemporalAdvection.cxx +++ b/vtkm/filter/flow/testing/UnitTestWorkletTemporalAdvection.cxx @@ -57,7 +57,7 @@ public: vtkm::Vec3f& pointOut) const { vtkm::VecVariable values; - status = evaluator.Evaluate(pointIn.Pos, 0.5f, values); + status = evaluator.Evaluate(pointIn.GetPosition(), 0.5f, values); if (values.GetNumberOfComponents() > 0) pointOut = values[0]; } diff --git a/vtkm/filter/flow/vtkm.module b/vtkm/filter/flow/vtkm.module new file mode 100644 index 000000000..db96f62ae --- /dev/null +++ b/vtkm/filter/flow/vtkm.module @@ -0,0 +1,17 @@ +NAME + vtkm_filter_flow +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +OPTIONAL_DEPENDS + MPI::MPI_CXX +TEST_DEPENDS + vtkm_filter_geometry_refinement + vtkm_filter_mesh_info + vtkm_io +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing + MPI::MPI_CXX diff --git a/vtkm/filter/flow/worklet/EulerIntegrator.h b/vtkm/filter/flow/worklet/EulerIntegrator.h index cc67f20a0..bcd0e74c1 100644 --- a/vtkm/filter/flow/worklet/EulerIntegrator.h +++ b/vtkm/filter/flow/worklet/EulerIntegrator.h @@ -38,7 +38,7 @@ public: vtkm::FloatDefault stepLength, vtkm::Vec3f& velocity) const { - auto time = particle.Time; + auto time = particle.GetTime(); auto inpos = particle.GetEvaluationPosition(stepLength); vtkm::VecVariable vectors; GridEvaluatorStatus evalStatus = this->Evaluator.Evaluate(inpos, time, vectors); diff --git a/vtkm/filter/flow/worklet/ParticleAdvection.h b/vtkm/filter/flow/worklet/ParticleAdvection.h index fa28c9ae6..78e3c2040 100644 --- a/vtkm/filter/flow/worklet/ParticleAdvection.h +++ b/vtkm/filter/flow/worklet/ParticleAdvection.h @@ -38,11 +38,11 @@ public: const vtkm::Id& step, ParticleType& particle) const { - particle.Pos = pt; - particle.ID = id; - particle.Time = time; - particle.NumSteps = step; - particle.Status.SetOk(); + particle.SetPosition(pt); + particle.SetID(id); + particle.SetTime(time); + particle.SetNumberOfSteps(step); + particle.GetStatus().SetOk(); } }; diff --git a/vtkm/filter/flow/worklet/ParticleAdvectionWorklets.h b/vtkm/filter/flow/worklet/ParticleAdvectionWorklets.h index af3d5a730..1a4e76bb3 100644 --- a/vtkm/filter/flow/worklet/ParticleAdvectionWorklets.h +++ b/vtkm/filter/flow/worklet/ParticleAdvectionWorklets.h @@ -48,7 +48,7 @@ public: const vtkm::Id& maxSteps) const { auto particle = integralCurve.GetParticle(idx); - vtkm::FloatDefault time = particle.Time; + vtkm::FloatDefault time = particle.GetTime(); bool tookAnySteps = false; //the integrator status needs to be more robust: @@ -143,7 +143,7 @@ public: template VTKM_EXEC void operator()(const ParticleType& p, vtkm::Id& numSteps) const { - numSteps = p.NumSteps; + numSteps = p.GetNumberOfSteps(); } }; @@ -156,13 +156,13 @@ public: using ExecutionSignature = void(_1, _2, _3); // Offset is number of points in streamline. - // 1 (inital point) + number of steps taken (p.NumSteps - initalNumSteps) + // 1 (inital point) + number of steps taken (p.GetNumberOfSteps() - initalNumSteps) template VTKM_EXEC void operator()(const ParticleType& p, const vtkm::Id& initialNumSteps, vtkm::Id& diff) const { - diff = 1 + p.NumSteps - initialNumSteps; + diff = 1 + p.GetNumberOfSteps() - initialNumSteps; } }; } // namespace detail diff --git a/vtkm/filter/flow/worklet/Particles.h b/vtkm/filter/flow/worklet/Particles.h index 68e7ade33..47bff9c0b 100644 --- a/vtkm/filter/flow/worklet/Particles.h +++ b/vtkm/filter/flow/worklet/Particles.h @@ -54,9 +54,9 @@ public: const vtkm::Vec3f& pt) { ParticleType newParticle(particle); - newParticle.Pos = pt; - newParticle.Time = time; - newParticle.NumSteps++; + newParticle.SetPosition(pt); + newParticle.SetTime(time); + newParticle.SetNumberOfSteps(particle.GetNumberOfSteps() + 1); this->Particles.Set(idx, newParticle); } @@ -67,37 +67,37 @@ public: { ParticleType p(this->GetParticle(idx)); - if (p.NumSteps == maxSteps) - p.Status.SetTerminate(); + if (p.GetNumberOfSteps() == maxSteps) + p.GetStatus().SetTerminate(); if (status.CheckFail()) - p.Status.SetFail(); + p.GetStatus().SetFail(); if (status.CheckSpatialBounds()) - p.Status.SetSpatialBounds(); + p.GetStatus().SetSpatialBounds(); if (status.CheckTemporalBounds()) - p.Status.SetTemporalBounds(); + p.GetStatus().SetTemporalBounds(); if (status.CheckInGhostCell()) - p.Status.SetInGhostCell(); + p.GetStatus().SetInGhostCell(); if (status.CheckZeroVelocity()) { - p.Status.SetZeroVelocity(); - p.Status.SetTerminate(); + p.GetStatus().SetZeroVelocity(); + p.GetStatus().SetTerminate(); } this->Particles.Set(idx, p); } VTKM_EXEC - bool CanContinue(const vtkm::Id& idx) { return this->GetParticle(idx).Status.CanContinue(); } + bool CanContinue(const vtkm::Id& idx) { return this->GetParticle(idx).GetStatus().CanContinue(); } VTKM_EXEC void UpdateTookSteps(const vtkm::Id& idx, bool val) { ParticleType p(this->GetParticle(idx)); if (val) - p.Status.SetTookAnySteps(); + p.GetStatus().SetTookAnySteps(); else - p.Status.ClearTookAnySteps(); + p.GetStatus().ClearTookAnySteps(); this->Particles.Set(idx, p); } @@ -172,7 +172,7 @@ public: if (this->StepCount.Get(idx) == 0) { vtkm::Id loc = idx * Length; - this->History.Set(loc, p.Pos); + this->History.Set(loc, p.GetPosition()); this->ValidPoint.Set(loc, 1); this->StepCount.Set(idx, 1); } diff --git a/vtkm/filter/flow/worklet/RK4Integrator.h b/vtkm/filter/flow/worklet/RK4Integrator.h index 7147a8a65..15653301e 100644 --- a/vtkm/filter/flow/worklet/RK4Integrator.h +++ b/vtkm/filter/flow/worklet/RK4Integrator.h @@ -38,7 +38,7 @@ public: vtkm::FloatDefault stepLength, vtkm::Vec3f& velocity) const { - auto time = particle.Time; + auto time = particle.GetTime(); auto inpos = particle.GetEvaluationPosition(stepLength); vtkm::FloatDefault boundary = this->Evaluator.GetTemporalBoundary(static_cast(1)); if ((time + stepLength + vtkm::Epsilon() - boundary) > 0.0) diff --git a/vtkm/filter/flow/worklet/Stepper.h b/vtkm/filter/flow/worklet/Stepper.h index b1872b7c6..082953c08 100644 --- a/vtkm/filter/flow/worklet/Stepper.h +++ b/vtkm/filter/flow/worklet/Stepper.h @@ -57,11 +57,11 @@ public: auto status = this->Integrator.CheckStep(particle, this->DeltaT, velocity); if (status.CheckOk()) { - outpos = particle.Pos + this->DeltaT * velocity; + outpos = particle.GetPosition() + this->DeltaT * velocity; time += this->DeltaT; } else - outpos = particle.Pos; + outpos = particle.GetPosition(); return status; } @@ -84,7 +84,7 @@ public: vtkm::Vec3f currPos(particle.GetEvaluationPosition(this->DeltaT)); vtkm::Vec3f currVelocity(0, 0, 0); vtkm::VecVariable currValue, tmp; - auto evalStatus = this->Evaluator.Evaluate(currPos, particle.Time, currValue); + auto evalStatus = this->Evaluator.Evaluate(currPos, particle.GetTime(), currValue); if (evalStatus.CheckFail()) return IntegratorStatus(evalStatus, false); @@ -102,8 +102,8 @@ public: if (status.CheckOk()) //Integration step succedded. { //See if this point is in/out. - auto newPos = particle.Pos + currStep * currVelocity; - evalStatus = this->Evaluator.Evaluate(newPos, particle.Time + currStep, tmp); + auto newPos = particle.GetPosition() + currStep * currVelocity; + evalStatus = this->Evaluator.Evaluate(newPos, particle.GetTime() + currStep, tmp); if (evalStatus.CheckOk()) { //Point still in. Update currPos and set range to {currStep, stepRange[1]} @@ -124,7 +124,7 @@ public: } } - evalStatus = this->Evaluator.Evaluate(currPos, particle.Time + stepRange[0], currValue); + evalStatus = this->Evaluator.Evaluate(currPos, particle.GetTime() + stepRange[0], currValue); // The eval at Time + stepRange[0] better be *inside* VTKM_ASSERT(evalStatus.CheckOk() && !evalStatus.CheckSpatialBounds()); if (evalStatus.CheckFail() || evalStatus.CheckSpatialBounds()) diff --git a/vtkm/filter/geometry_refinement/CMakeLists.txt b/vtkm/filter/geometry_refinement/CMakeLists.txt index b3acace96..ff52259c9 100644 --- a/vtkm/filter/geometry_refinement/CMakeLists.txt +++ b/vtkm/filter/geometry_refinement/CMakeLists.txt @@ -34,8 +34,3 @@ target_link_libraries(vtkm_filter_geometry_refinement PUBLIC vtkm_worklet vtkm_f target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_geometry_refinement) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/geometry_refinement/SplitSharpEdges.h b/vtkm/filter/geometry_refinement/SplitSharpEdges.h index 81ef19578..a760e3c0e 100644 --- a/vtkm/filter/geometry_refinement/SplitSharpEdges.h +++ b/vtkm/filter/geometry_refinement/SplitSharpEdges.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_geometry_refinement_SplitSharpEdges_h #define vtk_m_filter_geometry_refinement_SplitSharpEdges_h -#include +#include #include namespace vtkm @@ -33,7 +33,7 @@ namespace geometry_refinement /// to (5,4,3). /// By default, all old point's fields would be copied to the new point. /// Use with caution. -class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT SplitSharpEdges : public vtkm::filter::NewFilterField +class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT SplitSharpEdges : public vtkm::filter::FilterField { public: VTKM_CONT @@ -48,12 +48,6 @@ private: vtkm::FloatDefault FeatureAngle = 30.0; }; } // namespace geometry_refinement -class VTKM_DEPRECATED(1.8, - "Use vtkm::filter::geometry_refinement::SplitSharpEdges.") SplitSharpEdges - : public vtkm::filter::geometry_refinement::SplitSharpEdges -{ - using geometry_refinement::SplitSharpEdges::SplitSharpEdges; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/geometry_refinement/Tetrahedralize.h b/vtkm/filter/geometry_refinement/Tetrahedralize.h index 963422962..96bf07a5d 100644 --- a/vtkm/filter/geometry_refinement/Tetrahedralize.h +++ b/vtkm/filter/geometry_refinement/Tetrahedralize.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_geometry_refinement_Tetrahedralize_h #define vtk_m_filter_geometry_refinement_Tetrahedralize_h -#include +#include #include namespace vtkm @@ -20,16 +20,11 @@ namespace filter { namespace geometry_refinement { -class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Tetrahedralize : public vtkm::filter::NewFilter +class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Tetrahedralize : public vtkm::filter::Filter { VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace geometry_refinement -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::geometry_refinement::Tetrahedralize.") Tetrahedralize - : public vtkm::filter::geometry_refinement::Tetrahedralize -{ - using geometry_refinement::Tetrahedralize::Tetrahedralize; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/geometry_refinement/Triangulate.h b/vtkm/filter/geometry_refinement/Triangulate.h index c57245397..081bbcd58 100644 --- a/vtkm/filter/geometry_refinement/Triangulate.h +++ b/vtkm/filter/geometry_refinement/Triangulate.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_geometry_refinement_Triangulate_h #define vtk_m_filter_geometry_refinement_Triangulate_h -#include +#include #include namespace vtkm @@ -20,16 +20,11 @@ namespace filter { namespace geometry_refinement { -class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Triangulate : public vtkm::filter::NewFilter +class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Triangulate : public vtkm::filter::Filter { VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace geometry_refinement -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::geometry_refinement::Triangulate.") Triangulate - : public vtkm::filter::geometry_refinement::Triangulate -{ - using geometry_refinement::Triangulate::Triangulate; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/geometry_refinement/Tube.h b/vtkm/filter/geometry_refinement/Tube.h index 786c9f7c3..a9d510f04 100644 --- a/vtkm/filter/geometry_refinement/Tube.h +++ b/vtkm/filter/geometry_refinement/Tube.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_geometry_refinement_Tube_h #define vtk_m_filter_geometry_refinement_Tube_h -#include +#include #include namespace vtkm @@ -25,7 +25,7 @@ namespace geometry_refinement /// Takes as input a set of polylines, radius, num sides and capping flag. /// Produces tubes along each polyline -class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Tube : public vtkm::filter::NewFilterField +class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT Tube : public vtkm::filter::FilterField { public: VTKM_CONT @@ -45,11 +45,6 @@ private: bool Capping{}; }; } // namespace geometry_refinement -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::geometry_refinement::Tube.") Tube - : public vtkm::filter::geometry_refinement::Tube -{ - using geometry_refinement::Tube::Tube; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/geometry_refinement/VertexClustering.cxx b/vtkm/filter/geometry_refinement/VertexClustering.cxx index cb751e7f1..7effbe102 100644 --- a/vtkm/filter/geometry_refinement/VertexClustering.cxx +++ b/vtkm/filter/geometry_refinement/VertexClustering.cxx @@ -62,8 +62,8 @@ VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute(const vtkm::cont::Data outCoords); auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; - return this->CreateResult( - input, outCellSet, vtkm::cont::CoordinateSystem("coordinates", outCoords), mapper); + return this->CreateResultCoordinateSystem( + input, outCellSet, input.GetCoordinateSystem().GetName(), outCoords, mapper); } } // namespace geometry_refinement } // namespace filter diff --git a/vtkm/filter/geometry_refinement/VertexClustering.h b/vtkm/filter/geometry_refinement/VertexClustering.h index 9371e2f5e..dd681e366 100644 --- a/vtkm/filter/geometry_refinement/VertexClustering.h +++ b/vtkm/filter/geometry_refinement/VertexClustering.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_geometry_refinement_VertexClustering_h #define vtk_m_filter_geometry_refinement_VertexClustering_h -#include +#include #include namespace vtkm @@ -48,7 +48,7 @@ namespace geometry_refinement /// @warning /// This filter currently doesn't propagate cell or point fields -class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT VertexClustering : public vtkm::filter::NewFilter +class VTKM_FILTER_GEOMETRY_REFINEMENT_EXPORT VertexClustering : public vtkm::filter::Filter { public: VTKM_CONT @@ -63,12 +63,6 @@ private: vtkm::Id3 NumberOfDivisions = { 256, 256, 256 }; }; } // namespace geometry_refinement -class VTKM_DEPRECATED(1.8, - "Use vtkm::filter::geometry_refinement::VertexClustering.") VertexClustering - : public vtkm::filter::geometry_refinement::VertexClustering -{ - using geometry_refinement::VertexClustering::VertexClustering; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/geometry_refinement/testing/UnitTestSplitSharpEdgesFilter.cxx b/vtkm/filter/geometry_refinement/testing/UnitTestSplitSharpEdgesFilter.cxx index bc98ee603..76f0e1ff2 100644 --- a/vtkm/filter/geometry_refinement/testing/UnitTestSplitSharpEdgesFilter.cxx +++ b/vtkm/filter/geometry_refinement/testing/UnitTestSplitSharpEdgesFilter.cxx @@ -113,7 +113,8 @@ vtkm::cont::DataSet Make3DExplicitSimpleCube() vtkm::cont::DataSet Make3DWavelet() { - vtkm::source::Wavelet wavelet({ -25 }, { 25 }); + vtkm::source::Wavelet wavelet; + wavelet.SetExtent({ -25 }, { 25 }); wavelet.SetFrequency({ 60, 30, 40 }); wavelet.SetMagnitude({ 5 }); diff --git a/vtkm/filter/geometry_refinement/testing/UnitTestTubeFilter.cxx b/vtkm/filter/geometry_refinement/testing/UnitTestTubeFilter.cxx index a6a7e8736..560f11566 100644 --- a/vtkm/filter/geometry_refinement/testing/UnitTestTubeFilter.cxx +++ b/vtkm/filter/geometry_refinement/testing/UnitTestTubeFilter.cxx @@ -62,14 +62,12 @@ void TestTubeFilters() ptVar.push_back(1); ptVar.push_back(2); cellVar.push_back(100); - cellVar.push_back(101); //Polyline 2. ptVar.push_back(10); ptVar.push_back(11); ptVar.push_back(12); cellVar.push_back(110); - cellVar.push_back(111); //Add some degenerate polylines. //Polyline 3: (only 1 point) @@ -79,7 +77,6 @@ void TestTubeFilters() ptVar.push_back(-1); ptVar.push_back(-1); cellVar.push_back(-1); - cellVar.push_back(-1); ds.AddPointField("pointVar", ptVar); ds.AddCellField("cellVar", cellVar); @@ -117,10 +114,10 @@ void TestTubeFilters() vtkm::cont::ArrayHandle cellArr; output.GetField("cellVar").GetData().AsArrayHandle(cellArr); VTKM_TEST_ASSERT(cellArr.GetNumberOfValues() == 36, "Wrong number of values in cell field"); - std::vector cellVals = { 100, 100, 100, 100, 100, 100, 101, 101, 101, - 101, 101, 101, 100, 100, 100, 101, 101, 101, - 110, 110, 110, 110, 110, 110, 111, 111, 111, - 111, 111, 111, 110, 110, 110, 111, 111, 111 }; + std::vector cellVals = { 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, + 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110 }; portal = cellArr.ReadPortal(); for (vtkm::Id i = 0; i < 36; i++) VTKM_TEST_ASSERT(portal.Get(i) == cellVals[static_cast(i)], diff --git a/vtkm/filter/geometry_refinement/vtkm.module b/vtkm/filter/geometry_refinement/vtkm.module new file mode 100644 index 000000000..1b7fb2151 --- /dev/null +++ b/vtkm/filter/geometry_refinement/vtkm.module @@ -0,0 +1,18 @@ +NAME + vtkm_filter_geometry_refinement +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_contour + vtkm_filter_field_conversion + vtkm_filter_geometry_refinement + vtkm_filter_vector_analysis + vtkm_source +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing + vtkm_rendering diff --git a/vtkm/filter/geometry_refinement/worklet/SplitSharpEdges.h b/vtkm/filter/geometry_refinement/worklet/SplitSharpEdges.h index a949f5e91..6775aa1d7 100644 --- a/vtkm/filter/geometry_refinement/worklet/SplitSharpEdges.h +++ b/vtkm/filter/geometry_refinement/worklet/SplitSharpEdges.h @@ -475,7 +475,7 @@ public: // Create the new cellset - CellDeepCopy::Run(oldCellset, newCellset); + CellDeepCopy::Run(oldCellset, newCellset, this->NewPointsIdArray.GetNumberOfValues()); // FIXME: Since the non const get array function is not in CellSetExplict.h, // here I just get a non-const copy of the array handle. auto connectivityArrayHandle = newCellset.GetConnectivityArray(vtkm::TopologyElementTagCell(), diff --git a/vtkm/filter/geometry_refinement/worklet/Tube.h b/vtkm/filter/geometry_refinement/worklet/Tube.h index 22be15f6e..981e8e034 100644 --- a/vtkm/filter/geometry_refinement/worklet/Tube.h +++ b/vtkm/filter/geometry_refinement/worklet/Tube.h @@ -48,7 +48,6 @@ public: FieldOut ptsPerPolyline, FieldOut ptsPerTube, FieldOut numTubeConnIds, - FieldOut linesPerPolyline, FieldOut validCell); using ExecutionSignature = void(CellShape shapeType, PointCount numPoints, @@ -58,8 +57,7 @@ public: _4 ptsPerPolyline, _5 ptsPerTube, _6 numTubeConnIds, - _7 linesPerPolyline, - _8 validCell); + _7 validCell); using InputDomain = _1; template @@ -71,7 +69,6 @@ public: vtkm::Id& ptsPerPolyline, vtkm::Id& ptsPerTube, vtkm::Id& numTubeConnIds, - vtkm::Id& linesPerPolyline, vtkm::Id& validCell) const { // We only support polylines that contain 2 or more points. @@ -97,7 +94,6 @@ public: ptsPerTube = this->NumSides * numNonCoincidentPoints; // (two tris per segment) X (numSides) X numVertsPerCell numTubeConnIds = (numNonCoincidentPoints - 1) * 2 * this->NumSides * this->NumVertsPerCell; - linesPerPolyline = numNonCoincidentPoints - 1; //Capping adds center vertex in middle of cap, plus NumSides triangles for cap. if (this->Capping) @@ -113,7 +109,6 @@ public: nonIncidentPtsPerPolyline = 0; ptsPerTube = 0; numTubeConnIds = 0; - linesPerPolyline = 0; } } @@ -481,24 +476,23 @@ public: FieldInCell ptsPerPolyline, FieldInCell tubePointOffsets, FieldInCell tubeConnOffsets, - FieldInCell segOffset, WholeArrayOut outConnectivity, WholeArrayOut outCellSrcIdx); using ExecutionSignature = void(CellShape shapeType, + InputIndex inCellIndex, _2 ptsPerPolyline, _3 tubePointOffset, _4 tubeConnOffsets, - _5 segOffset, - _6 outConn, - _7 outCellSrcIdx); + _5 outConn, + _6 outCellSrcIdx); using InputDomain = _1; template VTKM_EXEC void operator()(const CellShapeTag& shapeType, + vtkm::Id inCellIndex, const vtkm::IdComponent& numPoints, const vtkm::Id& tubePointOffset, const vtkm::Id& tubeConnOffset, - const vtkm::Id& segOffset, OutConnType& outConn, OutCellSrcIdxType& outCellSrcIdx) const { @@ -517,7 +511,7 @@ public: outConn.Set(outIdx + 1, tubePtOffset + i * this->NumSides + (j + 1) % this->NumSides); outConn.Set(outIdx + 2, tubePtOffset + (i + 1) * this->NumSides + (j + 1) % this->NumSides); - outCellSrcIdx.Set(outIdx / 3, segOffset + static_cast(i)); + outCellSrcIdx.Set(outIdx / 3, inCellIndex); outIdx += 3; //Triangle 2: verts 0,2,3 @@ -525,7 +519,7 @@ public: outConn.Set(outIdx + 1, tubePtOffset + (i + 1) * this->NumSides + (j + 1) % this->NumSides); outConn.Set(outIdx + 2, tubePtOffset + (i + 1) * this->NumSides + j); - outCellSrcIdx.Set(outIdx / 3, segOffset + static_cast(i)); + outCellSrcIdx.Set(outIdx / 3, inCellIndex); outIdx += 3; } } @@ -539,7 +533,7 @@ public: outConn.Set(outIdx + 0, startCenterPt); outConn.Set(outIdx + 1, startCenterPt + 1 + j); outConn.Set(outIdx + 2, startCenterPt + 1 + ((j + 1) % this->NumSides)); - outCellSrcIdx.Set(outIdx / 3, segOffset); + outCellSrcIdx.Set(outIdx / 3, inCellIndex); outIdx += 3; } @@ -552,7 +546,7 @@ public: outConn.Set(outIdx + 0, endCenterPt); outConn.Set(outIdx + 1, endOffsetPt + j); outConn.Set(outIdx + 2, endOffsetPt + ((j + 1) % this->NumSides)); - outCellSrcIdx.Set(outIdx / 3, segOffset + static_cast(numPoints - 2)); + outCellSrcIdx.Set(outIdx / 3, inCellIndex); outIdx += 3; } } @@ -622,8 +616,7 @@ public: } //Count number of polyline pts, tube pts and tube cells - vtkm::cont::ArrayHandle ptsPerPolyline, ptsPerTube, numTubeConnIds, segPerPolyline, - validCell; + vtkm::cont::ArrayHandle ptsPerPolyline, ptsPerTube, numTubeConnIds, validCell; vtkm::cont::ArrayHandle nonIncidentPtsPerPolyline; CountSegments countSegs(this->Capping, this->NumSides); vtkm::worklet::DispatcherMapTopology countInvoker(countSegs); @@ -633,7 +626,6 @@ public: ptsPerPolyline, ptsPerTube, numTubeConnIds, - segPerPolyline, validCell); vtkm::Id totalPolylinePts = vtkm::cont::Algorithm::Reduce(ptsPerPolyline, vtkm::Id(0)); @@ -645,14 +637,13 @@ public: vtkm::Id totalTubeCells = totalTubeConnIds / 3; vtkm::cont::ArrayHandle polylinePtOffset, nonIncidentPolylinePtOffset, - tubePointOffsets, tubeConnOffsets, segOffset; + tubePointOffsets, tubeConnOffsets; vtkm::cont::Algorithm::ScanExclusive(ptsPerPolyline, polylinePtOffset); vtkm::cont::Algorithm::ScanExclusive( vtkm::cont::make_ArrayHandleCast(nonIncidentPtsPerPolyline), nonIncidentPolylinePtOffset); vtkm::cont::Algorithm::ScanExclusive(ptsPerTube, tubePointOffsets); vtkm::cont::Algorithm::ScanExclusive(numTubeConnIds, tubeConnOffsets); - vtkm::cont::Algorithm::ScanExclusive(segPerPolyline, segOffset); //Generate normals at each point on all polylines NormalsType normals; @@ -686,7 +677,6 @@ public: nonIncidentPtsPerPolyline, tubePointOffsets, tubeConnOffsets, - segOffset, newConnectivity, this->OutputCellSourceIndex); newCells.Fill(totalTubePts, vtkm::CELL_SHAPE_TRIANGLE, 3, newConnectivity); diff --git a/vtkm/filter/image_processing/CMakeLists.txt b/vtkm/filter/image_processing/CMakeLists.txt index e5f030cd3..78dee4573 100644 --- a/vtkm/filter/image_processing/CMakeLists.txt +++ b/vtkm/filter/image_processing/CMakeLists.txt @@ -26,12 +26,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_image_processing PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_image_processing) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/image_processing/ComputeMoments.h b/vtkm/filter/image_processing/ComputeMoments.h index 67f97c369..f0e1ae6d3 100644 --- a/vtkm/filter/image_processing/ComputeMoments.h +++ b/vtkm/filter/image_processing/ComputeMoments.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_image_processing_ComputeMoments_h #define vtk_m_filter_image_processing_ComputeMoments_h -#include +#include #include namespace vtkm @@ -19,7 +19,7 @@ namespace filter { namespace image_processing { -class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ComputeMoments : public vtkm::filter::NewFilterField +class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ComputeMoments : public vtkm::filter::FilterField { public: VTKM_CONT ComputeMoments(); @@ -38,11 +38,6 @@ private: vtkm::Int32 Order = 0; }; } // namespace image_processing -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::image_processing::ComputeMoments.") ComputeMoments - : public vtkm::filter::image_processing::ComputeMoments -{ - using image_processing::ComputeMoments::ComputeMoments; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/image_processing/ImageDifference.h b/vtkm/filter/image_processing/ImageDifference.h index bd5be6e76..bd473b670 100644 --- a/vtkm/filter/image_processing/ImageDifference.h +++ b/vtkm/filter/image_processing/ImageDifference.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_image_processing_ImageDifference_h #define vtk_m_filter_image_processing_ImageDifference_h -#include +#include #include namespace vtkm @@ -29,7 +29,7 @@ namespace image_processing /// The threshold-output is calculated for each pixel using the `vtkm::Magnitude` vector function /// on the individual pixel difference. /// -class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ImageDifference : public vtkm::filter::NewFilterField +class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ImageDifference : public vtkm::filter::FilterField { public: VTKM_CONT ImageDifference(); @@ -108,11 +108,6 @@ private: std::string ThresholdFieldName = "threshold-output"; }; } // namespace image_processing -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::image_processing::ImageDifference.") ImageDifference - : public vtkm::filter::image_processing::ImageDifference -{ - using image_processing::ImageDifference::ImageDifference; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/image_processing/ImageMedian.h b/vtkm/filter/image_processing/ImageMedian.h index 3fc007717..46f8cde84 100644 --- a/vtkm/filter/image_processing/ImageMedian.h +++ b/vtkm/filter/image_processing/ImageMedian.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_image_processing_ImageMedian_h #define vtk_m_filter_image_processing_ImageMedian_h -#include +#include #include /// \brief Median algorithm for general image blur @@ -30,7 +30,7 @@ namespace filter { namespace image_processing { -class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ImageMedian : public vtkm::filter::NewFilterField +class VTKM_FILTER_IMAGE_PROCESSING_EXPORT ImageMedian : public vtkm::filter::FilterField { public: VTKM_CONT ImageMedian() { this->SetOutputFieldName("median"); } @@ -44,11 +44,6 @@ private: int Neighborhood = 1; }; } // namespace image_processing -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::image_processing::ImageMedian.") ImageMedian - : public vtkm::filter::image_processing::ImageMedian -{ - using image_processing::ImageMedian::ImageMedian; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/image_processing/vtkm.module b/vtkm/filter/image_processing/vtkm.module new file mode 100644 index 000000000..5fdd1257c --- /dev/null +++ b/vtkm/filter/image_processing/vtkm.module @@ -0,0 +1,11 @@ +NAME + vtkm_filter_image_processing +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_source diff --git a/vtkm/filter/internal/ResolveFieldTypeAndExecute.h b/vtkm/filter/internal/ResolveFieldTypeAndExecute.h deleted file mode 100644 index 767f658fd..000000000 --- a/vtkm/filter/internal/ResolveFieldTypeAndExecute.h +++ /dev/null @@ -1,48 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_internal_ResolveFieldTypeAndExecute_h -#define vtk_m_filter_internal_ResolveFieldTypeAndExecute_h - -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ -namespace internal -{ - -struct VTKM_ALWAYS_EXPORT ResolveFieldTypeAndExecute -{ - template - void operator()(const vtkm::cont::ArrayHandle& field, - DerivedClass* derivedClass, - const vtkm::cont::DataSet& inputData, - const vtkm::filter::FieldMetadata& fieldMeta, - vtkm::filter::PolicyBase policy, - ResultType& result) - { - result = derivedClass->DoExecute(inputData, field, fieldMeta, policy); - } -}; -} -} -} // namespace vtkm::filter::internal - -#endif //vtk_m_filter_internal_ResolveFieldTypeAndExecute_h diff --git a/vtkm/filter/internal/ResolveFieldTypeAndMap.h b/vtkm/filter/internal/ResolveFieldTypeAndMap.h deleted file mode 100644 index 3c051a563..000000000 --- a/vtkm/filter/internal/ResolveFieldTypeAndMap.h +++ /dev/null @@ -1,65 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_filter_internal_ResolveFieldTypeAndMap_h -#define vtk_m_filter_internal_ResolveFieldTypeAndMap_h - -#include -#include -#include - -#include -#include - -namespace vtkm -{ -namespace filter -{ -namespace internal -{ - -template -struct ResolveFieldTypeAndMap -{ - using Self = ResolveFieldTypeAndMap; - - Derived* DerivedClass; - vtkm::cont::DataSet& InputResult; - const vtkm::filter::FieldMetadata& Metadata; - const vtkm::filter::PolicyBase& Policy; - bool& RanProperly; - - ResolveFieldTypeAndMap(Derived* derivedClass, - vtkm::cont::DataSet& inResult, - const vtkm::filter::FieldMetadata& fieldMeta, - const vtkm::filter::PolicyBase& policy, - bool& ran) - : DerivedClass(derivedClass) - , InputResult(inResult) - , Metadata(fieldMeta) - , Policy(policy) - , RanProperly(ran) - { - } - - template - void operator()(const vtkm::cont::ArrayHandle& field) const - { - this->RanProperly = - this->DerivedClass->DoMapField(this->InputResult, field, this->Metadata, this->Policy); - } - -private: - void operator=(const ResolveFieldTypeAndMap&) = delete; -}; -} -} -} // namespace vtkm::filter::internal - -#endif //vtk_m_filter_internal_ResolveFieldTypeAndMap_h diff --git a/vtkm/filter/mesh_info/CMakeLists.txt b/vtkm/filter/mesh_info/CMakeLists.txt index 64a06fce4..998a17b0d 100644 --- a/vtkm/filter/mesh_info/CMakeLists.txt +++ b/vtkm/filter/mesh_info/CMakeLists.txt @@ -70,12 +70,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_mesh_info PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_mesh_info) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/mesh_info/CellMeasures.h b/vtkm/filter/mesh_info/CellMeasures.h index ad89e0db2..92afb78a2 100644 --- a/vtkm/filter/mesh_info/CellMeasures.h +++ b/vtkm/filter/mesh_info/CellMeasures.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_mesh_info_CellMeasures_h #define vtk_m_filter_mesh_info_CellMeasures_h -#include +#include #include namespace vtkm @@ -47,7 +47,7 @@ VTKM_EXEC_CONT inline IntegrationType operator|(IntegrationType left, Integratio /// or 0 (if measure is not well defined or the cell type is unsupported). /// /// By default, the new cell-data array is named "measure". -class VTKM_FILTER_MESH_INFO_EXPORT CellMeasures : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT CellMeasures : public vtkm::filter::FilterField { public: VTKM_CONT @@ -66,83 +66,4 @@ private: } // namespace filter } // namespace vtkm -// Implement the deprecated functionality of vtkm::filter::CellMeasures, which was moved into the -// mesh_info namespace (along with some other API changes). Everything below this line (up to the -// #endif for the include guard) can be deleted once the deprecated functionality is removed. - -// Don't warn about deprecation while implementing deprecated functionality. -VTKM_DEPRECATED_SUPPRESS_BEGIN - -namespace vtkm -{ - -struct VTKM_DEPRECATED(1.8, "IntegrateOver is no longer supported") IntegrateOver -{ -}; -struct VTKM_DEPRECATED(1.8, "IntegrateOverCurve is no longer supported") IntegrateOverCurve - : IntegrateOver -{ - static constexpr vtkm::filter::mesh_info::IntegrationType value = - vtkm::filter::mesh_info::IntegrationType::ArcLength; -}; -struct VTKM_DEPRECATED(1.8, "IntegrateOverSurface is no longer supported") IntegrateOverSurface - : IntegrateOver -{ - static constexpr vtkm::filter::mesh_info::IntegrationType value = - vtkm::filter::mesh_info::IntegrationType::Area; -}; -struct VTKM_DEPRECATED(1.8, "IntegrateOverSurface is no longer supported") IntegrateOverSolid - : IntegrateOver -{ - static constexpr vtkm::filter::mesh_info::IntegrationType value = - vtkm::filter::mesh_info::IntegrationType::Volume; -}; - -// Lists of acceptable types of integration -using ArcLength VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::IntegrationType::ArcLength") = - vtkm::List; -using Area VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::IntegrationType::Area") = - vtkm::List; -using Volume VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::IntegrationType::Volume") = - vtkm::List; -using AllMeasures VTKM_DEPRECATED(1.8, - "Use vtkm::filter::mesh_info::IntegrationType::AllMeasures") = - vtkm::List; - -namespace detail -{ - -inline vtkm::filter::mesh_info::IntegrationType OldToNewIntegrationType(vtkm::List<>) -{ - return vtkm::filter::mesh_info::IntegrationType::None; -} - -template -inline vtkm::filter::mesh_info::IntegrationType OldToNewIntegrationType(vtkm::List) -{ - return T::value | OldToNewIntegrationType(vtkm::List{}); -} - -} // namespace detail - -namespace filter -{ - -template -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::CellMeasures.") CellMeasures - : public vtkm::filter::mesh_info::CellMeasures -{ -public: - CellMeasures() - : vtkm::filter::mesh_info::CellMeasures( - vtkm::detail::OldToNewIntegrationType(IntegrationTypeList{})) - { - } -}; - -} // namespace filter -} // namespace vtkm - -VTKM_DEPRECATED_SUPPRESS_END - #endif // vtk_m_filter_mesh_info_CellMeasures_h diff --git a/vtkm/filter/mesh_info/GhostCellClassify.cxx b/vtkm/filter/mesh_info/GhostCellClassify.cxx index 366e1a063..d7f062f41 100644 --- a/vtkm/filter/mesh_info/GhostCellClassify.cxx +++ b/vtkm/filter/mesh_info/GhostCellClassify.cxx @@ -143,7 +143,7 @@ VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::Dat } auto output = this->CreateResult(input); - output.AddGhostCellField(this->GhostCellName, ghosts); + output.SetGhostCellField(this->GhostCellName, ghosts); return output; } } diff --git a/vtkm/filter/mesh_info/GhostCellClassify.h b/vtkm/filter/mesh_info/GhostCellClassify.h index 03e1d6952..ca3027642 100644 --- a/vtkm/filter/mesh_info/GhostCellClassify.h +++ b/vtkm/filter/mesh_info/GhostCellClassify.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_mesh_info_GhostCellClassify_h #define vtk_m_filter_mesh_info_GhostCellClassify_h -#include +#include #include namespace vtkm @@ -19,14 +19,14 @@ namespace filter { namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT GhostCellClassify : public vtkm::filter::NewFilter +class VTKM_FILTER_MESH_INFO_EXPORT GhostCellClassify : public vtkm::filter::Filter { VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; std::string GhostCellName; public: VTKM_CONT GhostCellClassify() - : NewFilter() + : Filter() , GhostCellName(vtkm::cont::GetGlobalGhostCellFieldName()) { } @@ -35,11 +35,6 @@ public: VTKM_CONT const std::string& GetGhostCellName() { return this->GhostCellName; } }; } // namespace mesh_info -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::GhostCellClassify.") GhostCellClassify - : public vtkm::filter::mesh_info::GhostCellClassify -{ - using mesh_info::GhostCellClassify::GhostCellClassify; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/mesh_info/MeshQuality.cxx b/vtkm/filter/mesh_info/MeshQuality.cxx index 4e3e18073..ed1a5d407 100644 --- a/vtkm/filter/mesh_info/MeshQuality.cxx +++ b/vtkm/filter/mesh_info/MeshQuality.cxx @@ -89,7 +89,7 @@ VTKM_CONT MeshQuality::MeshQuality(CellMetric metric) VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(const vtkm::cont::DataSet& input) { - std::unique_ptr implementation; + std::unique_ptr implementation; switch (this->MyMetric) { case vtkm::filter::mesh_info::CellMetric::Area: @@ -172,69 +172,3 @@ VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(const vtkm::cont::DataSet& } // namespace mesh_info } // namespace filter } // namespace vtkm - -namespace vtkm -{ -namespace filter -{ - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -vtkm::filter::mesh_info::CellMetric MeshQuality::ConvertCellMetric( - vtkm::filter::CellMetric oldMetricEnum) -{ - switch (oldMetricEnum) - { - case vtkm::filter::CellMetric::AREA: - return vtkm::filter::mesh_info::CellMetric::Area; - case vtkm::filter::CellMetric::ASPECT_GAMMA: - return vtkm::filter::mesh_info::CellMetric::AspectGamma; - case vtkm::filter::CellMetric::ASPECT_RATIO: - return vtkm::filter::mesh_info::CellMetric::AspectRatio; - case vtkm::filter::CellMetric::CONDITION: - return vtkm::filter::mesh_info::CellMetric::Condition; - case vtkm::filter::CellMetric::DIAGONAL_RATIO: - return vtkm::filter::mesh_info::CellMetric::DiagonalRatio; - case vtkm::filter::CellMetric::DIMENSION: - return vtkm::filter::mesh_info::CellMetric::Dimension; - case vtkm::filter::CellMetric::JACOBIAN: - return vtkm::filter::mesh_info::CellMetric::Jacobian; - case vtkm::filter::CellMetric::MAX_ANGLE: - return vtkm::filter::mesh_info::CellMetric::MaxAngle; - case vtkm::filter::CellMetric::MAX_DIAGONAL: - return vtkm::filter::mesh_info::CellMetric::MaxDiagonal; - case vtkm::filter::CellMetric::MIN_ANGLE: - return vtkm::filter::mesh_info::CellMetric::MinAngle; - case vtkm::filter::CellMetric::MIN_DIAGONAL: - return vtkm::filter::mesh_info::CellMetric::MinDiagonal; - case vtkm::filter::CellMetric::ODDY: - return vtkm::filter::mesh_info::CellMetric::Oddy; - case vtkm::filter::CellMetric::RELATIVE_SIZE_SQUARED: - return vtkm::filter::mesh_info::CellMetric::RelativeSizeSquared; - case vtkm::filter::CellMetric::SCALED_JACOBIAN: - return vtkm::filter::mesh_info::CellMetric::ScaledJacobian; - case vtkm::filter::CellMetric::SHAPE: - return vtkm::filter::mesh_info::CellMetric::Shape; - case vtkm::filter::CellMetric::SHAPE_AND_SIZE: - return vtkm::filter::mesh_info::CellMetric::ShapeAndSize; - case vtkm::filter::CellMetric::SHEAR: - return vtkm::filter::mesh_info::CellMetric::Shear; - case vtkm::filter::CellMetric::SKEW: - return vtkm::filter::mesh_info::CellMetric::Skew; - case vtkm::filter::CellMetric::STRETCH: - return vtkm::filter::mesh_info::CellMetric::Stretch; - case vtkm::filter::CellMetric::TAPER: - return vtkm::filter::mesh_info::CellMetric::Taper; - case vtkm::filter::CellMetric::VOLUME: - return vtkm::filter::mesh_info::CellMetric::Volume; - case vtkm::filter::CellMetric::WARPAGE: - return vtkm::filter::mesh_info::CellMetric::Warpage; - default: - throw vtkm::cont::ErrorBadValue("Invalid mesh quality metric."); - } -} - -VTKM_DEPRECATED_SUPPRESS_END - -} // namespace filter -} // namespace vtkm diff --git a/vtkm/filter/mesh_info/MeshQuality.h b/vtkm/filter/mesh_info/MeshQuality.h index 1bdd4a642..50699509d 100644 --- a/vtkm/filter/mesh_info/MeshQuality.h +++ b/vtkm/filter/mesh_info/MeshQuality.h @@ -21,7 +21,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQuality_h #define vtk_m_filter_mesh_info_MeshQuality_h -#include +#include #include namespace vtkm @@ -66,7 +66,7 @@ enum struct CellMetric * Each field contains the metric summary statistics for the cell type. * Summary statists with all 0 values imply that the specified metric does not support the cell type. */ -class VTKM_FILTER_MESH_INFO_EXPORT MeshQuality : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQuality : public vtkm::filter::FilterField { public: VTKM_CONT explicit MeshQuality(CellMetric); @@ -77,79 +77,6 @@ private: CellMetric MyMetric; }; } // namespace mesh_info - -VTKM_DEPRECATED_SUPPRESS_BEGIN -VTKM_DEPRECATED(1.8) -static const std::string MetricNames[] = { "area", - "aspectGamma", - "aspectRatio", - "condition", - "diagonalRatio", - "dimension", - "jacobian", - "maxAngle", - "maxDiagonal", - "minAngle", - "minDiagonal", - "oddy", - "relativeSizeSquared", - "scaledJacobian", - "shape", - "shapeAndSize", - "shear", - "skew", - "stretch", - "taper", - "volume", - "warpage" }; -VTKM_DEPRECATED_SUPPRESS_END - -enum struct VTKM_DEPRECATED(1.8 "Use vtkm::filter::mesh_info::CellMetric.") CellMetric -{ - AREA, - ASPECT_GAMMA, - ASPECT_RATIO, - CONDITION, - DIAGONAL_RATIO, - DIMENSION, - JACOBIAN, - MAX_ANGLE, - MAX_DIAGONAL, - MIN_ANGLE, - MIN_DIAGONAL, - ODDY, - RELATIVE_SIZE_SQUARED, - SCALED_JACOBIAN, - SHAPE, - SHAPE_AND_SIZE, - SHEAR, - SKEW, - STRETCH, - TAPER, - VOLUME, - WARPAGE, - NUMBER_OF_CELL_METRICS, - EMPTY -}; - -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::MeshQuality.") - VTKM_FILTER_MESH_INFO_EXPORT MeshQuality : public vtkm::filter::mesh_info::MeshQuality -{ - VTKM_DEPRECATED_SUPPRESS_BEGIN - static vtkm::filter::mesh_info::CellMetric ConvertCellMetric( - vtkm::filter::CellMetric oldMetricEnum); - VTKM_DEPRECATED_SUPPRESS_END - -public: - using mesh_info::MeshQuality::MeshQuality; - - VTKM_DEPRECATED_SUPPRESS_BEGIN - MeshQuality(vtkm::filter::CellMetric oldMetric) - : mesh_info::MeshQuality(ConvertCellMetric(oldMetric)) - { - } - VTKM_DEPRECATED_SUPPRESS_END -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/mesh_info/MeshQualityArea.h b/vtkm/filter/mesh_info/MeshQualityArea.h index 876b0240d..85b7dbcf9 100644 --- a/vtkm/filter/mesh_info/MeshQualityArea.h +++ b/vtkm/filter/mesh_info/MeshQualityArea.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityArea_h #define vtk_m_filter_mesh_info_MeshQualityArea_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityArea : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityArea : public vtkm::filter::FilterField { public: MeshQualityArea(); diff --git a/vtkm/filter/mesh_info/MeshQualityAspectGamma.h b/vtkm/filter/mesh_info/MeshQualityAspectGamma.h index 267c362b4..b60b69e51 100644 --- a/vtkm/filter/mesh_info/MeshQualityAspectGamma.h +++ b/vtkm/filter/mesh_info/MeshQualityAspectGamma.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityAspectGamma_h #define vtk_m_filter_mesh_info_MeshQualityAspectGamma_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityAspectGamma : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityAspectGamma : public vtkm::filter::FilterField { public: MeshQualityAspectGamma(); diff --git a/vtkm/filter/mesh_info/MeshQualityAspectRatio.h b/vtkm/filter/mesh_info/MeshQualityAspectRatio.h index 38f6cc6d1..5e3f4e4da 100644 --- a/vtkm/filter/mesh_info/MeshQualityAspectRatio.h +++ b/vtkm/filter/mesh_info/MeshQualityAspectRatio.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityAspectRatio_h #define vtk_m_filter_mesh_info_MeshQualityAspectRatio_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityAspectRatio : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityAspectRatio : public vtkm::filter::FilterField { public: MeshQualityAspectRatio(); diff --git a/vtkm/filter/mesh_info/MeshQualityCondition.h b/vtkm/filter/mesh_info/MeshQualityCondition.h index fc753b49c..811c3f7af 100644 --- a/vtkm/filter/mesh_info/MeshQualityCondition.h +++ b/vtkm/filter/mesh_info/MeshQualityCondition.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityCondition_h #define vtk_m_filter_mesh_info_MeshQualityCondition_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityCondition : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityCondition : public vtkm::filter::FilterField { public: MeshQualityCondition(); diff --git a/vtkm/filter/mesh_info/MeshQualityDiagonalRatio.h b/vtkm/filter/mesh_info/MeshQualityDiagonalRatio.h index d53bb068f..48bd01419 100644 --- a/vtkm/filter/mesh_info/MeshQualityDiagonalRatio.h +++ b/vtkm/filter/mesh_info/MeshQualityDiagonalRatio.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityDiagonalRatio_h #define vtk_m_filter_mesh_info_MeshQualityDiagonalRatio_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityDiagonalRatio : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityDiagonalRatio : public vtkm::filter::FilterField { public: MeshQualityDiagonalRatio(); diff --git a/vtkm/filter/mesh_info/MeshQualityDimension.h b/vtkm/filter/mesh_info/MeshQualityDimension.h index 2ae5cc845..d55fe2375 100644 --- a/vtkm/filter/mesh_info/MeshQualityDimension.h +++ b/vtkm/filter/mesh_info/MeshQualityDimension.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityDimension_h #define vtk_m_filter_mesh_info_MeshQualityDimension_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityDimension : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityDimension : public vtkm::filter::FilterField { public: MeshQualityDimension(); diff --git a/vtkm/filter/mesh_info/MeshQualityJacobian.h b/vtkm/filter/mesh_info/MeshQualityJacobian.h index 3045443bd..c5776a0a6 100644 --- a/vtkm/filter/mesh_info/MeshQualityJacobian.h +++ b/vtkm/filter/mesh_info/MeshQualityJacobian.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityJacobian_h #define vtk_m_filter_mesh_info_MeshQualityJacobian_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityJacobian : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityJacobian : public vtkm::filter::FilterField { public: MeshQualityJacobian(); diff --git a/vtkm/filter/mesh_info/MeshQualityMaxAngle.h b/vtkm/filter/mesh_info/MeshQualityMaxAngle.h index 6c91b9f9a..84ff3bed7 100644 --- a/vtkm/filter/mesh_info/MeshQualityMaxAngle.h +++ b/vtkm/filter/mesh_info/MeshQualityMaxAngle.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityMaxAngle_h #define vtk_m_filter_mesh_info_MeshQualityMaxAngle_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMaxAngle : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMaxAngle : public vtkm::filter::FilterField { public: MeshQualityMaxAngle(); diff --git a/vtkm/filter/mesh_info/MeshQualityMaxDiagonal.h b/vtkm/filter/mesh_info/MeshQualityMaxDiagonal.h index d33e88fac..4be5a3f08 100644 --- a/vtkm/filter/mesh_info/MeshQualityMaxDiagonal.h +++ b/vtkm/filter/mesh_info/MeshQualityMaxDiagonal.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityMaxDiagonal_h #define vtk_m_filter_mesh_info_MeshQualityMaxDiagonal_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMaxDiagonal : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMaxDiagonal : public vtkm::filter::FilterField { public: MeshQualityMaxDiagonal(); diff --git a/vtkm/filter/mesh_info/MeshQualityMinAngle.h b/vtkm/filter/mesh_info/MeshQualityMinAngle.h index 4d498db34..84bcdb603 100644 --- a/vtkm/filter/mesh_info/MeshQualityMinAngle.h +++ b/vtkm/filter/mesh_info/MeshQualityMinAngle.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityMinAngle_h #define vtk_m_filter_mesh_info_MeshQualityMinAngle_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMinAngle : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMinAngle : public vtkm::filter::FilterField { public: MeshQualityMinAngle(); diff --git a/vtkm/filter/mesh_info/MeshQualityMinDiagonal.h b/vtkm/filter/mesh_info/MeshQualityMinDiagonal.h index 91d16c674..d9cb986a9 100644 --- a/vtkm/filter/mesh_info/MeshQualityMinDiagonal.h +++ b/vtkm/filter/mesh_info/MeshQualityMinDiagonal.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityMinDiagonal_h #define vtk_m_filter_mesh_info_MeshQualityMinDiagonal_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMinDiagonal : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityMinDiagonal : public vtkm::filter::FilterField { public: MeshQualityMinDiagonal(); diff --git a/vtkm/filter/mesh_info/MeshQualityOddy.h b/vtkm/filter/mesh_info/MeshQualityOddy.h index b81e9a57e..880007652 100644 --- a/vtkm/filter/mesh_info/MeshQualityOddy.h +++ b/vtkm/filter/mesh_info/MeshQualityOddy.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityOddy_h #define vtk_m_filter_mesh_info_MeshQualityOddy_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityOddy : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityOddy : public vtkm::filter::FilterField { public: MeshQualityOddy(); diff --git a/vtkm/filter/mesh_info/MeshQualityRelativeSizeSquared.h b/vtkm/filter/mesh_info/MeshQualityRelativeSizeSquared.h index 9c850cd8f..7870573c5 100644 --- a/vtkm/filter/mesh_info/MeshQualityRelativeSizeSquared.h +++ b/vtkm/filter/mesh_info/MeshQualityRelativeSizeSquared.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityRelativeSizeSquared_h #define vtk_m_filter_mesh_info_MeshQualityRelativeSizeSquared_h -#include +#include #include namespace vtkm @@ -30,8 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityRelativeSizeSquared - : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityRelativeSizeSquared : public vtkm::filter::FilterField { public: MeshQualityRelativeSizeSquared(); diff --git a/vtkm/filter/mesh_info/MeshQualityScaledJacobian.h b/vtkm/filter/mesh_info/MeshQualityScaledJacobian.h index d54a85257..7ca0cbefc 100644 --- a/vtkm/filter/mesh_info/MeshQualityScaledJacobian.h +++ b/vtkm/filter/mesh_info/MeshQualityScaledJacobian.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityScaledJacobian_h #define vtk_m_filter_mesh_info_MeshQualityScaledJacobian_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityScaledJacobian : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityScaledJacobian : public vtkm::filter::FilterField { public: MeshQualityScaledJacobian(); diff --git a/vtkm/filter/mesh_info/MeshQualityShape.h b/vtkm/filter/mesh_info/MeshQualityShape.h index 7d961b07c..33e6ee3dc 100644 --- a/vtkm/filter/mesh_info/MeshQualityShape.h +++ b/vtkm/filter/mesh_info/MeshQualityShape.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityShape_h #define vtk_m_filter_mesh_info_MeshQualityShape_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShape : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShape : public vtkm::filter::FilterField { public: MeshQualityShape(); diff --git a/vtkm/filter/mesh_info/MeshQualityShapeAndSize.h b/vtkm/filter/mesh_info/MeshQualityShapeAndSize.h index 2a48c8cf0..75b70d290 100644 --- a/vtkm/filter/mesh_info/MeshQualityShapeAndSize.h +++ b/vtkm/filter/mesh_info/MeshQualityShapeAndSize.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityShapeAndSize_h #define vtk_m_filter_mesh_info_MeshQualityShapeAndSize_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShapeAndSize : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShapeAndSize : public vtkm::filter::FilterField { public: MeshQualityShapeAndSize(); diff --git a/vtkm/filter/mesh_info/MeshQualityShear.h b/vtkm/filter/mesh_info/MeshQualityShear.h index 4bb7b417a..f8b0e5dbb 100644 --- a/vtkm/filter/mesh_info/MeshQualityShear.h +++ b/vtkm/filter/mesh_info/MeshQualityShear.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityShear_h #define vtk_m_filter_mesh_info_MeshQualityShear_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShear : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityShear : public vtkm::filter::FilterField { public: MeshQualityShear(); diff --git a/vtkm/filter/mesh_info/MeshQualitySkew.h b/vtkm/filter/mesh_info/MeshQualitySkew.h index 40a669fc8..d8201fcc9 100644 --- a/vtkm/filter/mesh_info/MeshQualitySkew.h +++ b/vtkm/filter/mesh_info/MeshQualitySkew.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualitySkew_h #define vtk_m_filter_mesh_info_MeshQualitySkew_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualitySkew : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualitySkew : public vtkm::filter::FilterField { public: MeshQualitySkew(); diff --git a/vtkm/filter/mesh_info/MeshQualityStretch.h b/vtkm/filter/mesh_info/MeshQualityStretch.h index acc661d63..e42550c0b 100644 --- a/vtkm/filter/mesh_info/MeshQualityStretch.h +++ b/vtkm/filter/mesh_info/MeshQualityStretch.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityStretch_h #define vtk_m_filter_mesh_info_MeshQualityStretch_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityStretch : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityStretch : public vtkm::filter::FilterField { public: MeshQualityStretch(); diff --git a/vtkm/filter/mesh_info/MeshQualityTaper.h b/vtkm/filter/mesh_info/MeshQualityTaper.h index 127a7f2e2..eaeea6f34 100644 --- a/vtkm/filter/mesh_info/MeshQualityTaper.h +++ b/vtkm/filter/mesh_info/MeshQualityTaper.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityTaper_h #define vtk_m_filter_mesh_info_MeshQualityTaper_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityTaper : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityTaper : public vtkm::filter::FilterField { public: MeshQualityTaper(); diff --git a/vtkm/filter/mesh_info/MeshQualityVolume.h b/vtkm/filter/mesh_info/MeshQualityVolume.h index f98786b7b..107eaacc2 100644 --- a/vtkm/filter/mesh_info/MeshQualityVolume.h +++ b/vtkm/filter/mesh_info/MeshQualityVolume.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityVolume_h #define vtk_m_filter_mesh_info_MeshQualityVolume_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityVolume : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityVolume : public vtkm::filter::FilterField { public: MeshQualityVolume(); diff --git a/vtkm/filter/mesh_info/MeshQualityWarpage.h b/vtkm/filter/mesh_info/MeshQualityWarpage.h index bf783487a..d98884dd9 100644 --- a/vtkm/filter/mesh_info/MeshQualityWarpage.h +++ b/vtkm/filter/mesh_info/MeshQualityWarpage.h @@ -20,7 +20,7 @@ #ifndef vtk_m_filter_mesh_info_MeshQualityWarpage_h #define vtk_m_filter_mesh_info_MeshQualityWarpage_h -#include +#include #include namespace vtkm @@ -30,7 +30,7 @@ namespace filter namespace mesh_info { -class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityWarpage : public vtkm::filter::NewFilterField +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityWarpage : public vtkm::filter::FilterField { public: MeshQualityWarpage(); diff --git a/vtkm/filter/mesh_info/vtkm.module b/vtkm/filter/mesh_info/vtkm.module new file mode 100644 index 000000000..fff949fe4 --- /dev/null +++ b/vtkm/filter/mesh_info/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_filter_mesh_info +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet diff --git a/vtkm/filter/multi_block/AmrArrays.h b/vtkm/filter/multi_block/AmrArrays.h index 505d31dc0..ab98b8e5c 100644 --- a/vtkm/filter/multi_block/AmrArrays.h +++ b/vtkm/filter/multi_block/AmrArrays.h @@ -12,7 +12,7 @@ #include -#include +#include #include namespace vtkm @@ -21,7 +21,7 @@ namespace filter { namespace multi_block { -class VTKM_FILTER_MULTI_BLOCK_EXPORT AmrArrays : public vtkm::filter::NewFilter +class VTKM_FILTER_MULTI_BLOCK_EXPORT AmrArrays : public vtkm::filter::Filter { private: vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet&) override @@ -70,14 +70,6 @@ private: std::vector> ChildrenIdsVector; }; } // namespace multi_block - - -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::multi_block::AmrArrays.") AmrArrays - : public vtkm::filter::multi_block::AmrArrays -{ - using multi_block::AmrArrays::AmrArrays; -}; - } // namesapce filter } // namespace vtkm diff --git a/vtkm/filter/multi_block/CMakeLists.txt b/vtkm/filter/multi_block/CMakeLists.txt index 0d134bf57..695b9532c 100644 --- a/vtkm/filter/multi_block/CMakeLists.txt +++ b/vtkm/filter/multi_block/CMakeLists.txt @@ -22,10 +22,4 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_multi_block PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_multi_block) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/multi_block/testing/CMakeLists.txt b/vtkm/filter/multi_block/testing/CMakeLists.txt index b0d1aaa6b..9a4406306 100644 --- a/vtkm/filter/multi_block/testing/CMakeLists.txt +++ b/vtkm/filter/multi_block/testing/CMakeLists.txt @@ -8,16 +8,19 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -if (VTKm_ENABLE_RENDERING) - list(APPEND libraries vtkm_filter_multi_block vtkm_source vtkm_rendering vtkm_rendering_testing) - - list(APPEND unit_tests - RenderTestAmrArrays.cxx - ) - vtkm_unit_tests( - SOURCES ${unit_tests} - LIBRARIES ${libraries} - USE_VTKM_JOB_POOL +set(libraries + vtkm_filter_multi_block + vtkm_source + vtkm_rendering + vtkm_rendering_testing ) -endif() +set(unit_tests + RenderTestAmrArrays.cxx + ) + +vtkm_unit_tests( + SOURCES ${unit_tests} + LIBRARIES ${libraries} + USE_VTKM_JOB_POOL + ) diff --git a/vtkm/filter/multi_block/testing/RenderTestAmrArrays.cxx b/vtkm/filter/multi_block/testing/RenderTestAmrArrays.cxx index e4f98e6b7..a80294eee 100644 --- a/vtkm/filter/multi_block/testing/RenderTestAmrArrays.cxx +++ b/vtkm/filter/multi_block/testing/RenderTestAmrArrays.cxx @@ -24,7 +24,10 @@ void TestAmrArraysExecute(int dim, int numberOfLevels, int cellsPerDimension) std::cout << "Generate Image for AMR" << std::endl; // Generate AMR - vtkm::source::Amr source(dim, cellsPerDimension, numberOfLevels); + vtkm::source::Amr source; + source.SetDimension(dim); + source.SetNumberOfLevels(numberOfLevels); + source.SetCellsPerDimension(cellsPerDimension); vtkm::cont::PartitionedDataSet amrDataSet = source.Execute(); // std::cout << "amr " << std::endl; // amrDataSet.PrintSummary(std::cout); diff --git a/vtkm/filter/multi_block/vtkm.module b/vtkm/filter/multi_block/vtkm.module new file mode 100644 index 000000000..8503072c7 --- /dev/null +++ b/vtkm/filter/multi_block/vtkm.module @@ -0,0 +1,12 @@ +NAME + vtkm_filter_multi_block +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_source + vtkm_rendering + vtkm_rendering_testing diff --git a/vtkm/filter/resampling/CMakeLists.txt b/vtkm/filter/resampling/CMakeLists.txt index 51f5c0074..726d079a0 100644 --- a/vtkm/filter/resampling/CMakeLists.txt +++ b/vtkm/filter/resampling/CMakeLists.txt @@ -21,12 +21,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_resampling PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_resampling) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/resampling/Probe.cxx b/vtkm/filter/resampling/Probe.cxx index 3a59ef899..0c134ef3d 100644 --- a/vtkm/filter/resampling/Probe.cxx +++ b/vtkm/filter/resampling/Probe.cxx @@ -76,8 +76,8 @@ vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input) auto mapper = [&](auto& outDataSet, const auto& f) { DoMapField(outDataSet, f, worklet, this->InvalidValue); }; - auto output = this->CreateResult( - input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper); + auto output = this->CreateResultCoordinateSystem( + input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystem(), mapper); output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField())); output.AddField( vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet()))); diff --git a/vtkm/filter/resampling/Probe.h b/vtkm/filter/resampling/Probe.h index 2b896a260..56a4fbf3d 100644 --- a/vtkm/filter/resampling/Probe.h +++ b/vtkm/filter/resampling/Probe.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_resampling_Probe_h #define vtk_m_filter_resampling_Probe_h -#include +#include #include namespace vtkm @@ -19,7 +19,7 @@ namespace filter { namespace resampling { -class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::NewFilterField +class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::FilterField { public: VTKM_CONT @@ -43,13 +43,6 @@ private: vtkm::Float64 InvalidValue = vtkm::Nan64(); }; } // namespace resampling - -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::resampling::Probe.") Probe - : public vtkm::filter::resampling::Probe -{ - using resampling::Probe::Probe; -}; - } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/resampling/vtkm.module b/vtkm/filter/resampling/vtkm.module new file mode 100644 index 000000000..6b17adf26 --- /dev/null +++ b/vtkm/filter/resampling/vtkm.module @@ -0,0 +1,10 @@ +NAME + vtkm_filter_resampling +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_DEPENDS + vtkm_filter_clean_grid diff --git a/vtkm/filter/resampling/worklet/Probe.h b/vtkm/filter/resampling/worklet/Probe.h index 178a94255..10ce47ac3 100644 --- a/vtkm/filter/resampling/worklet/Probe.h +++ b/vtkm/filter/resampling/worklet/Probe.h @@ -109,15 +109,14 @@ public: } // Compute points inside cell bounds - auto portal = points.GetPortal(); auto minp = - static_cast(vtkm::Ceil((cbmin - portal.GetOrigin()) / portal.GetSpacing())); + static_cast(vtkm::Ceil((cbmin - points.GetOrigin()) / points.GetSpacing())); auto maxp = - static_cast(vtkm::Floor((cbmax - portal.GetOrigin()) / portal.GetSpacing())); + static_cast(vtkm::Floor((cbmax - points.GetOrigin()) / points.GetSpacing())); // clamp minp = vtkm::Max(minp, vtkm::Id3(0)); - maxp = vtkm::Min(maxp, portal.GetDimensions() - vtkm::Id3(1)); + maxp = vtkm::Min(maxp, points.GetDimensions() - vtkm::Id3(1)); for (vtkm::Id k = minp[2]; k <= maxp[2]; ++k) { @@ -125,13 +124,13 @@ public: { for (vtkm::Id i = minp[0]; i <= maxp[0]; ++i) { - auto pt = portal.Get(vtkm::Id3(i, j, k)); + auto pt = points.Get(vtkm::Id3(i, j, k)); CoordsType pc; vtkm::ErrorCode status = vtkm::exec::WorldCoordinatesToParametricCoordinates(cellPoints, pt, cellShape, pc); if ((status == vtkm::ErrorCode::Success) && vtkm::exec::CellInside(pc, cellShape)) { - auto pointId = i + portal.GetDimensions()[0] * (j + portal.GetDimensions()[1] * k); + auto pointId = i + points.GetDimensions()[0] * (j + points.GetDimensions()[1] * k); cellIds.Set(pointId, cellId); pcoords.Set(pointId, pc); } diff --git a/vtkm/filter/scalar_topology/CMakeLists.txt b/vtkm/filter/scalar_topology/CMakeLists.txt index 01a938d26..11ebd8010 100644 --- a/vtkm/filter/scalar_topology/CMakeLists.txt +++ b/vtkm/filter/scalar_topology/CMakeLists.txt @@ -39,8 +39,3 @@ target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_scalar_topology) add_subdirectory(internal) add_subdirectory(worklet) - -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/scalar_topology/ContourTreeUniform.h b/vtkm/filter/scalar_topology/ContourTreeUniform.h index 9de8d050d..fdf0c4dc0 100644 --- a/vtkm/filter/scalar_topology/ContourTreeUniform.h +++ b/vtkm/filter/scalar_topology/ContourTreeUniform.h @@ -57,7 +57,7 @@ #ifndef vtk_m_filter_scalar_topology_ContourTreeUniform_h #define vtk_m_filter_scalar_topology_ContourTreeUniform_h -#include +#include #include namespace vtkm @@ -72,7 +72,7 @@ namespace scalar_topology /// peak of contour /// Based on the algorithm presented in the paper: // “Parallel Peak Pruning for Scalable SMP Contour Tree Computation.” -class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeMesh2D : public vtkm::filter::NewFilterField +class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeMesh2D : public vtkm::filter::FilterField { public: VTKM_CONT @@ -89,7 +89,7 @@ private: /// peak of contour /// Based on the algorithm presented in the paper: // “Parallel Peak Pruning for Scalable SMP Contour Tree Computation.” -class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeMesh3D : public vtkm::filter::NewFilterField +class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeMesh3D : public vtkm::filter::FilterField { public: VTKM_CONT @@ -100,16 +100,6 @@ private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace scalar_topology -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::scalar_topology::ContourTree2D.") ContourTree2D - : public vtkm::filter::scalar_topology::ContourTreeMesh2D -{ - using scalar_topology::ContourTreeMesh2D::ContourTreeMesh2D; -}; -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::scalar_topology::ContourTree3D.") ContourTree3D - : public vtkm::filter::scalar_topology::ContourTreeMesh3D -{ - using scalar_topology::ContourTreeMesh3D::ContourTreeMesh3D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.cxx b/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.cxx index ac145b9af..aa425799b 100644 --- a/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.cxx +++ b/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.cxx @@ -222,7 +222,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet ContourTreeAugmented::DoExecutePartitio const vtkm::cont::PartitionedDataSet& input) { this->PreExecute(input); - auto result = this->NewFilter::DoExecutePartitions(input); + auto result = this->Filter::DoExecutePartitions(input); this->PostExecute(input, result); return result; } diff --git a/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.h b/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.h index aadb869c8..c47121de9 100644 --- a/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.h +++ b/vtkm/filter/scalar_topology/ContourTreeUniformAugmented.h @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include @@ -85,7 +85,7 @@ namespace scalar_topology /// tree are merged progressively using a binary-reduction scheme to compute the /// final contour tree. I.e., in the multi-block context, the final tree is /// constructed on rank 0. -class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeAugmented : public vtkm::filter::NewFilterField +class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeAugmented : public vtkm::filter::FilterField { public: VTKM_CONT bool CanThread() const override @@ -120,19 +120,6 @@ public: void SetBlockIndices(vtkm::Id3 blocksPerDim, const vtkm::cont::ArrayHandle& localBlockIndices); - VTKM_CONT - VTKM_DEPRECATED(1.9, - "Set PointSize, GlobalPointOrigin, and GlobalPointSize in CellSetStructured and " - "optionally use SetBlockIndices.") - void SetSpatialDecomposition(vtkm::Id3 blocksPerDim, - vtkm::Id3, - const vtkm::cont::ArrayHandle& localBlockIndices, - const vtkm::cont::ArrayHandle&, - const vtkm::cont::ArrayHandle&) - { - SetBlockIndices(blocksPerDim, localBlockIndices); - } - ///@{ /// Get the contour tree computed by the filter const vtkm::worklet::contourtree_augmented::ContourTree& GetContourTree() const; @@ -185,11 +172,6 @@ private: MultiBlockTreeHelper; }; } // namespace scalar_topology -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::scalar_topology::ContourTreeAugmented.") - ContourTreeAugmented : public vtkm::filter::scalar_topology::ContourTreeAugmented -{ - using scalar_topology::ContourTreeAugmented::ContourTreeAugmented; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.cxx b/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.cxx index a4de37b00..03714050a 100644 --- a/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.cxx +++ b/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.cxx @@ -164,30 +164,6 @@ void SaveHierarchicalTreeDot( //----------------------------------------------------------------------------- // Main constructor //----------------------------------------------------------------------------- -ContourTreeUniformDistributed::ContourTreeUniformDistributed( - vtkm::Id3 blocksPerDim, - vtkm::Id3, // globalSize, -> Now in CellSetStructured - const vtkm::cont::ArrayHandle& localBlockIndices, - const vtkm::cont::ArrayHandle&, // localBlockOrigins, -> Use from CellSetStructured - const vtkm::cont::ArrayHandle&, // localBlockSizes, -> Use from CellSetStructured - vtkm::cont::LogLevel timingsLogLevel, - vtkm::cont::LogLevel treeLogLevel) - : UseBoundaryExtremaOnly(true) - , UseMarchingCubes(false) - , AugmentHierarchicalTree(false) - , SaveDotFiles(false) - , TimingsLogLevel(timingsLogLevel) - , TreeLogLevel(treeLogLevel) - , BlocksPerDimension(blocksPerDim) - , LocalBlockIndices(localBlockIndices) - , LocalMeshes() - , LocalContourTrees() - , LocalBoundaryTrees() - , LocalInteriorForests() -{ - this->SetOutputFieldName("resultData"); -} - ContourTreeUniformDistributed::ContourTreeUniformDistributed(vtkm::cont::LogLevel timingsLogLevel, vtkm::cont::LogLevel treeLogLevel) : UseBoundaryExtremaOnly(true) diff --git a/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.h b/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.h index bafebbc21..0f7fa1e06 100644 --- a/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.h +++ b/vtkm/filter/scalar_topology/ContourTreeUniformDistributed.h @@ -63,7 +63,7 @@ #include #include -#include +#include #include namespace vtkm @@ -88,7 +88,7 @@ namespace scalar_topology /// final contour tree. I.e., in the multi-block context, the final tree is /// constructed on rank 0. class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT ContourTreeUniformDistributed - : public vtkm::filter::NewFilterField + : public vtkm::filter::FilterField { public: VTKM_CONT bool CanThread() const override @@ -97,33 +97,6 @@ public: return false; } - /// - /// Create the contour tree filter - /// @param[in] blocksPerDim Number of data blocks used in each data dimension - /// @param[in] globalSize Global extends of the input mesh (i.e., number of mesh points in each dimension) - /// @param[in] localBlockIndices Array with the (x,y,z) index of each local data block with - /// with respect to blocksPerDim - /// @param[in] localBlockOrigins Array with the (x,y,z) origin (with regard to mesh index) of each - /// local data block - /// @param[in] localBlockSizes Array with the sizes (i.e., extends in number of mesh points) of each - /// local data block - /// @param[in] timingsLogLevel Set the vtkm::cont:LogLevel to be used to record timings information - /// specific to the computation of the hierachical contour tree - /// @param[in] treeLogLevel Set the vtkm::cont:LogLevel to be used to record metadata information - /// about the various trees computed as part of the hierarchical contour tree compute - VTKM_CONT - VTKM_DEPRECATED( - 1.9, - "Use default constructor and set PointSize, GlobalPointIndexStart, and GlobalPointSize in " - "CellSetStructured. Optionally use `SetBlockIndices` accessor (if information is available).") - ContourTreeUniformDistributed(vtkm::Id3 blocksPerDim, - vtkm::Id3 globalSize, - const vtkm::cont::ArrayHandle& localBlockIndices, - const vtkm::cont::ArrayHandle& localBlockOrigins, - const vtkm::cont::ArrayHandle& localBlockSizes, - vtkm::cont::LogLevel timingsLogLevel = vtkm::cont::LogLevel::Perf, - vtkm::cont::LogLevel treeLogLevel = vtkm::cont::LogLevel::Info); - ContourTreeUniformDistributed(vtkm::cont::LogLevel timingsLogLevel = vtkm::cont::LogLevel::Perf, vtkm::cont::LogLevel treeLogLevel = vtkm::cont::LogLevel::Info); @@ -248,33 +221,6 @@ private: vtkm::Id NumIterations; }; } // namespace scalar_topology -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::scalar_topology::ContourTreeUniformDistributed.") - ContourTreeUniformDistributed - : public vtkm::filter::scalar_topology::ContourTreeUniformDistributed -{ - using scalar_topology::ContourTreeUniformDistributed::ContourTreeUniformDistributed; - - ContourTreeUniformDistributed(vtkm::Id3 blocksPerDim, - vtkm::Id3, - const vtkm::cont::ArrayHandle& localBlockIndices, - const vtkm::cont::ArrayHandle&, - const vtkm::cont::ArrayHandle&, - bool useBoundaryExtremaOnly = true, - bool useMarchingCubes = false, - bool augmentHierarchicalTree = false, - bool saveDotFiles = false, - vtkm::cont::LogLevel timingsLogLevel = vtkm::cont::LogLevel::Perf, - vtkm::cont::LogLevel treeLogLevel = vtkm::cont::LogLevel::Info) - : vtkm::filter::scalar_topology::ContourTreeUniformDistributed(timingsLogLevel, treeLogLevel) - { - this->SetUseBoundaryExtremaOnly(useBoundaryExtremaOnly); - this->SetUseMarchingCubes(useMarchingCubes); - this->SetAugmentHierarchicalTree(augmentHierarchicalTree); - this->SetSaveDotFiles(saveDotFiles); - this->SetBlockIndices(blocksPerDim, localBlockIndices); - this->SetOutputFieldName("resultData"); - } -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/scalar_topology/DistributedBranchDecompositionFilter.h b/vtkm/filter/scalar_topology/DistributedBranchDecompositionFilter.h index 244bbfa71..774c8ae35 100644 --- a/vtkm/filter/scalar_topology/DistributedBranchDecompositionFilter.h +++ b/vtkm/filter/scalar_topology/DistributedBranchDecompositionFilter.h @@ -42,7 +42,7 @@ #ifndef vtk_m_filter_scalar_topology_DistributedBranchDecompositionFilter_h #define vtk_m_filter_scalar_topology_DistributedBranchDecompositionFilter_h -#include +#include #include namespace vtkm @@ -54,7 +54,7 @@ namespace scalar_topology /// \brief Compute branch decompostion from distributed contour tree class VTKM_FILTER_SCALAR_TOPOLOGY_EXPORT DistributedBranchDecompositionFilter - : public vtkm::filter::NewFilter + : public vtkm::filter::Filter { public: VTKM_CONT DistributedBranchDecompositionFilter() = default; diff --git a/vtkm/filter/scalar_topology/testing/CMakeLists.txt b/vtkm/filter/scalar_topology/testing/CMakeLists.txt index 0643aa983..7b3377fc6 100644 --- a/vtkm/filter/scalar_topology/testing/CMakeLists.txt +++ b/vtkm/filter/scalar_topology/testing/CMakeLists.txt @@ -29,16 +29,9 @@ set(unit_tests_device UnitTestDistributedBranchDecompositionFilter.cxx ) -set(libraries - vtkm_filter_scalar_topology - vtkm_io - vtkm_source - ) - vtkm_unit_tests( SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device} - LIBRARIES ${libraries} USE_VTKM_JOB_POOL ) diff --git a/vtkm/filter/scalar_topology/testing/UnitTestContourTreeUniformAugmentedFilter.cxx b/vtkm/filter/scalar_topology/testing/UnitTestContourTreeUniformAugmentedFilter.cxx index d40a87657..dc197bad2 100644 --- a/vtkm/filter/scalar_topology/testing/UnitTestContourTreeUniformAugmentedFilter.cxx +++ b/vtkm/filter/scalar_topology/testing/UnitTestContourTreeUniformAugmentedFilter.cxx @@ -98,7 +98,7 @@ private: vtkm::filter::scalar_topology::ContourTreeAugmented filter(useMarchingCubes, computeRegularStructure); filter.SetActiveField("pointvar"); - auto result = filter.Execute(dataSet); + filter.Execute(dataSet); return filter; } diff --git a/vtkm/filter/scalar_topology/vtkm.module b/vtkm/filter/scalar_topology/vtkm.module new file mode 100644 index 000000000..517117993 --- /dev/null +++ b/vtkm/filter/scalar_topology/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_filter_scalar_topology +GROUPS + Filters +DEPENDS + vtkm_filter_core +TEST_DEPENDS + vtkm_io + vtkm_source diff --git a/vtkm/filter/scalar_topology/worklet/contourtree_augmented/activegraph/SetArcsSlideVertices.h b/vtkm/filter/scalar_topology/worklet/contourtree_augmented/activegraph/SetArcsSlideVertices.h index 5af78866c..1885b2cf3 100644 --- a/vtkm/filter/scalar_topology/worklet/contourtree_augmented/activegraph/SetArcsSlideVertices.h +++ b/vtkm/filter/scalar_topology/worklet/contourtree_augmented/activegraph/SetArcsSlideVertices.h @@ -148,14 +148,14 @@ public: if (hyperID == NumHypernodes - 1) rightSupernodeID = NumSupernodes - 1; else - rightSupernodeID = treeFirstSuperchildPortal[hyperID + 1] - 1; + rightSupernodeID = treeFirstSuperchildPortal.Get(hyperID + 1) - 1; } // join graph else { // split graph if (hyperID == 0) rightSupernodeID = NumSupernodes - 1; else - rightSupernodeID = treeFirstSuperchildPortal[hyperID - 1] - 1; + rightSupernodeID = treeFirstSuperchildPortal.Get(hyperID - 1) - 1; } // split graph // the right end is guaranteed to be the hypernode at the top, which is not @@ -164,7 +164,7 @@ public: while (leftSupernodeID != rightSupernodeID - 1) { // binary search vtkm::Id midSupernodeID = (leftSupernodeID + rightSupernodeID) / 2; - vtkm::Id midNodeID = treeSupernodesPortal[midSupernodeID]; + vtkm::Id midNodeID = treeSupernodesPortal.Get(midSupernodeID); // this is NEVER equal, because nodeID cannot be a supernode if (IsJoinGraph ? (midNodeID > nodeID) : (midNodeID < nodeID)) rightSupernodeID = midSupernodeID; diff --git a/vtkm/filter/scalar_topology/worklet/contourtree_augmented/meshextrema/PointerDoubling.h b/vtkm/filter/scalar_topology/worklet/contourtree_augmented/meshextrema/PointerDoubling.h index 2292603b6..3bd04dabf 100644 --- a/vtkm/filter/scalar_topology/worklet/contourtree_augmented/meshextrema/PointerDoubling.h +++ b/vtkm/filter/scalar_topology/worklet/contourtree_augmented/meshextrema/PointerDoubling.h @@ -53,7 +53,6 @@ #ifndef vtk_m_worklet_contourtree_augmented_pointer_doubling_h #define vtk_m_worklet_contourtree_augmented_pointer_doubling_h -#include #include #include diff --git a/vtkm/filter/testing/CMakeLists.txt b/vtkm/filter/testing/CMakeLists.txt index f6a11c674..e7972df48 100644 --- a/vtkm/filter/testing/CMakeLists.txt +++ b/vtkm/filter/testing/CMakeLists.txt @@ -9,7 +9,6 @@ ##============================================================================ set(unit_tests - UnitTestFieldMetadata.cxx UnitTestFieldSelection.cxx UnitTestMapFieldMergeAverage.cxx UnitTestMapFieldPermutation.cxx @@ -17,13 +16,10 @@ set(unit_tests UnitTestPartitionedDataSetFilters.cxx ) -set(libraries - vtkm_filter - vtkm_io - vtkm_source -) - vtkm_unit_tests( + # For historical reasons, these tests are part of the vtkm_filter_core module even though + # they are in vtkm/filter. Thus, we need to rename the test for the filter to recognize it. + NAME UnitTests_vtkm_filter_core_testing DEVICE_SOURCES ${unit_tests} LIBRARIES ${libraries} USE_VTKM_JOB_POOL diff --git a/vtkm/filter/testing/RenderTestStreamline.cxx b/vtkm/filter/testing/RenderTestStreamline.cxx deleted file mode 100644 index a6fde1804..000000000 --- a/vtkm/filter/testing/RenderTestStreamline.cxx +++ /dev/null @@ -1,75 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace -{ -void TestStreamline() -{ - std::cout << "Generate Image for Streamline filter" << std::endl; - - auto pathname = vtkm::cont::testing::Testing::DataPath("uniform/StreamlineTestDataSet.vtk"); - vtkm::io::VTKDataSetReader reader(pathname); - vtkm::cont::DataSet dataSet = reader.ReadDataSet(); - vtkm::cont::ArrayHandle seedArray = - vtkm::cont::make_ArrayHandle({ vtkm::Particle(vtkm::Vec3f(.2f, 1.0f, .2f), 0), - vtkm::Particle(vtkm::Vec3f(.2f, 2.0f, .2f), 1), - vtkm::Particle(vtkm::Vec3f(.2f, 3.0f, .2f), 2) }); - - vtkm::filter::flow::Streamline streamline; - streamline.SetStepSize(0.1f); - streamline.SetNumberOfSteps(20); - streamline.SetSeeds(seedArray); - streamline.SetActiveField("vector"); - auto result = streamline.Execute(dataSet); - - // Some sort of color map is needed when rendering the coordinates of a dataset - // so create a zeroed array for the coordinates. - std::vector colorMap(static_cast::size_type>( - result.GetCoordinateSystem().GetNumberOfPoints())); - for (std::vector::size_type i = 0; i < colorMap.size(); i++) - { - colorMap[i] = static_cast(i); - } - result.AddPointField("pointvar", colorMap); - - // The streamline by itself doesn't generate renderable geometry, so surround the - // streamlines in tubes. - vtkm::filter::geometry_refinement::Tube tube; - tube.SetCapping(true); - tube.SetNumberOfSides(3); - tube.SetRadius(static_cast(0.2)); - result = tube.Execute(result); - result.PrintSummary(std::cout); - - vtkm::rendering::testing::RenderTestOptions testOptions; - testOptions.ColorTable = vtkm::cont::ColorTable::Preset::Inferno; - testOptions.EnableAnnotations = false; - vtkm::rendering::testing::RenderTest(result, "pointvar", "filter/streamline.png", testOptions); -} -} // namespace - -int RenderTestStreamline(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestStreamline, argc, argv); -} diff --git a/vtkm/filter/testing/UnitTestFieldMetadata.cxx b/vtkm/filter/testing/UnitTestFieldMetadata.cxx deleted file mode 100644 index fc5056e24..000000000 --- a/vtkm/filter/testing/UnitTestFieldMetadata.cxx +++ /dev/null @@ -1,81 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include - -VTKM_DEPRECATED_SUPPRESS_BEGIN -namespace -{ - -vtkm::cont::Field makePointField() -{ - return vtkm::cont::Field( - "foo", vtkm::cont::Field::Association::Points, vtkm::cont::ArrayHandle()); -} - -void TestFieldTypesUnknown() -{ - vtkm::filter::FieldMetadata defaultMD; - VTKM_TEST_ASSERT(defaultMD.IsPointField() == false, "default is not point or cell"); - VTKM_TEST_ASSERT(defaultMD.IsCellField() == false, "default is not point or cell"); - - //verify the field helper works properly - vtkm::cont::Field field1; - vtkm::filter::FieldMetadata makeMDFromField(field1); - VTKM_TEST_ASSERT(makeMDFromField.IsPointField() == false, "makeMDFromField is not point or cell"); - VTKM_TEST_ASSERT(makeMDFromField.IsCellField() == false, "makeMDFromField is not point or cell"); -} - -void TestFieldTypesPoint() -{ - vtkm::filter::FieldMetadata helperMD(makePointField()); - VTKM_TEST_ASSERT(helperMD.IsPointField() == true, "point should be a point field"); - VTKM_TEST_ASSERT(helperMD.IsCellField() == false, "point can't be a cell field"); - - //verify the field helper works properly - auto field = vtkm::cont::make_FieldPoint( - "pointvar", - vtkm::cont::make_ArrayHandle({ 10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f })); - vtkm::filter::FieldMetadata makeMDFromField(field); - VTKM_TEST_ASSERT(makeMDFromField.IsPointField() == true, "point should be a point field"); - VTKM_TEST_ASSERT(makeMDFromField.IsCellField() == false, "point can't be a cell field"); -} - -void TestFieldTypesCell() -{ - vtkm::filter::FieldMetadata defaultMD; - vtkm::filter::FieldMetadata helperMD( - vtkm::cont::make_FieldCell("foo", vtkm::cont::ArrayHandle())); - VTKM_TEST_ASSERT(helperMD.IsPointField() == false, "cell can't be a point field"); - VTKM_TEST_ASSERT(helperMD.IsCellField() == true, "cell should be a cell field"); - - //verify the field helper works properly - auto field = vtkm::cont::make_FieldCell( - "pointvar", - vtkm::cont::make_ArrayHandle({ 10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f })); - vtkm::filter::FieldMetadata makeMDFromField(field); - VTKM_TEST_ASSERT(makeMDFromField.IsPointField() == false, "cell can't be a point field"); - VTKM_TEST_ASSERT(makeMDFromField.IsCellField() == true, "cell should be a cell field"); -} - -void TestFieldMetadata() -{ - TestFieldTypesUnknown(); - TestFieldTypesPoint(); - TestFieldTypesCell(); -} -} - -int UnitTestFieldMetadata(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestFieldMetadata, argc, argv); -} -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/filter/testing/UnitTestFieldSelection.cxx b/vtkm/filter/testing/UnitTestFieldSelection.cxx index e1bedb6e9..9beb5e2c9 100644 --- a/vtkm/filter/testing/UnitTestFieldSelection.cxx +++ b/vtkm/filter/testing/UnitTestFieldSelection.cxx @@ -140,6 +140,22 @@ void TestFieldSelection() true, "field selection failed."); VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == true, "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("baz") == false, "field selection failed."); + + std::cout << " Select a field as excluded (should not change result)" << std::endl; + selection.AddField("baz", vtkm::filter::FieldSelection::Mode::Exclude); + VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == true, "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("foo", vtkm::cont::Field::Association::Points) == + true, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::Association::Points) == + false, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::Association::Cells) == + true, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == true, "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("baz") == false, "field selection failed."); } { @@ -161,6 +177,21 @@ void TestFieldSelection() "field selection failed."); VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == false, "field selection failed."); VTKM_TEST_ASSERT(selection.IsFieldSelected("baz") == true, "field selection failed."); + + std::cout << " Select a field as included (should not change result)" << std::endl; + selection.AddField("baz", vtkm::filter::FieldSelection::Mode::Select); + VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == false, "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("foo", vtkm::cont::Field::Association::Points) == + false, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::Association::Points) == + true, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::Association::Cells) == + false, + "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == false, "field selection failed."); + VTKM_TEST_ASSERT(selection.IsFieldSelected("baz") == true, "field selection failed."); } } } diff --git a/vtkm/filter/testing/UnitTestMultiBlockFilter.cxx b/vtkm/filter/testing/UnitTestMultiBlockFilter.cxx index 6ee313c1b..5929a8d4a 100644 --- a/vtkm/filter/testing/UnitTestMultiBlockFilter.cxx +++ b/vtkm/filter/testing/UnitTestMultiBlockFilter.cxx @@ -93,7 +93,8 @@ void TestMultiBlockFilter() for (int i = 0; i < 10; i++) { vtkm::Id3 dims(10 + i, 10 + i, 10 + i); - vtkm::source::Tangle tangle(dims); + vtkm::source::Tangle tangle; + tangle.SetCellDimensions(dims); pds.AppendPartition(tangle.Execute()); } diff --git a/vtkm/filter/vector_analysis/CMakeLists.txt b/vtkm/filter/vector_analysis/CMakeLists.txt index a316c0e48..011c8a790 100644 --- a/vtkm/filter/vector_analysis/CMakeLists.txt +++ b/vtkm/filter/vector_analysis/CMakeLists.txt @@ -34,11 +34,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_vector_analysis PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_vector_analysis) add_subdirectory(worklet) -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/vector_analysis/CrossProduct.h b/vtkm/filter/vector_analysis/CrossProduct.h index 0ca8b25a6..06dcbbb14 100644 --- a/vtkm/filter/vector_analysis/CrossProduct.h +++ b/vtkm/filter/vector_analysis/CrossProduct.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_vector_analysis_CrossProduct_h #define vtk_m_filter_vector_analysis_CrossProduct_h -#include +#include #include @@ -22,7 +22,7 @@ namespace filter namespace vector_analysis { -class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT CrossProduct : public vtkm::filter::NewFilterField +class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT CrossProduct : public vtkm::filter::FilterField { public: VTKM_CONT @@ -123,11 +123,6 @@ private: }; } // namespace vector_analysis -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::vector_analysis::CrossProduct.") CrossProduct - : public vtkm::filter::vector_analysis::CrossProduct -{ - using vector_analysis::CrossProduct::CrossProduct; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/vector_analysis/DotProduct.h b/vtkm/filter/vector_analysis/DotProduct.h index 02325f413..c859cb3c6 100644 --- a/vtkm/filter/vector_analysis/DotProduct.h +++ b/vtkm/filter/vector_analysis/DotProduct.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_vector_analysis_DotProduct_h #define vtk_m_filter_vector_analysis_DotProduct_h -#include +#include #include namespace vtkm @@ -20,7 +20,7 @@ namespace filter { namespace vector_analysis { -class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT DotProduct : public vtkm::filter::NewFilterField +class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT DotProduct : public vtkm::filter::FilterField { public: VTKM_CONT DotProduct(); @@ -122,11 +122,6 @@ private: vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace vector_analysis -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::vector_analysis::DotProduct.") DotProduct - : public vtkm::filter::vector_analysis::DotProduct -{ - using vector_analysis::DotProduct::DotProduct; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/vector_analysis/Gradient.h b/vtkm/filter/vector_analysis/Gradient.h index e971c2dba..e2231b375 100644 --- a/vtkm/filter/vector_analysis/Gradient.h +++ b/vtkm/filter/vector_analysis/Gradient.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_vector_analysis_Gradient_h #define vtk_m_filter_vector_analysis_Gradient_h -#include +#include #include namespace vtkm @@ -29,7 +29,7 @@ namespace vector_analysis /// /// Note: If no explicit name for the output field is provided the filter will /// default to "Gradients" -class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT Gradient : public vtkm::filter::NewFilterField +class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT Gradient : public vtkm::filter::FilterField { public: /// When this flag is on (default is off), the gradient filter will provide a @@ -104,11 +104,6 @@ private: }; } // namespace vector_analysis -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::vector_analysis::Gradient.") Gradient - : public vtkm::filter::vector_analysis::Gradient -{ - using vector_analysis::Gradient::Gradient; -}; } // namespace filter } // namespace vtkm::filter diff --git a/vtkm/filter/vector_analysis/SurfaceNormals.h b/vtkm/filter/vector_analysis/SurfaceNormals.h index 821d1f866..6042552bb 100644 --- a/vtkm/filter/vector_analysis/SurfaceNormals.h +++ b/vtkm/filter/vector_analysis/SurfaceNormals.h @@ -10,7 +10,7 @@ #ifndef vtk_m_filter_vector_analysis_SurfaceNormal_h #define vtk_m_filter_vector_analysis_SurfaceNormal_h -#include +#include #include namespace vtkm @@ -25,7 +25,7 @@ namespace vector_analysis /// The cell normals are faceted and are computed based on the plane where a /// face lies. The point normals are smooth normals, computed by averaging /// the face normals of incident cells. -class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT SurfaceNormals : public vtkm::filter::NewFilterField +class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT SurfaceNormals : public vtkm::filter::FilterField { public: /// Create SurfaceNormals filter. This calls @@ -108,11 +108,6 @@ private: std::string PointNormalsName; }; } // namespace vector_analysis -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::vector_analysis::SurfaceNormals.") SurfaceNormals - : public vtkm::filter::vector_analysis::SurfaceNormals -{ - using vector_analysis::SurfaceNormals::SurfaceNormals; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/vector_analysis/VectorMagnitude.h b/vtkm/filter/vector_analysis/VectorMagnitude.h index 9de73a729..eb19c5974 100644 --- a/vtkm/filter/vector_analysis/VectorMagnitude.h +++ b/vtkm/filter/vector_analysis/VectorMagnitude.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_vector_analysis_VectorMagnitude_h #define vtk_m_filter_vector_analysis_VectorMagnitude_h -#include +#include #include namespace vtkm @@ -20,7 +20,7 @@ namespace filter { namespace vector_analysis { -class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT VectorMagnitude : public vtkm::filter::NewFilterField +class VTKM_FILTER_VECTOR_ANALYSIS_EXPORT VectorMagnitude : public vtkm::filter::FilterField { public: VectorMagnitude(); @@ -29,11 +29,6 @@ private: VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; }; } // namespace vector_analysis -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::vector_analysis::VectorMagnitude.") VectorMagnitude - : public vtkm::filter::vector_analysis::VectorMagnitude -{ - using vector_analysis::VectorMagnitude::VectorMagnitude; -}; } // namespace filter } // namespace vtkm::filter diff --git a/vtkm/filter/vector_analysis/vtkm.module b/vtkm/filter/vector_analysis/vtkm.module new file mode 100644 index 000000000..0a9def8bf --- /dev/null +++ b/vtkm/filter/vector_analysis/vtkm.module @@ -0,0 +1,12 @@ +NAME + vtkm_filter_vector_analysis +GROUPS + FiltersCommon + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing + vtkm_rendering diff --git a/vtkm/filter/vector_analysis/worklet/gradient/PointGradient.h b/vtkm/filter/vector_analysis/worklet/gradient/PointGradient.h index 2fbc4caa5..2dc069e5d 100644 --- a/vtkm/filter/vector_analysis/worklet/gradient/PointGradient.h +++ b/vtkm/filter/vector_analysis/worklet/gradient/PointGradient.h @@ -128,26 +128,17 @@ private: return result; } - //This is fairly complex so that we can trigger code to extract - //VecRectilinearPointCoordinates when using structured connectivity, and - //uniform point coordinates. - //c++14 would make the return type simply auto template VTKM_EXEC auto GetValues(const ThreadIndicesType& indices, const WholeFieldIn& in) const - -> decltype(std::declval>() - .Load(indices, in.GetPortal())) { //the current problem is that when the topology is structured //we are passing in an vtkm::Id when it wants a Id2 or an Id3 that //represents the flat index of the topology - using ExecObjectType = typename WholeFieldIn::PortalType; using Fetch = vtkm::exec::arg::Fetch; + WholeFieldIn>; Fetch fetch; - return fetch.Load(indices, in.GetPortal()); + return fetch.Load(indices, in); } }; } diff --git a/vtkm/filter/vtkm.module b/vtkm/filter/vtkm.module new file mode 100644 index 000000000..bba926f7a --- /dev/null +++ b/vtkm/filter/vtkm.module @@ -0,0 +1,14 @@ +NAME + vtkm_filter_core +GROUPS + Core +DEPENDS + vtkm_cont + vtkm_worklet +TEST_DEPENDS + vtkm_filter + vtkm_io + vtkm_source +TEST_OPTIONAL_DEPENDS + vtkm_rendering + vtkm_rendering_testing diff --git a/vtkm/filter/zfp/CMakeLists.txt b/vtkm/filter/zfp/CMakeLists.txt index 7bbc39a10..0468dccea 100644 --- a/vtkm/filter/zfp/CMakeLists.txt +++ b/vtkm/filter/zfp/CMakeLists.txt @@ -32,11 +32,6 @@ vtkm_library( USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_filter_zfp PUBLIC vtkm_worklet vtkm_filter_core) target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_zfp) add_subdirectory(worklet) -#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/filter/zfp/ZFPCompressor1D.cxx b/vtkm/filter/zfp/ZFPCompressor1D.cxx index c5e82da79..47f85e19f 100644 --- a/vtkm/filter/zfp/ZFPCompressor1D.cxx +++ b/vtkm/filter/zfp/ZFPCompressor1D.cxx @@ -30,8 +30,12 @@ VTKM_CONT vtkm::cont::DataSet ZFPCompressor1D::DoExecute(const vtkm::cont::DataS compressed = compressor.Compress(concrete, rate, field.GetNumberOfValues()); }); - // TODO: is it really PointField or WHOLE_MESH, should we do it the same way as Histogram? - return this->CreateResultFieldPoint(input, "compressed", compressed); + // Note: the compressed array is set as a WholeDataSet field. It is really associated with + // the points, but the size does not match and problems will occur if the user attempts to + // use it as a point data set. The decompressor will place the data back as a point field. + // (This might cause issues if cell fields are ever supported.) + return this->CreateResultField( + input, "compressed", vtkm::cont::Field::Association::WholeDataSet, compressed); } } // namespace zfp } // namespace filter diff --git a/vtkm/filter/zfp/ZFPCompressor1D.h b/vtkm/filter/zfp/ZFPCompressor1D.h index dbdfbdd16..39c5ed0b2 100644 --- a/vtkm/filter/zfp/ZFPCompressor1D.h +++ b/vtkm/filter/zfp/ZFPCompressor1D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPCompressor1D_h #define vtk_m_filter_zfp_ZFPCompressor1D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPCompressor1D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPCompressor1D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPCompressor1D.") ZFPCompressor1D - : public vtkm::filter::zfp::ZFPCompressor1D -{ - using zfp::ZFPCompressor1D::ZFPCompressor1D; -}; } // namespace filter } // namespace vtkm::filter diff --git a/vtkm/filter/zfp/ZFPCompressor2D.cxx b/vtkm/filter/zfp/ZFPCompressor2D.cxx index c07dbdbce..e2a342973 100644 --- a/vtkm/filter/zfp/ZFPCompressor2D.cxx +++ b/vtkm/filter/zfp/ZFPCompressor2D.cxx @@ -35,8 +35,12 @@ VTKM_CONT vtkm::cont::DataSet ZFPCompressor2D::DoExecute(const vtkm::cont::DataS compressed = compressor.Compress(concrete, rate, pointDimensions); }); - // TODO: is it really PointField or WHOLE_MESH, should we do it the same way as Histogram? - return this->CreateResultFieldPoint(input, "compressed", compressed); + // Note: the compressed array is set as a WholeDataSet field. It is really associated with + // the points, but the size does not match and problems will occur if the user attempts to + // use it as a point data set. The decompressor will place the data back as a point field. + // (This might cause issues if cell fields are ever supported.) + return this->CreateResultField( + input, "compressed", vtkm::cont::Field::Association::WholeDataSet, compressed); } } // namespace zfp } // namespace filter diff --git a/vtkm/filter/zfp/ZFPCompressor2D.h b/vtkm/filter/zfp/ZFPCompressor2D.h index df1e8f7c5..e48fcb404 100644 --- a/vtkm/filter/zfp/ZFPCompressor2D.h +++ b/vtkm/filter/zfp/ZFPCompressor2D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPCompressor2D_h #define vtk_m_filter_zfp_ZFPCompressor2D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPCompressor2D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPCompressor2D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPCompressor2D.") ZFPCompressor2D - : public vtkm::filter::zfp::ZFPCompressor2D -{ - using zfp::ZFPCompressor2D::ZFPCompressor2D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/zfp/ZFPCompressor3D.cxx b/vtkm/filter/zfp/ZFPCompressor3D.cxx index e712172ed..6f3a4e94d 100644 --- a/vtkm/filter/zfp/ZFPCompressor3D.cxx +++ b/vtkm/filter/zfp/ZFPCompressor3D.cxx @@ -35,8 +35,12 @@ VTKM_CONT vtkm::cont::DataSet ZFPCompressor3D::DoExecute(const vtkm::cont::DataS compressed = compressor.Compress(concrete, rate, pointDimensions); }); - // TODO: is it really PointField or WHOLE_MESH, should we do it the same way as Histogram? - return this->CreateResultFieldPoint(input, "compressed", compressed); + // Note: the compressed array is set as a WholeDataSet field. It is really associated with + // the points, but the size does not match and problems will occur if the user attempts to + // use it as a point data set. The decompressor will place the data back as a point field. + // (This might cause issues if cell fields are ever supported.) + return this->CreateResultField( + input, "compressed", vtkm::cont::Field::Association::WholeDataSet, compressed); } } // namespace zfp } // namespace filter diff --git a/vtkm/filter/zfp/ZFPCompressor3D.h b/vtkm/filter/zfp/ZFPCompressor3D.h index 2adf3f80f..844054f11 100644 --- a/vtkm/filter/zfp/ZFPCompressor3D.h +++ b/vtkm/filter/zfp/ZFPCompressor3D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPCompressor3D_h #define vtk_m_filter_zfp_ZFPCompressor3D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPCompressor3D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPCompressor3D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPCompressor3D.") ZFPCompressor3D - : public vtkm::filter::zfp::ZFPCompressor3D -{ - using zfp::ZFPCompressor3D::ZFPCompressor3D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/zfp/ZFPDecompressor1D.cxx b/vtkm/filter/zfp/ZFPDecompressor1D.cxx index 03dcb6b49..1a7a033a7 100644 --- a/vtkm/filter/zfp/ZFPDecompressor1D.cxx +++ b/vtkm/filter/zfp/ZFPDecompressor1D.cxx @@ -26,9 +26,13 @@ VTKM_CONT vtkm::cont::DataSet ZFPDecompressor1D::DoExecute(const vtkm::cont::Dat vtkm::cont::ArrayHandle compressed; vtkm::cont::ArrayCopyShallowIfPossible(this->GetFieldFromDataSet(input).GetData(), compressed); + vtkm::cont::CellSetStructured<1> cellSet; + input.GetCellSet().AsCellSet(cellSet); + vtkm::Id pointDimensions = cellSet.GetPointDimensions(); + vtkm::cont::ArrayHandle decompressed; vtkm::worklet::ZFP1DDecompressor decompressor; - decompressor.Decompress(compressed, decompressed, this->rate, compressed.GetNumberOfValues()); + decompressor.Decompress(compressed, decompressed, this->rate, pointDimensions); return this->CreateResultFieldPoint(input, "decompressed", decompressed); } diff --git a/vtkm/filter/zfp/ZFPDecompressor1D.h b/vtkm/filter/zfp/ZFPDecompressor1D.h index 3ef5bcb72..bf82bc001 100644 --- a/vtkm/filter/zfp/ZFPDecompressor1D.h +++ b/vtkm/filter/zfp/ZFPDecompressor1D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPDecompressor1D_h #define vtk_m_filter_zfp_ZFPDecompressor1D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor1D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor1D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPDecompressor1D.") ZFPDecompressor1D - : public vtkm::filter::zfp::ZFPDecompressor1D -{ - using zfp::ZFPDecompressor1D::ZFPDecompressor1D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/zfp/ZFPDecompressor2D.h b/vtkm/filter/zfp/ZFPDecompressor2D.h index 4aaa0f4e5..7c0d609de 100644 --- a/vtkm/filter/zfp/ZFPDecompressor2D.h +++ b/vtkm/filter/zfp/ZFPDecompressor2D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPDecompressor2D_h #define vtk_m_filter_zfp_ZFPDecompressor2D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor2D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor2D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPDecompressor2D.") ZFPDecompressor2D - : public vtkm::filter::zfp::ZFPDecompressor2D -{ - using zfp::ZFPDecompressor2D::ZFPDecompressor2D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/zfp/ZFPDecompressor3D.h b/vtkm/filter/zfp/ZFPDecompressor3D.h index 19c6b05bd..744c8cd32 100644 --- a/vtkm/filter/zfp/ZFPDecompressor3D.h +++ b/vtkm/filter/zfp/ZFPDecompressor3D.h @@ -11,7 +11,7 @@ #ifndef vtk_m_filter_zfp_ZFPDecompressor3D_h #define vtk_m_filter_zfp_ZFPDecompressor3D_h -#include +#include #include namespace vtkm @@ -26,7 +26,7 @@ namespace zfp /// output of compressed data. /// @warning /// This filter is currently only supports 1D volumes. -class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor3D : public vtkm::filter::NewFilterField +class VTKM_FILTER_ZFP_EXPORT ZFPDecompressor3D : public vtkm::filter::FilterField { public: void SetRate(vtkm::Float64 _rate) { rate = _rate; } @@ -38,11 +38,6 @@ private: vtkm::Float64 rate = 0; }; } // namespace zfp -class VTKM_DEPRECATED(1.8, "Use vtkm::filter::zfp::ZFPDecompressor3D.") ZFPDecompressor3D - : public vtkm::filter::zfp::ZFPDecompressor3D -{ - using zfp::ZFPDecompressor3D::ZFPDecompressor3D; -}; } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/zfp/vtkm.module b/vtkm/filter/zfp/vtkm.module new file mode 100644 index 000000000..d72681034 --- /dev/null +++ b/vtkm/filter/zfp/vtkm.module @@ -0,0 +1,8 @@ +NAME + vtkm_filter_zfp +GROUPS + Filters +DEPENDS + vtkm_filter_core +PRIVATE_DEPENDS + vtkm_worklet diff --git a/vtkm/internal/ArrayPortalVirtual.h b/vtkm/internal/ArrayPortalVirtual.h deleted file mode 100644 index bd5ba54b0..000000000 --- a/vtkm/internal/ArrayPortalVirtual.h +++ /dev/null @@ -1,154 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_internal_ArrayPortalVirtual_h -#define vtk_m_internal_ArrayPortalVirtual_h - -#include -#ifdef VTKM_NO_DEPRECATED_VIRTUAL -#error "This header should not be included when VTKM_NO_DEPRECATED_VIRTUAL is set." -#endif //VTKM_NO_DEPRECATED_VIRTUAL - -#include -#include - -#include -#include - -namespace vtkm -{ -namespace internal -{ - -class VTKM_ALWAYS_EXPORT PortalVirtualBase -{ -public: - VTKM_EXEC_CONT PortalVirtualBase() noexcept {} - - VTKM_EXEC_CONT virtual ~PortalVirtualBase() noexcept { - //we implement this as we need a destructor with cuda markup. - //Using =default causes cuda free errors inside VirtualObjectTransferCuda - }; -}; - -} // namespace internal - -template -class VTKM_ALWAYS_EXPORT ArrayPortalVirtual : public internal::PortalVirtualBase -{ -public: - using ValueType = T; - - //use parents constructor - using PortalVirtualBase::PortalVirtualBase; - - VTKM_EXEC_CONT virtual ~ArrayPortalVirtual(){}; - - VTKM_EXEC_CONT virtual T Get(vtkm::Id index) const noexcept = 0; - - VTKM_EXEC_CONT virtual void Set(vtkm::Id, const T&) const noexcept {} -}; - - -template -class VTKM_ALWAYS_EXPORT ArrayPortalWrapper final - : public vtkm::ArrayPortalVirtual -{ - using T = typename PortalT::ValueType; - -public: - ArrayPortalWrapper(const PortalT& p) noexcept - : ArrayPortalVirtual() - , Portal(p) - { - } - - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - ~ArrayPortalWrapper() {} - - VTKM_EXEC_CONT - T Get(vtkm::Id index) const noexcept - { - using call_supported_t = typename internal::PortalSupportsGets::type; - return this->Get(call_supported_t(), index); - } - - VTKM_EXEC_CONT - void Set(vtkm::Id index, const T& value) const noexcept - { - using call_supported_t = typename internal::PortalSupportsSets::type; - this->Set(call_supported_t(), index, value); - } - -private: - // clang-format off - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT inline T Get(std::true_type, vtkm::Id index) const noexcept { return this->Portal.Get(index); } - VTKM_EXEC_CONT inline T Get(std::false_type, vtkm::Id) const noexcept { return T{}; } - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT inline void Set(std::true_type, vtkm::Id index, const T& value) const noexcept { this->Portal.Set(index, value); } - VTKM_EXEC_CONT inline void Set(std::false_type, vtkm::Id, const T&) const noexcept {} - // clang-format on - - - PortalT Portal; -}; - - -template -class VTKM_ALWAYS_EXPORT ArrayPortalRef -{ -public: - using ValueType = T; - - VTKM_EXEC_CONT - ArrayPortalRef() noexcept - : Portal(nullptr) - , NumberOfValues(0) - { - } - - VTKM_EXEC_CONT - ArrayPortalRef(const ArrayPortalVirtual* portal, vtkm::Id numValues) noexcept - : Portal(portal) - , NumberOfValues(numValues) - { - } - - //Currently this needs to be valid on both the host and device for cuda, so we can't - //call the underlying portal as that uses device virtuals and the method will fail. - //We need to seriously look at the interaction of portals and iterators for device - //adapters and determine a better approach as iterators are really fat - VTKM_EXEC_CONT inline vtkm::Id GetNumberOfValues() const noexcept { return this->NumberOfValues; } - - //This isn't valid on the host for cuda - VTKM_EXEC_CONT inline T Get(vtkm::Id index) const noexcept { return this->Portal->Get(index); } - - //This isn't valid on the host for - VTKM_EXEC_CONT inline void Set(vtkm::Id index, const T& t) const noexcept - { - this->Portal->Set(index, t); - } - - const ArrayPortalVirtual* Portal; - vtkm::Id NumberOfValues; -}; - -template -inline ArrayPortalRef make_ArrayPortalRef(const ArrayPortalVirtual* portal, - vtkm::Id numValues) noexcept -{ - return ArrayPortalRef(portal, numValues); -} - - -} // namespace vtkm - -#endif diff --git a/vtkm/internal/CMakeLists.txt b/vtkm/internal/CMakeLists.txt index e3da52118..62e860314 100755 --- a/vtkm/internal/CMakeLists.txt +++ b/vtkm/internal/CMakeLists.txt @@ -38,7 +38,6 @@ elseif(TARGET vtkm::kokkos_hip) endif() set(VTKM_ENABLE_LOGGING ${VTKm_ENABLE_LOGGING}) -set(VTKM_NO_DEPRECATED_VIRTUAL ${VTKm_NO_DEPRECATED_VIRTUAL}) vtkm_get_kit_name(kit_name kit_dir) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in @@ -76,19 +75,9 @@ set(headers Windows.h ) -if (NOT VTKm_NO_DEPRECATED_VIRTUAL) - set(headers ${headers} - ArrayPortalVirtual.h - ) -endif() - vtkm_declare_headers(${headers}) vtkm_pyexpander_generated_file(FunctionInterfaceDetailPre.h) vtkm_pyexpander_generated_file(FunctionInterfaceDetailPost.h) vtkm_pyexpander_generated_file(VariantImplDetail.h) vtkm_pyexpander_generated_file(VecOperators.h) - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/internal/Configure.h.in b/vtkm/internal/Configure.h.in index d75c2d5fa..f290d8e39 100644 --- a/vtkm/internal/Configure.h.in +++ b/vtkm/internal/Configure.h.in @@ -323,10 +323,6 @@ //Mark if we have enabled logging. #cmakedefine VTKM_ENABLE_LOGGING -#ifndef VTKM_NO_DEPRECATED_VIRTUAL -#cmakedefine VTKM_NO_DEPRECATED_VIRTUAL -#endif - // Define a pair of macros, VTKM_SWALLOW_SEMICOLON_PRE_BLOCK and // VTKM_SWALLOW_SEMICOLON_POST_BLOCK that can be used around a block in a // macro to "swallow" the semicolon after the macro's use so that it is diff --git a/vtkm/internal/VariantImpl.h b/vtkm/internal/VariantImpl.h index f22b5458b..1d5a62571 100644 --- a/vtkm/internal/VariantImpl.h +++ b/vtkm/internal/VariantImpl.h @@ -17,7 +17,6 @@ #include -#include #include #include @@ -26,8 +25,6 @@ namespace vtkm { namespace VTK_M_NAMESPACE { -namespace internal -{ // Forward declaration template @@ -126,8 +123,7 @@ template struct VariantTriviallyCopyable; template -struct VariantTriviallyCopyable> - : AllTriviallyCopyable +struct VariantTriviallyCopyable> : AllTriviallyCopyable { }; @@ -135,7 +131,7 @@ template struct VariantTriviallyConstructible; template -struct VariantTriviallyConstructible> +struct VariantTriviallyConstructible> : AllTriviallyConstructible { }; @@ -205,9 +201,8 @@ struct VariantConstructorImpl; // Can trivially construct, deconstruct, and copy all data. (Probably all trivial classes.) template -struct VariantConstructorImpl, - std::true_type, - std::true_type> : VariantStorageImpl +struct VariantConstructorImpl, std::true_type, std::true_type> + : VariantStorageImpl { VariantConstructorImpl() = default; ~VariantConstructorImpl() = default; @@ -221,7 +216,7 @@ struct VariantConstructorImpl, // Can trivially copy, but cannot trivially construct. Common if a class is simple but // initializes itself. template -struct VariantConstructorImpl, +struct VariantConstructorImpl, std::false_type, std::true_type> : VariantStorageImpl { @@ -242,7 +237,7 @@ struct VariantConstructorImpl, // Cannot trivially copy. We assume we cannot trivially construct/destruct. template -struct VariantConstructorImpl, +struct VariantConstructorImpl, construct_type, std::false_type> : VariantStorageImpl { @@ -547,23 +542,12 @@ public: } }; -/// \brief Convert a ListTag to a Variant. -/// -/// Depricated. Use ListAsVariant instead. -/// -template -using ListTagAsVariant VTKM_DEPRECATED( - 1.6, - "vtkm::ListTag is no longer supported. Use vtkm::List instead.") = - vtkm::ListApply; - /// \brief Convert a `List` to a `Variant`. /// template -using ListAsVariant = vtkm::ListApply; +using ListAsVariant = vtkm::ListApply; } -} -} // namespace vtkm::VTK_M_NAMESPACE::internal +} // namespace vtkm::VTK_M_NAMESPACE #undef VTK_M_DEVICE #undef VTK_M_NAMESPACE diff --git a/vtkm/internal/VariantImplDetail.h b/vtkm/internal/VariantImplDetail.h index 61d957997..896c75ed5 100644 --- a/vtkm/internal/VariantImplDetail.h +++ b/vtkm/internal/VariantImplDetail.h @@ -32,8 +32,6 @@ namespace vtkm { namespace VTK_M_NAMESPACE { -namespace internal -{ namespace detail { @@ -1010,5 +1008,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl( } } -} -} // vtkm::VTK_M_NAMESPACE::internal::detail +} // vtkm::VTK_M_NAMESPACE::detail diff --git a/vtkm/internal/VariantImplDetail.h.in b/vtkm/internal/VariantImplDetail.h.in index 823db4170..546cde5fb 100644 --- a/vtkm/internal/VariantImplDetail.h.in +++ b/vtkm/internal/VariantImplDetail.h.in @@ -65,8 +65,6 @@ namespace vtkm { namespace VTK_M_NAMESPACE { -namespace internal -{ namespace detail { @@ -354,5 +352,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl( } } -} -} // vtkm::VTK_M_NAMESPACE::internal::detail +} // vtkm::VTK_M_NAMESPACE::detail diff --git a/vtkm/internal/testing/CMakeLists.txt b/vtkm/internal/testing/CMakeLists.txt deleted file mode 100644 index 41d90beb9..000000000 --- a/vtkm/internal/testing/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(unit_tests - UnitTestArrayPortalBasic.cxx - UnitTestArrayPortalValueReference.cxx - UnitTestConfigureFor32.cxx - UnitTestConfigureFor64.cxx - #UnitTestFunctionInterface.cxx #FIXME - ) -vtkm_unit_tests(SOURCES ${unit_tests}) diff --git a/vtkm/interop/CMakeLists.txt b/vtkm/interop/CMakeLists.txt index 06e65f06b..88ce89a47 100755 --- a/vtkm/interop/CMakeLists.txt +++ b/vtkm/interop/CMakeLists.txt @@ -16,10 +16,6 @@ set(headers #----------------------------------------------------------------------------- vtkm_declare_headers(${headers}) -if(VTKm_ENABLE_TESTING AND TARGET vtkm_rendering) - add_subdirectory(testing) -endif() - #----------------------------------------------------------------------------- add_subdirectory(internal) diff --git a/vtkm/interop/testing/CMakeLists.txt b/vtkm/interop/testing/CMakeLists.txt index afa50e42d..785ad8712 100644 --- a/vtkm/interop/testing/CMakeLists.txt +++ b/vtkm/interop/testing/CMakeLists.txt @@ -45,5 +45,4 @@ if(unit_tests) vtkm_unit_tests(SOURCES ${unit_tests} LIBRARIES vtkm_rendering GLUT::GLUT DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG) - endif() diff --git a/vtkm/interop/vtkm.module b/vtkm/interop/vtkm.module new file mode 100644 index 000000000..72427a8ed --- /dev/null +++ b/vtkm/interop/vtkm.module @@ -0,0 +1,4 @@ +NAME + vtkm_interop +TEST_DEPENDS + vtkm_rendering diff --git a/vtkm/io/CMakeLists.txt b/vtkm/io/CMakeLists.txt index 893c650f9..5c6c17f12 100644 --- a/vtkm/io/CMakeLists.txt +++ b/vtkm/io/CMakeLists.txt @@ -83,16 +83,9 @@ vtkm_library( TEMPLATE_SOURCES ${template_sources} ) -# CMAKE 3.12 does not know about PRIVATE TARGET_OBJECTS -target_link_libraries(vtkm_io PUBLIC vtkm_cont PRIVATE vtkm_lodepng) if (VTKm_ENABLE_HDF5_IO) target_include_directories(vtkm_io PRIVATE $) target_link_libraries(vtkm_io PRIVATE ${HDF5_HL_LIBRARIES}) endif() add_subdirectory(internal) -add_subdirectory(reader) -add_subdirectory(writer) -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/io/VTKDataSetReaderBase.cxx b/vtkm/io/VTKDataSetReaderBase.cxx index ef613a208..03f28c7bd 100644 --- a/vtkm/io/VTKDataSetReaderBase.cxx +++ b/vtkm/io/VTKDataSetReaderBase.cxx @@ -664,10 +664,10 @@ void VTKDataSetReaderBase::ReadGlobalOrPedigreeIds(vtkm::cont::Field::Associatio std::string dataType; this->DataFile->Stream >> dataName >> dataType >> std::ws; internal::parseAssert(dataType == "vtkIdType"); + // vtk writes vtkIdType as int - std::vector buffer(numElements); // vtk writes vtkIdType as int - this->ReadArray(buffer); - vtkm::cont::UnknownArrayHandle data(vtkm::cont::make_ArrayHandleMove(std::move(buffer))); + vtkm::cont::UnknownArrayHandle data = + this->DoReadArrayVariant(association, "int", numElements, 1); this->AddField(dataName, association, data); this->SkipArrayMetaData(1); diff --git a/vtkm/io/VTKDataSetWriter.cxx b/vtkm/io/VTKDataSetWriter.cxx index 78650e6ee..daaf261dc 100644 --- a/vtkm/io/VTKDataSetWriter.cxx +++ b/vtkm/io/VTKDataSetWriter.cxx @@ -320,6 +320,12 @@ void WritePointFields(std::ostream& out, continue; } + if (field.GetName() == dataSet.GetCoordinateSystemName()) + { + // Do not write out the first coordinate system as a field. + continue; + } + vtkm::Id npoints = field.GetNumberOfValues(); int ncomps = field.GetData().GetNumberOfComponentsFlat(); diff --git a/vtkm/io/reader/BOVDataSetReader.h b/vtkm/io/reader/BOVDataSetReader.h deleted file mode 100644 index 5b19480cf..000000000 --- a/vtkm/io/reader/BOVDataSetReader.h +++ /dev/null @@ -1,40 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_io_reader_BOVDataSetReader_h -#define vtk_m_io_reader_BOVDataSetReader_h - -#include -#include - -namespace vtkm -{ -namespace io -{ -namespace reader -{ - -class VTKM_DEPRECATED(1.6, "Please use vtkm::io::BOVDataSetReader.") BOVDataSetReader - : public io::BOVDataSetReader -{ -public: - BOVDataSetReader(const char* fileName) - : io::BOVDataSetReader(fileName) - { - } - BOVDataSetReader(const std::string& fileName) - : io::BOVDataSetReader(fileName) - { - } -}; -} -} -} // vtkm::io::reader - -#endif // vtk_m_io_reader_BOVReader_h diff --git a/vtkm/io/reader/CMakeLists.txt b/vtkm/io/reader/CMakeLists.txt deleted file mode 100644 index 2128ba0a7..000000000 --- a/vtkm/io/reader/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(headers - BOVDataSetReader.h - VTKDataSetReader.h -) - -vtkm_declare_headers( - ${headers} -) diff --git a/vtkm/io/reader/VTKDataSetReader.h b/vtkm/io/reader/VTKDataSetReader.h deleted file mode 100644 index 0f3f99573..000000000 --- a/vtkm/io/reader/VTKDataSetReader.h +++ /dev/null @@ -1,41 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_io_reader_VTKDataSetReader_h -#define vtk_m_io_reader_VTKDataSetReader_h - -#include -#include - -namespace vtkm -{ -namespace io -{ -namespace reader -{ - -class VTKM_DEPRECATED(1.6, "Please use vtkm::io::VTKDataSetReader.") VTKDataSetReader - : public io::VTKDataSetReader -{ -public: - explicit VTKDataSetReader(const char* fileName) - : io::VTKDataSetReader(fileName) - { - } - - explicit VTKDataSetReader(const std::string& fileName) - : io::VTKDataSetReader(fileName) - { - } -}; -} -} -} // vtkm::io::reader - -#endif // vtk_m_io_reader_VTKReader_h diff --git a/vtkm/io/testing/UnitTestBOVDataSetReader.cxx b/vtkm/io/testing/UnitTestBOVDataSetReader.cxx index f1851ac90..606acd2de 100644 --- a/vtkm/io/testing/UnitTestBOVDataSetReader.cxx +++ b/vtkm/io/testing/UnitTestBOVDataSetReader.cxx @@ -45,7 +45,7 @@ void TestReadingBOVDataSet() auto const& ds = readBOVDataSet(bovFile.data()); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); // See the .bov file: DATA SIZE: 50 50 50 VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50, @@ -53,7 +53,7 @@ void TestReadingBOVDataSet() VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 49 * 49 * 49, "Incorrect number of cells"); // See the .bov file: VARIABLE: "var" VTKM_TEST_ASSERT(ds.HasField("var"), "Should have field 'var', but does not."); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "There is only one field in noise.bov"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "There is only one field in noise.bov"); VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "There is only one coordinate system in noise.bov"); diff --git a/vtkm/io/testing/UnitTestVTKDataSetReader.cxx b/vtkm/io/testing/UnitTestVTKDataSetReader.cxx index f3acc02df..7270ddffc 100644 --- a/vtkm/io/testing/UnitTestVTKDataSetReader.cxx +++ b/vtkm/io/testing/UnitTestVTKDataSetReader.cxx @@ -53,7 +53,7 @@ void TestReadingPolyData(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 5, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 8, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 8, "Incorrect number of points (from cell set)"); @@ -70,7 +70,7 @@ void TestReadingPolyDataEmpty() VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 8); VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0); VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 8); - VTKM_TEST_ASSERT(data.GetNumberOfFields() == 1); + VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2); } void TestReadingStructuredPoints(Format format) @@ -81,7 +81,7 @@ void TestReadingStructuredPoints(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 72, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72, "Incorrect number of points (from cell set)"); @@ -99,7 +99,7 @@ void TestReadingStructuredPointsVisIt(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 64, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 64, "Incorrect number of points (from cell set)"); @@ -116,7 +116,7 @@ void TestReadingUnstructuredGrid(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26, "Incorrect number of points (from cell set)"); @@ -133,13 +133,36 @@ void TestReadingV5Format(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 7, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26, "Incorrect number of points (from cell set)"); VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 15, "Incorrect number of cells"); VTKM_TEST_ASSERT(ds.GetCellSet().IsType>(), "Incorrect cellset type"); + + for (vtkm::IdComponent fieldIdx = 0; fieldIdx < ds.GetNumberOfFields(); ++fieldIdx) + { + vtkm::cont::Field field = ds.GetField(fieldIdx); + switch (field.GetAssociation()) + { + case vtkm::cont::Field::Association::Points: + VTKM_TEST_ASSERT(field.GetData().GetNumberOfValues() == ds.GetNumberOfPoints(), + "Field ", + field.GetName(), + " is the wrong size"); + break; + case vtkm::cont::Field::Association::Cells: + VTKM_TEST_ASSERT(field.GetData().GetNumberOfValues() == ds.GetNumberOfCells(), + "Field ", + field.GetName(), + " is the wrong size"); + break; + default: + // Could be any size. + break; + } + } } void TestReadingUnstructuredGridEmpty() @@ -150,7 +173,7 @@ void TestReadingUnstructuredGridEmpty() VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 26); VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0); VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 26); - VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2); + VTKM_TEST_ASSERT(data.GetNumberOfFields() == 3); } void TestReadingUnstructuredPixels() @@ -268,7 +291,7 @@ void TestReadingUnstructuredGridVisIt(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26, "Incorrect number of points (from cell set)"); @@ -286,7 +309,7 @@ void TestReadingRectilinearGrid1(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 125, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 125, "Incorrect number of points (from cell set)"); @@ -304,7 +327,7 @@ void TestReadingRectilinearGrid2(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 24, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 24, "Incorrect number of points (from cell set)"); @@ -320,7 +343,7 @@ void TestReadingStructuredGridASCII() vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 6, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 6, "Incorrect number of points (from cell set)"); @@ -336,7 +359,7 @@ void TestReadingStructuredGridBin() vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 18, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 18, "Incorrect number of points (from cell set)"); @@ -356,7 +379,7 @@ void TestReadingFishTank() VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points (from cell set)"); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.HasField("vec"), "The vtk file has a field 'vec', but the dataset does not."); VTKM_TEST_ASSERT(ds.HasField("vec_magnitude"), "The vtk file has a field 'vec_magnitude', but the dataset does not."); @@ -599,7 +622,7 @@ void TestSkppingStringFields(Format format) vtkm::cont::DataSet ds = readVTKDataSet(testFileName); - VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields"); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields"); VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 72, "Incorrect number of points"); VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72, "Incorrect number of points (from cell set)"); diff --git a/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx b/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx index 94d1393f8..06caecd69 100644 --- a/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx +++ b/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx @@ -53,17 +53,6 @@ struct CheckSameCoordinateSystem CheckSameField{}(originalArray, fileCoords); } -#ifndef VTKM_NO_DEPRECATED_VIRTUAL - VTKM_DEPRECATED_SUPPRESS_BEGIN - template - void operator()(const vtkm::cont::ArrayHandleVirtual& originalArray, - const vtkm::cont::CoordinateSystem& fileCoords) const - { - CheckSameField{}(originalArray, fileCoords); - } - VTKM_DEPRECATED_SUPPRESS_END -#endif - void operator()(const vtkm::cont::ArrayHandleUniformPointCoordinates& originalArray, const vtkm::cont::CoordinateSystem& fileCoords) const { @@ -123,6 +112,13 @@ void CheckWrittenReadData(const vtkm::cont::DataSet& originalData, for (vtkm::IdComponent fieldId = 0; fieldId < originalData.GetNumberOfFields(); ++fieldId) { vtkm::cont::Field originalField = originalData.GetField(fieldId); + if (originalField.IsPointField() && + (originalField.GetName() == originalData.GetCoordinateSystemName())) + { + // Do not check the field that is the first coordinate system. It is likely to have + // changed name because VTK does not name coordinate systems. + continue; + } VTKM_TEST_ASSERT(fileData.HasField(originalField.GetName(), originalField.GetAssociation())); vtkm::cont::Field fileField = fileData.GetField(originalField.GetName(), originalField.GetAssociation()); diff --git a/vtkm/io/vtkm.module b/vtkm/io/vtkm.module new file mode 100644 index 000000000..22dd1c88b --- /dev/null +++ b/vtkm/io/vtkm.module @@ -0,0 +1,10 @@ +NAME + vtkm_io +GROUPS + IO +DEPENDS + vtkm_cont +PRIVATE_DEPENDS + vtkm_lodepng +TEST_OPTIONAL_DEPENDS + vtkm_rendering diff --git a/vtkm/io/writer/CMakeLists.txt b/vtkm/io/writer/CMakeLists.txt deleted file mode 100644 index 9d88e46f2..000000000 --- a/vtkm/io/writer/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(headers - VTKDataSetWriter.h -) - -vtkm_declare_headers( - ${headers} -) diff --git a/vtkm/io/writer/VTKDataSetWriter.h b/vtkm/io/writer/VTKDataSetWriter.h deleted file mode 100644 index da8e3aa28..000000000 --- a/vtkm/io/writer/VTKDataSetWriter.h +++ /dev/null @@ -1,36 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_io_writer_DataSetWriter_h -#define vtk_m_io_writer_DataSetWriter_h - -#include -#include - -namespace vtkm -{ -namespace io -{ -namespace writer -{ - -struct VTKM_DEPRECATED(1.6, "Please use vtkm::io::VTKDataSetWriter") VTKDataSetWriter - : vtkm::io::VTKDataSetWriter -{ -public: - VTKDataSetWriter(const std::string& filename) - : vtkm::io::VTKDataSetWriter(filename) - { - } -}; -} -} -} //namespace vtkm::io::writer - -#endif //vtk_m_io_writer_DataSetWriter_h diff --git a/vtkm/random/CMakeLists.txt b/vtkm/random/CMakeLists.txt index 5074453b4..cec3695c4 100644 --- a/vtkm/random/CMakeLists.txt +++ b/vtkm/random/CMakeLists.txt @@ -12,8 +12,3 @@ set(headers Philox.h) vtkm_declare_headers(${headers}) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/random/vtkm.module b/vtkm/random/vtkm.module new file mode 100644 index 000000000..63dfc7f6c --- /dev/null +++ b/vtkm/random/vtkm.module @@ -0,0 +1,2 @@ +NAME + vtkm_random diff --git a/vtkm/rendering/CMakeLists.txt b/vtkm/rendering/CMakeLists.txt index 9fd4ff251..e19985206 100644 --- a/vtkm/rendering/CMakeLists.txt +++ b/vtkm/rendering/CMakeLists.txt @@ -8,15 +8,6 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -#unconditionally include rendering contexts so that the helper functions -#are around even if rendering isn't enabled -include(VTKmRenderingContexts) - -if(NOT VTKm_ENABLE_RENDERING) - return() -endif() - - set(headers Actor.h AxisAnnotation.h @@ -33,8 +24,6 @@ set(headers ColorLegendAnnotation.h ConnectivityProxy.h Cylinderizer.h - DecodePNG.h # deprecated - EncodePNG.h # deprecated GlyphType.h LineRenderer.h LineRendererBatcher.h @@ -154,23 +143,14 @@ vtkm_library( ) #----------------------------------------------------------------------------- -target_link_libraries(vtkm_rendering PUBLIC vtkm_filter_image_processing vtkm_filter_entity_extraction vtkm_io) if(UNIX AND NOT APPLE) target_link_libraries(vtkm_rendering PRIVATE rt) endif() -#----------------------------------------------------------------------------- -target_link_libraries(vtkm_rendering PUBLIC vtkm_rendering_gl_context) - -if(NOT VTKm_INSTALL_ONLY_LIBRARIES) - install(TARGETS vtkm_rendering_gl_context - EXPORT ${VTKm_EXPORT_NAME} - ) -endif() - #----------------------------------------------------------------------------- add_subdirectory(internal) add_subdirectory(raytracing) -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () + +#----------------------------------------------------------------------------- +# Pretty much obsolete, but might be expected to be exported. +include(VTKmRenderingContexts) diff --git a/vtkm/rendering/Camera.h b/vtkm/rendering/Camera.h index 10918a351..2e8113db0 100644 --- a/vtkm/rendering/Camera.h +++ b/vtkm/rendering/Camera.h @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -98,9 +97,6 @@ public: TwoD, ThreeD, }; - using ModeEnum VTKM_DEPRECATED(1.8, "Use Camaera::Mode") = Mode; - VTKM_DEPRECATED(1.8, "Use Camera::Mode::TwoD.") static constexpr Mode MODE_2D = Mode::TwoD; - VTKM_DEPRECATED(1.8, "Use Camera::Mode::ThreeD.") static constexpr Mode MODE_3D = Mode::ThreeD; VTKM_CONT Camera(Mode vtype = Camera::Mode::ThreeD) diff --git a/vtkm/rendering/Canvas.h b/vtkm/rendering/Canvas.h index bd54a4f36..6da78559b 100644 --- a/vtkm/rendering/Canvas.h +++ b/vtkm/rendering/Canvas.h @@ -13,7 +13,6 @@ #include -#include #include #include #include @@ -44,17 +43,8 @@ public: virtual vtkm::rendering::Canvas* NewCopy() const; - VTKM_DEPRECATED(1.6, "Initialize() does nothing.") - virtual void Initialize() {} - - VTKM_DEPRECATED(1.6, "Activate() does nothing.") - virtual void Activate() {} - virtual void Clear(); - VTKM_DEPRECATED(1.6, "Finish() does nothing.") - virtual void Finish() {} - virtual void BlendBackground(); VTKM_CONT diff --git a/vtkm/rendering/ConnectivityProxy.cxx b/vtkm/rendering/ConnectivityProxy.cxx index 8ac1186d2..751b3ceab 100644 --- a/vtkm/rendering/ConnectivityProxy.cxx +++ b/vtkm/rendering/ConnectivityProxy.cxx @@ -39,20 +39,16 @@ protected: bool CompositeBackground; public: - InternalsType(vtkm::cont::DataSet& dataSet) + InternalsType(const vtkm::cont::DataSet& dataSet, const std::string& fieldName) { Dataset = dataSet; Cells = dataSet.GetCellSet(); Coords = dataSet.GetCoordinateSystem(); Mode = RenderMode::Volume; CompositeBackground = true; - // - // Just grab a default scalar field - // - - if (Dataset.GetNumberOfFields() > 0) + if (!fieldName.empty()) { - this->SetScalarField(Dataset.GetField(0).GetName()); + this->SetScalarField(fieldName); } } @@ -243,8 +239,9 @@ public: VTKM_CONT -ConnectivityProxy::ConnectivityProxy(vtkm::cont::DataSet& dataSet) - : Internals(new InternalsType(dataSet)) +ConnectivityProxy::ConnectivityProxy(const vtkm::cont::DataSet& dataSet, + const std::string& fieldName) + : Internals(new InternalsType(dataSet, fieldName)) { } @@ -259,7 +256,7 @@ ConnectivityProxy::ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset, dataset.AddCoordinateSystem(coords); dataset.AddField(scalarField); - Internals = std::shared_ptr(new InternalsType(dataset)); + Internals = std::shared_ptr(new InternalsType(dataset, scalarField.GetName())); } VTKM_CONT diff --git a/vtkm/rendering/ConnectivityProxy.h b/vtkm/rendering/ConnectivityProxy.h index 8aaa55cdd..6212f0384 100644 --- a/vtkm/rendering/ConnectivityProxy.h +++ b/vtkm/rendering/ConnectivityProxy.h @@ -11,7 +11,6 @@ #define vtk_m_rendering_ConnectivityProxy_h #include -#include #include #include #include @@ -31,7 +30,7 @@ using PartialVector32 = std::vector -#include -#include - -namespace vtkm -{ -namespace rendering -{ - -VTKM_RENDERING_EXPORT -vtkm::UInt32 DecodePNG(std::vector& out_image, - unsigned long& image_width, - unsigned long& image_height, - const unsigned char* in_png, - std::size_t in_size) VTKM_DEPRECATED(1.6, "Please use vtkm::io::DecodePNG") -{ - return vtkm::io::DecodePNG(out_image, image_width, image_height, in_png, in_size); -} -} -} // vtkm::rendering - - -#endif diff --git a/vtkm/rendering/EncodePNG.h b/vtkm/rendering/EncodePNG.h deleted file mode 100644 index 160ebedda..000000000 --- a/vtkm/rendering/EncodePNG.h +++ /dev/null @@ -1,42 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_rendering_EncodePNG_h -#define vtk_m_rendering_EncodePNG_h - -#include -#include - -namespace vtkm -{ -namespace rendering -{ - -VTKM_RENDERING_EXPORT -vtkm::UInt32 EncodePNG(std::vector const& image, - unsigned long width, - unsigned long height, - unsigned char* out_png, - std::size_t out_size) VTKM_DEPRECATED(1.6, "Please use vtkm::io::EncodePNG.") -{ - return io::EncodePNG(image, width, height, out_png, out_size); -} - -VTKM_IO_EXPORT -vtkm::UInt32 SavePNG(std::string const& filename, - std::vector const& image, - unsigned long width, - unsigned long height) VTKM_DEPRECATED("Please use SavePNG from vtkm::io") -{ - return io::SavePNG(filename, image, width, height); -} -} -} // vtkm::rendering - -#endif //vtk_m_rendering_EncodePNG_h diff --git a/vtkm/rendering/Mapper.h b/vtkm/rendering/Mapper.h index 5ee3abced..df3c95c69 100644 --- a/vtkm/rendering/Mapper.h +++ b/vtkm/rendering/Mapper.h @@ -10,7 +10,6 @@ #ifndef vtk_m_rendering_Mapper_h #define vtk_m_rendering_Mapper_h -#include #include #include #include @@ -39,12 +38,6 @@ public: virtual void SetActiveColorTable(const vtkm::cont::ColorTable& ct); - VTKM_DEPRECATED(1.6, "StartScene() does nothing") - void StartScene() {} - - VTKM_DEPRECATED(1.6, "EndScene() does nothing") - void EndScene() {} - virtual void SetCanvas(vtkm::rendering::Canvas* canvas) = 0; virtual vtkm::rendering::Canvas* GetCanvas() const = 0; diff --git a/vtkm/rendering/MapperGlyphScalar.cxx b/vtkm/rendering/MapperGlyphScalar.cxx index c175362d5..7943daaa4 100644 --- a/vtkm/rendering/MapperGlyphScalar.cxx +++ b/vtkm/rendering/MapperGlyphScalar.cxx @@ -363,7 +363,7 @@ void MapperGlyphScalar::RenderCells(const vtkm::cont::UnknownCellSet& cellset, vtkm::cont::DataSet processedDataSet = this->FilterPoints(cellset, coords, scalarField); vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet(); vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem(); - vtkm::cont::Field processedField = processedDataSet.GetField(0); + vtkm::cont::Field processedField = processedDataSet.GetField(scalarField.GetName()); if (this->ScaleByValue) { diff --git a/vtkm/rendering/MapperGlyphVector.cxx b/vtkm/rendering/MapperGlyphVector.cxx index 873d1eaec..4152608ad 100644 --- a/vtkm/rendering/MapperGlyphVector.cxx +++ b/vtkm/rendering/MapperGlyphVector.cxx @@ -86,7 +86,7 @@ void MapperGlyphVector::RenderCells(const vtkm::cont::UnknownCellSet& cellset, vtkm::cont::DataSet processedDataSet = this->FilterPoints(cellset, coords, field); vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet(); vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem(); - vtkm::cont::Field processedField = processedDataSet.GetField(0); + vtkm::cont::Field processedField = processedDataSet.GetField(field.GetName()); if (this->ScaleByValue) { diff --git a/vtkm/rendering/MapperWireframer.cxx b/vtkm/rendering/MapperWireframer.cxx index 9f79c3913..73b91a051 100644 --- a/vtkm/rendering/MapperWireframer.cxx +++ b/vtkm/rendering/MapperWireframer.cxx @@ -303,7 +303,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::UnknownCellSet& inCellSet, externalFaces.SetPassPolyData(true); vtkm::cont::DataSet output = externalFaces.Execute(dataSet); cellSet = output.GetCellSet(); - actualField = output.GetField(0); + actualField = output.GetField(inScalarField.GetName()); } // Extract unique edges from the cell set. diff --git a/vtkm/rendering/TextAnnotation.h b/vtkm/rendering/TextAnnotation.h index dd2b7ae4f..7dae167e1 100644 --- a/vtkm/rendering/TextAnnotation.h +++ b/vtkm/rendering/TextAnnotation.h @@ -16,8 +16,6 @@ #include #include -#include - namespace vtkm { namespace rendering diff --git a/vtkm/rendering/View.cxx b/vtkm/rendering/View.cxx index e3c775c64..f99e5f87e 100644 --- a/vtkm/rendering/View.cxx +++ b/vtkm/rendering/View.cxx @@ -149,8 +149,6 @@ void View::SetForegroundColor(const vtkm::rendering::Color& color) this->Internal->CanvasPointer->SetForegroundColor(color); } -void View::Initialize() {} - void View::SaveAs(const std::string& fileName) const { this->GetCanvas().SaveAs(fileName); @@ -161,16 +159,6 @@ void View::SetAxisColor(vtkm::rendering::Color c) this->AxisColor = c; } -void View::ClearAnnotations() -{ - this->Internal->TextAnnotations.clear(); -} - -void View::AddAnnotation(std::unique_ptr ann) -{ - this->Internal->TextAnnotations.push_back(std::move(ann)); -} - void View::ClearTextAnnotations() { this->Internal->TextAnnotations.clear(); diff --git a/vtkm/rendering/View.h b/vtkm/rendering/View.h index e8c65b8e8..e964c136d 100644 --- a/vtkm/rendering/View.h +++ b/vtkm/rendering/View.h @@ -12,7 +12,6 @@ #include -#include #include #include #include @@ -93,9 +92,6 @@ public: VTKM_CONT void SetRenderAnnotationsEnabled(bool val) { this->RenderAnnotationsEnabled = val; } VTKM_CONT bool GetRenderAnnotationsEnabled() { return this->RenderAnnotationsEnabled; } - VTKM_DEPRECATED(1.6, "Initialize() does nothing.") - virtual void Initialize(); - virtual void Paint() = 0; virtual void RenderScreenAnnotations() = 0; virtual void RenderWorldAnnotations() = 0; @@ -104,11 +100,6 @@ public: void SaveAs(const std::string& fileName) const; - VTKM_CONT VTKM_DEPRECATED(1.6, "Use ClearTextAnnotations Instead") void ClearAnnotations(); - - VTKM_CONT VTKM_DEPRECATED(1.6, "Use AddTextAnnotation Instead") void AddAnnotation( - std::unique_ptr ann); - VTKM_CONT void SetAxisColor(vtkm::rendering::Color c); diff --git a/vtkm/rendering/raytracing/BoundingVolumeHierarchy.cxx b/vtkm/rendering/raytracing/BoundingVolumeHierarchy.cxx index 2d1314abc..5381ac39f 100644 --- a/vtkm/rendering/raytracing/BoundingVolumeHierarchy.cxx +++ b/vtkm/rendering/raytracing/BoundingVolumeHierarchy.cxx @@ -47,9 +47,6 @@ public: class GatherFloat32; - template - class GatherVecCast; - class CreateLeafs; class BVHData; @@ -118,37 +115,6 @@ public: } }; //class createLeafs -template -class LinearBVHBuilder::GatherVecCast : public vtkm::worklet::WorkletMapField -{ -private: - using Vec4IdArrayHandle = typename vtkm::cont::ArrayHandle; - using Vec4IntArrayHandle = typename vtkm::cont::ArrayHandle; - using PortalConst = typename Vec4IdArrayHandle::ReadPortalType; - using Portal = typename Vec4IntArrayHandle::WritePortalType; - -private: - PortalConst InputPortal; - Portal OutputPortal; - -public: - VTKM_CONT - GatherVecCast(const Vec4IdArrayHandle& inputPortal, - Vec4IntArrayHandle& outputPortal, - const vtkm::Id& size) - : InputPortal(inputPortal.PrepareForInput(DeviceAdapterTag())) - { - this->OutputPortal = outputPortal.PrepareForOutput(size, DeviceAdapterTag()); - } - using ControlSignature = void(FieldIn); - using ExecutionSignature = void(WorkIndex, _1); - VTKM_EXEC - void operator()(const vtkm::Id& outIndex, const vtkm::Id& inIndex) const - { - OutputPortal.Set(outIndex, InputPortal.Get(inIndex)); - } -}; //class GatherVec3Id - class LinearBVHBuilder::BVHData { public: diff --git a/vtkm/rendering/raytracing/Camera.cxx b/vtkm/rendering/raytracing/Camera.cxx index 1f9ef03ef..83d2e229d 100644 --- a/vtkm/rendering/raytracing/Camera.cxx +++ b/vtkm/rendering/raytracing/Camera.cxx @@ -500,20 +500,6 @@ void Camera::SetParameters(const vtkm::rendering::Camera& camera, this->CameraView = camera; } -VTKM_DEPRECATED(1.6, "Use the canvas width and height rather than the canvas itself.") -VTKM_CONT void Camera::SetParameters(const vtkm::rendering::Camera& camera, - vtkm::rendering::CanvasRayTracer& canvas) -{ - this->SetUp(camera.GetViewUp()); - this->SetLookAt(camera.GetLookAt()); - this->SetPosition(camera.GetPosition()); - this->SetZoom(camera.GetZoom()); - this->SetFieldOfView(camera.GetFieldOfView()); - this->SetHeight(vtkm::Int32(canvas.GetHeight())); - this->SetWidth(vtkm::Int32(canvas.GetWidth())); - this->CameraView = camera; -} - VTKM_CONT void Camera::SetHeight(const vtkm::Int32& height) diff --git a/vtkm/rendering/raytracing/MeshConnectivity.h b/vtkm/rendering/raytracing/MeshConnectivity.h index 7eea2d799..6ea6d93bb 100644 --- a/vtkm/rendering/raytracing/MeshConnectivity.h +++ b/vtkm/rendering/raytracing/MeshConnectivity.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -250,7 +250,7 @@ public: /// \brief General version of mesh connectivity that can be used for all supported mesh types. class VTKM_ALWAYS_EXPORT MeshConnectivity { - using ConnectivityType = vtkm::exec::internal:: + using ConnectivityType = vtkm::exec:: Variant; ConnectivityType Connectivity; diff --git a/vtkm/rendering/testing/CMakeLists.txt b/vtkm/rendering/testing/CMakeLists.txt index 181f41c4a..0b97eb5bf 100644 --- a/vtkm/rendering/testing/CMakeLists.txt +++ b/vtkm/rendering/testing/CMakeLists.txt @@ -8,11 +8,6 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -set(headers - RenderTest.h - Testing.h -) - vtkm_declare_headers(${headers}) set(unit_tests @@ -30,18 +25,4 @@ set(unit_tests UnitTestMapperGlyphVector.cxx ) -set(library_sources - RenderTest.cxx - Testing.cxx - ) - -vtkm_library( - NAME vtkm_rendering_testing - # When rendering code no longer needs a device compiler, this should change to SOURCES - DEVICE_SOURCES ${library_sources} - HEADERS ${headers} - ) -target_link_libraries(vtkm_rendering_testing PUBLIC vtkm_cont_testing vtkm_rendering) -target_link_libraries(vtkm_rendering_testing PRIVATE vtkm_io) - -vtkm_unit_tests(SOURCES ${unit_tests} LIBRARIES vtkm_rendering vtkm_rendering_testing) +vtkm_unit_tests(SOURCES ${unit_tests}) diff --git a/vtkm/rendering/testing/RenderTest.h b/vtkm/rendering/testing/RenderTest.h index 57417f338..837034562 100644 --- a/vtkm/rendering/testing/RenderTest.h +++ b/vtkm/rendering/testing/RenderTest.h @@ -10,7 +10,11 @@ #ifndef vtk_m_rendering_testing_RenderTest_h #define vtk_m_rendering_testing_RenderTest_h -#include +// Because the testing directory is reserved for test executables and not +// libraries, the vtkm_rendering_testing module has to put this file in +// vtkm/rendering/testlib instead of vtkm/rendering/testing where you normally +// would expect it. +#include #include #include diff --git a/vtkm/rendering/testing/Testing.h b/vtkm/rendering/testing/Testing.h index b93744f7b..7bc391510 100644 --- a/vtkm/rendering/testing/Testing.h +++ b/vtkm/rendering/testing/Testing.h @@ -24,7 +24,11 @@ #include -#include +// Because the testing directory is reserved for test executables and not +// libraries, the vtkm_rendering_testing module has to put this file in +// vtkm/rendering/testlib instead of vtkm/rendering/testing where you normally +// would expect it. +#include #include #include diff --git a/vtkm/rendering/testlib/CMakeLists.txt b/vtkm/rendering/testlib/CMakeLists.txt new file mode 100644 index 000000000..317b5c34e --- /dev/null +++ b/vtkm/rendering/testlib/CMakeLists.txt @@ -0,0 +1,30 @@ +##============================================================================ +## 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. +##============================================================================ + +# Headers, which are used by tests all over VTK-m, are expected to be in the +# testing directory where tests are located. We could move things around so +# that this module is built in the testing directory and the tests are created +# somewhere else, which would also be confusing to developers trying to add +# tests. This seems like the least confusing option. +set(headers + ../testing/RenderTest.h + ../testing/Testing.h +) + +set(sources + RenderTest.cxx + Testing.cxx + ) + +vtkm_library( + NAME vtkm_rendering_testing + SOURCES ${sources} + HEADERS ${headers} + ) diff --git a/vtkm/rendering/testing/RenderTest.cxx b/vtkm/rendering/testlib/RenderTest.cxx similarity index 100% rename from vtkm/rendering/testing/RenderTest.cxx rename to vtkm/rendering/testlib/RenderTest.cxx diff --git a/vtkm/rendering/testing/Testing.cxx b/vtkm/rendering/testlib/Testing.cxx similarity index 100% rename from vtkm/rendering/testing/Testing.cxx rename to vtkm/rendering/testlib/Testing.cxx diff --git a/vtkm/rendering/testlib/vtkm.module b/vtkm/rendering/testlib/vtkm.module new file mode 100644 index 000000000..6c0e4154d --- /dev/null +++ b/vtkm/rendering/testlib/vtkm.module @@ -0,0 +1,9 @@ +NAME + vtkm_rendering_testing +GROUPS + Testing +DEPENDS + vtkm_cont_testing vtkm_rendering +PRIVATE_DEPENDS + vtkm_io +NO_TESTING diff --git a/vtkm/rendering/vtkm.module b/vtkm/rendering/vtkm.module new file mode 100644 index 000000000..1c417eb8b --- /dev/null +++ b/vtkm/rendering/vtkm.module @@ -0,0 +1,10 @@ +NAME + vtkm_rendering +GROUPS + Rendering +DEPENDS + vtkm_filter_image_processing + vtkm_filter_entity_extraction + vtkm_io +TEST_DEPENDS + vtkm_rendering_testing diff --git a/vtkm/source/Amr.cxx b/vtkm/source/Amr.cxx index dcc3df35d..605fefc4a 100644 --- a/vtkm/source/Amr.cxx +++ b/vtkm/source/Amr.cxx @@ -30,8 +30,6 @@ Amr::Amr(vtkm::IdComponent dimension, { } -Amr::~Amr() = default; - template vtkm::cont::DataSet Amr::GenerateDataSet(unsigned int level, unsigned int amrIndex) const { @@ -53,10 +51,11 @@ vtkm::cont::DataSet Amr::GenerateDataSet(unsigned int level, unsigned int amrInd center[2] = 0; } - vtkm::source::Wavelet waveletSource(-extent, extent); + vtkm::source::Wavelet waveletSource; waveletSource.SetOrigin(origin); waveletSource.SetSpacing(spacing); waveletSource.SetCenter(center); + waveletSource.SetExtent(-extent, extent); waveletSource.SetFrequency(frequency); waveletSource.SetStandardDeviation(deviation); vtkm::cont::DataSet wavelet = waveletSource.Execute(); diff --git a/vtkm/source/Amr.h b/vtkm/source/Amr.h index bd451f84a..c5868a435 100644 --- a/vtkm/source/Amr.h +++ b/vtkm/source/Amr.h @@ -58,22 +58,39 @@ namespace source class VTKM_SOURCE_EXPORT Amr { public: - VTKM_CONT - Amr(vtkm::IdComponent dimension = 2, - vtkm::IdComponent cellsPerDimension = 6, - vtkm::IdComponent numberOfLevels = 4); - VTKM_CONT - ~Amr(); + VTKM_CONT Amr() = default; - vtkm::cont::PartitionedDataSet Execute() const; + VTKM_CONT VTKM_DEPRECATED(2.0, "Use Set* methods to set parameters.") + Amr(vtkm::IdComponent dimension, + vtkm::IdComponent cellsPerDimension = 6, + vtkm::IdComponent numberOfLevels = 4); + + VTKM_CONT ~Amr() = default; + + VTKM_CONT void SetDimension(vtkm::IdComponent dimension) { this->Dimension = dimension; } + VTKM_CONT vtkm::IdComponent GetDimension() const { return this->Dimension; } + + VTKM_CONT void SetCellsPerDimension(vtkm::IdComponent cellsPerDimension) + { + this->CellsPerDimension = cellsPerDimension; + } + VTKM_CONT vtkm::IdComponent GetCellsPerDimension() const { return this->CellsPerDimension; } + + VTKM_CONT void SetNumberOfLevels(vtkm::IdComponent numberOfLevels) + { + this->NumberOfLevels = numberOfLevels; + } + VTKM_CONT vtkm::IdComponent GetNumberOfLevels() const { return this->NumberOfLevels; } + + VTKM_CONT vtkm::cont::PartitionedDataSet Execute() const; private: template vtkm::cont::DataSet GenerateDataSet(unsigned int level, unsigned int amrIndex) const; - vtkm::IdComponent Dimension; - vtkm::IdComponent CellsPerDimension; - vtkm::IdComponent NumberOfLevels; + vtkm::IdComponent Dimension = 2; + vtkm::IdComponent CellsPerDimension = 6; + vtkm::IdComponent NumberOfLevels = 4; }; } //namespace source } //namespace vtkm diff --git a/vtkm/source/CMakeLists.txt b/vtkm/source/CMakeLists.txt index d5ad5e314..50a362606 100644 --- a/vtkm/source/CMakeLists.txt +++ b/vtkm/source/CMakeLists.txt @@ -30,10 +30,3 @@ vtkm_library(NAME vtkm_source DEVICE_SOURCES ${device_sources} HEADERS ${headers} ) - -target_link_libraries(vtkm_source PUBLIC vtkm_cont vtkm_filter_field_conversion vtkm_filter_multi_block) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/source/Oscillator.cxx b/vtkm/source/Oscillator.cxx index d3976e9eb..ed3a17701 100644 --- a/vtkm/source/Oscillator.cxx +++ b/vtkm/source/Oscillator.cxx @@ -10,13 +10,10 @@ #include #include -namespace vtkm +namespace { -namespace source -{ -namespace internal -{ -struct Oscillator + +struct Oscillation { vtkm::Vec3f Center; vtkm::FloatDefault Radius; @@ -24,7 +21,7 @@ struct Oscillator vtkm::FloatDefault Zeta; }; -class OscillatorSource : public vtkm::worklet::WorkletMapField +class OscillatorWorklet : public vtkm::worklet::WorkletMapField { public: typedef void ControlSignature(FieldIn, FieldOut); @@ -40,7 +37,7 @@ public: { if (this->PeriodicOscillators.GetNumberOfComponents() < MAX_OSCILLATORS) { - this->PeriodicOscillators.Append(Oscillator{ { x, y, z }, radius, omega, zeta }); + this->PeriodicOscillators.Append(Oscillation{ { x, y, z }, radius, omega, zeta }); } } @@ -54,7 +51,7 @@ public: { if (this->DampedOscillators.GetNumberOfComponents() < MAX_OSCILLATORS) { - this->DampedOscillators.Append(Oscillator{ { x, y, z }, radius, omega, zeta }); + this->DampedOscillators.Append(Oscillation{ { x, y, z }, radius, omega, zeta }); } } @@ -68,7 +65,7 @@ public: { if (this->DecayingOscillators.GetNumberOfComponents() < MAX_OSCILLATORS) { - this->DecayingOscillators.Append(Oscillator{ { x, y, z }, radius, omega, zeta }); + this->DecayingOscillators.Append(Oscillation{ { x, y, z }, radius, omega, zeta }); } } @@ -80,7 +77,7 @@ public: { vtkm::UInt8 oIdx; vtkm::FloatDefault t0, t, result = 0; - const internal::Oscillator* oscillator; + const Oscillation* oscillator; t0 = 0.0; t = vtkm::FloatDefault(this->Time * 2 * 3.14159265358979323846); @@ -136,27 +133,64 @@ public: private: static constexpr vtkm::IdComponent MAX_OSCILLATORS = 10; - vtkm::VecVariable PeriodicOscillators; - vtkm::VecVariable DampedOscillators; - vtkm::VecVariable DecayingOscillators; + vtkm::VecVariable PeriodicOscillators; + vtkm::VecVariable DampedOscillators; + vtkm::VecVariable DecayingOscillators; vtkm::FloatDefault Time{}; -}; // OscillatorSource +}; // OscillatorWorklet -} // internal +} // anonymous namespace + +namespace vtkm +{ +namespace source +{ + +//----------------------------------------------------------------------------- +struct Oscillator::InternalStruct +{ + vtkm::Id3 PointDimensions = { 3, 3, 3 }; + OscillatorWorklet Worklet; +}; + +//----------------------------------------------------------------------------- +Oscillator::Oscillator() + : Internals(new InternalStruct) +{ +} //----------------------------------------------------------------------------- Oscillator::Oscillator(vtkm::Id3 dims) - : Dims(dims) - , Worklet(std::make_unique()) + : Internals(new InternalStruct) { + this->SetCellDimensions(dims); } Oscillator::~Oscillator() = default; +//----------------------------------------------------------------------------- +void Oscillator::SetPointDimensions(vtkm::Id3 pointDimensions) +{ + this->Internals->PointDimensions = pointDimensions; +} +vtkm::Id3 Oscillator::GetPointDimensions() const +{ + return this->Internals->PointDimensions; +} + +void Oscillator::SetCellDimensions(vtkm::Id3 cellDimensions) +{ + this->SetPointDimensions(cellDimensions + vtkm::Id3(1)); +} +vtkm::Id3 Oscillator::GetCellDimensions() const +{ + return this->GetPointDimensions() - vtkm::Id3(1); +} + //----------------------------------------------------------------------------- void Oscillator::SetTime(vtkm::FloatDefault time) { - this->Worklet->SetTime(time); + this->Internals->Worklet.SetTime(time); } //----------------------------------------------------------------------------- @@ -167,7 +201,7 @@ void Oscillator::AddPeriodic(vtkm::FloatDefault x, vtkm::FloatDefault omega, vtkm::FloatDefault zeta) { - this->Worklet->AddPeriodic(x, y, z, radius, omega, zeta); + this->Internals->Worklet.AddPeriodic(x, y, z, radius, omega, zeta); } //----------------------------------------------------------------------------- @@ -178,7 +212,7 @@ void Oscillator::AddDamped(vtkm::FloatDefault x, vtkm::FloatDefault omega, vtkm::FloatDefault zeta) { - this->Worklet->AddDamped(x, y, z, radius, omega, zeta); + this->Internals->Worklet.AddDamped(x, y, z, radius, omega, zeta); } //----------------------------------------------------------------------------- @@ -189,7 +223,7 @@ void Oscillator::AddDecaying(vtkm::FloatDefault x, vtkm::FloatDefault omega, vtkm::FloatDefault zeta) { - this->Worklet->AddDecaying(x, y, z, radius, omega, zeta); + this->Internals->Worklet.AddDecaying(x, y, z, radius, omega, zeta); } @@ -200,22 +234,23 @@ vtkm::cont::DataSet Oscillator::DoExecute() const vtkm::cont::DataSet dataSet; - const vtkm::Id3 pdims{ this->Dims + vtkm::Id3{ 1, 1, 1 } }; vtkm::cont::CellSetStructured<3> cellSet; - cellSet.SetPointDimensions(pdims); + vtkm::Id3 pointDims = this->GetPointDimensions(); + cellSet.SetPointDimensions(pointDims); dataSet.SetCellSet(cellSet); + vtkm::Id3 cellDims = this->GetCellDimensions(); const vtkm::Vec3f origin(0.0f, 0.0f, 0.0f); - const vtkm::Vec3f spacing(1.0f / static_cast(this->Dims[0]), - 1.0f / static_cast(this->Dims[1]), - 1.0f / static_cast(this->Dims[2])); + const vtkm::Vec3f spacing(1.0f / static_cast(cellDims[0]), + 1.0f / static_cast(cellDims[1]), + 1.0f / static_cast(cellDims[2])); - vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(pdims, origin, spacing); + vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(pointDims, origin, spacing); dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); vtkm::cont::ArrayHandle outArray; - this->Invoke(*(this->Worklet), coordinates, outArray); + this->Invoke(this->Internals->Worklet, coordinates, outArray); dataSet.AddField(vtkm::cont::make_FieldPoint("oscillating", outArray)); return dataSet; diff --git a/vtkm/source/Oscillator.h b/vtkm/source/Oscillator.h index 547d74dfc..1600b685f 100644 --- a/vtkm/source/Oscillator.h +++ b/vtkm/source/Oscillator.h @@ -16,10 +16,6 @@ namespace vtkm { namespace source { -namespace internal -{ -class OscillatorSource; -} /**\brief An analytical, time-varying uniform dataset with a point based array * @@ -32,15 +28,22 @@ class OscillatorSource; class VTKM_SOURCE_EXPORT Oscillator final : public vtkm::source::Source { public: + VTKM_CONT Oscillator(); + ///Construct a Oscillator with Cell Dimensions - VTKM_CONT - explicit Oscillator(vtkm::Id3 dims); + VTKM_CONT VTKM_DEPRECATED( + 2.0, + "Use SetCellDimensions or SetPointDimensions.") explicit Oscillator(vtkm::Id3 dims); // We can not declare default destructor here since compiler does not know how // to create one for the Worklet at this point yet. However, the implementation // in Oscillator.cxx does have ~Oscillator() = default; - VTKM_CONT - ~Oscillator() override; + VTKM_CONT ~Oscillator() override; + + VTKM_CONT void SetPointDimensions(vtkm::Id3 pointDimensions); + VTKM_CONT vtkm::Id3 GetPointDimensions() const; + VTKM_CONT void SetCellDimensions(vtkm::Id3 pointDimensions); + VTKM_CONT vtkm::Id3 GetCellDimensions() const; VTKM_CONT void SetTime(vtkm::FloatDefault time); @@ -72,8 +75,8 @@ public: private: VTKM_CONT vtkm::cont::DataSet DoExecute() const override; - vtkm::Id3 Dims; - std::unique_ptr Worklet; + struct InternalStruct; + std::unique_ptr Internals; }; } } diff --git a/vtkm/source/PerlinNoise.cxx b/vtkm/source/PerlinNoise.cxx index d5116b90b..3b667b26b 100644 --- a/vtkm/source/PerlinNoise.cxx +++ b/vtkm/source/PerlinNoise.cxx @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -46,14 +46,15 @@ struct PerlinNoiseWorklet : public vtkm::worklet::WorkletVisitPointsWithCells vtkm::FloatDefault w = this->Fade(zf); vtkm::Id aaa, aba, aab, abb, baa, bba, bab, bbb; - aaa = perms[perms[perms[xi] + yi] + zi]; - aba = perms[perms[perms[xi] + this->Increment(yi)] + zi]; - aab = perms[perms[perms[xi] + yi] + this->Increment(zi)]; - abb = perms[perms[perms[xi] + this->Increment(yi)] + this->Increment(zi)]; - baa = perms[perms[perms[this->Increment(xi)] + yi] + zi]; - bba = perms[perms[perms[this->Increment(xi)] + this->Increment(yi)] + zi]; - bab = perms[perms[perms[this->Increment(xi)] + yi] + this->Increment(zi)]; - bbb = perms[perms[perms[this->Increment(xi)] + this->Increment(yi)] + this->Increment(zi)]; + aaa = perms.Get(perms.Get(perms.Get(xi) + yi) + zi); + aba = perms.Get(perms.Get(perms.Get(xi) + this->Increment(yi)) + zi); + aab = perms.Get(perms.Get(perms.Get(xi) + yi) + this->Increment(zi)); + abb = perms.Get(perms.Get(perms.Get(xi) + this->Increment(yi)) + this->Increment(zi)); + baa = perms.Get(perms.Get(perms.Get(this->Increment(xi)) + yi) + zi); + bba = perms.Get(perms.Get(perms.Get(this->Increment(xi)) + this->Increment(yi)) + zi); + bab = perms.Get(perms.Get(perms.Get(this->Increment(xi)) + yi) + this->Increment(zi)); + bbb = perms.Get(perms.Get(perms.Get(this->Increment(xi)) + this->Increment(yi)) + + this->Increment(zi)); vtkm::FloatDefault x1, x2, y1, y2; x1 = vtkm::Lerp(this->Gradient(aaa, xf, yf, zf), this->Gradient(baa, xf - 1, yf, zf), u); @@ -124,10 +125,10 @@ struct PerlinNoiseWorklet : public vtkm::worklet::WorkletVisitPointsWithCells vtkm::Id Repeat; }; -class PerlinNoiseField : public vtkm::filter::NewFilterField +class PerlinNoiseField : public vtkm::filter::FilterField { public: - VTKM_CONT PerlinNoiseField(vtkm::IdComponent tableSize, vtkm::Id seed) + VTKM_CONT PerlinNoiseField(vtkm::IdComponent tableSize, vtkm::IdComponent seed) : TableSize(tableSize) , Seed(seed) { @@ -167,7 +168,7 @@ private: } vtkm::IdComponent TableSize; - vtkm::Id Seed; + vtkm::IdComponent Seed; vtkm::cont::ArrayHandle Permutations; }; @@ -179,25 +180,30 @@ namespace source { PerlinNoise::PerlinNoise(vtkm::Id3 dims) - : PerlinNoise(dims, vtkm::Vec3f(0), static_cast(time(NULL))) + : PerlinNoise() { + this->SetCellDimensions(dims); } PerlinNoise::PerlinNoise(vtkm::Id3 dims, vtkm::IdComponent seed) - : PerlinNoise(dims, vtkm::Vec3f(0), seed) + : PerlinNoise() { + this->SetCellDimensions(dims); + this->SetSeed(seed); } PerlinNoise::PerlinNoise(vtkm::Id3 dims, vtkm::Vec3f origin) - : PerlinNoise(dims, origin, static_cast(time(NULL))) + : PerlinNoise() { + this->SetCellDimensions(dims); + this->SetOrigin(origin); } PerlinNoise::PerlinNoise(vtkm::Id3 dims, vtkm::Vec3f origin, vtkm::IdComponent seed) - : Dims(dims) - , Origin(origin) - , Seed(seed) { + this->SetCellDimensions(dims); + this->SetOrigin(origin); + this->SetSeed(seed); } vtkm::cont::DataSet PerlinNoise::DoExecute() const @@ -205,21 +211,39 @@ vtkm::cont::DataSet PerlinNoise::DoExecute() const VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf); vtkm::cont::DataSet dataSet; - const vtkm::Id3 pdims{ this->Dims + vtkm::Id3{ 1, 1, 1 } }; - const vtkm::Vec3f spacing(1.0f / static_cast(this->Dims[0]), - 1.0f / static_cast(this->Dims[1]), - 1.0f / static_cast(this->Dims[2])); + const vtkm::Vec3f cellDims = this->GetCellDimensions(); + const vtkm::Vec3f spacing(1.0f / cellDims[0], 1.0f / cellDims[1], 1.0f / cellDims[2]); vtkm::cont::CellSetStructured<3> cellSet; - cellSet.SetPointDimensions(pdims); + cellSet.SetPointDimensions(this->PointDimensions); dataSet.SetCellSet(cellSet); - vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(pdims, this->Origin, spacing); + vtkm::cont::ArrayHandleUniformPointCoordinates coordinates( + this->PointDimensions, this->Origin, spacing); dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); - auto tableSize = static_cast( - vtkm::Max(this->Dims[0], vtkm::Max(this->Dims[1], this->Dims[2]))); - PerlinNoiseField noiseGenerator(tableSize, this->Seed); + auto tableSize = + static_cast(vtkm::Max(cellDims[0], vtkm::Max(cellDims[1], cellDims[2]))); + + vtkm::IdComponent seed = this->Seed; + if (!this->SeedSet) + { + // If a seed has not been chosen, create a unique seed here. It is done here instead + // of the `PerlinNoise` source constructor for 2 reasons. First, `std::random_device` + // can be slow. If the user wants to specify a seed, it makes no sense to spend + // time generating a random seed only to overwrite it. Second, creating the seed + // here allows subsequent runs of the `PerlinNoise` source to have different random + // results if a seed is not specified. + // + // It is also worth noting that the current time is added to the random number. + // This is because the spec for std::random_device allows it to be deterministic + // if nondeterministic hardware is unavailable and the deterministic numbers can + // be the same for every execution of the program. Adding the current time is + // a fallback for that case. + seed = static_cast(std::random_device{}() + time(NULL)); + } + + PerlinNoiseField noiseGenerator(tableSize, seed); noiseGenerator.SetOutputFieldName("perlinnoise"); dataSet = noiseGenerator.Execute(dataSet); diff --git a/vtkm/source/PerlinNoise.h b/vtkm/source/PerlinNoise.h index 670ceefce..5944200d1 100644 --- a/vtkm/source/PerlinNoise.h +++ b/vtkm/source/PerlinNoise.h @@ -29,22 +29,49 @@ namespace source class VTKM_SOURCE_EXPORT PerlinNoise final : public vtkm::source::Source { public: - ///Construct a PerlinNoise with Cell Dimensions + VTKM_CONT PerlinNoise() = default; + VTKM_CONT ~PerlinNoise() = default; + + VTKM_CONT PerlinNoise(const PerlinNoise&) = default; + VTKM_CONT PerlinNoise(PerlinNoise&&) = default; + VTKM_CONT PerlinNoise& operator=(const PerlinNoise&) = default; + VTKM_CONT PerlinNoise& operator=(PerlinNoise&&) = default; + + VTKM_DEPRECATED(2.0, "Use SetCellDimensions or SetPointDimensions.") VTKM_CONT PerlinNoise(vtkm::Id3 dims); + VTKM_DEPRECATED(2.0, "Use Set*Dimensions and SetSeed.") VTKM_CONT PerlinNoise(vtkm::Id3 dims, vtkm::IdComponent seed); + VTKM_DEPRECATED(2.0, "Use Set*Dimensions and SetOrigin.") VTKM_CONT PerlinNoise(vtkm::Id3 dims, vtkm::Vec3f origin); + VTKM_DEPRECATED(2.0, "Use Set*Dimensions, SetOrigin, and SetSeed.") VTKM_CONT PerlinNoise(vtkm::Id3 dims, vtkm::Vec3f origin, vtkm::IdComponent seed); - vtkm::IdComponent GetSeed() const { return this->Seed; } + VTKM_CONT vtkm::Id3 GetPointDimensions() const { return this->PointDimensions; } + VTKM_CONT void SetPointDimensions(vtkm::Id3 dims) { this->PointDimensions = dims; } - void SetSeed(vtkm::IdComponent seed) { this->Seed = seed; } + VTKM_CONT vtkm::Id3 GetCellDimensions() const { return this->PointDimensions - vtkm::Id3(1); } + VTKM_CONT void SetCellDimensions(vtkm::Id3 dims) { this->PointDimensions = dims + vtkm::Id3(1); } + + VTKM_CONT vtkm::Vec3f GetOrigin() const { return this->Origin; } + VTKM_CONT void SetOrigin(const vtkm::Vec3f& origin) { this->Origin = origin; } + + /// \brief The seed used for the pseudorandom number generation of the noise. + /// + /// If the seed is not set, then a new, unique seed is picked each time `Execute` is run. + VTKM_CONT vtkm::IdComponent GetSeed() const { return this->Seed; } + VTKM_CONT void SetSeed(vtkm::IdComponent seed) + { + this->Seed = seed; + this->SeedSet = true; + } private: vtkm::cont::DataSet DoExecute() const override; - vtkm::Id3 Dims; - vtkm::Vec3f Origin; - vtkm::IdComponent Seed; + vtkm::Id3 PointDimensions = { 16, 16, 16 }; + vtkm::Vec3f Origin = { 0, 0, 0 }; + vtkm::IdComponent Seed = 0; + bool SeedSet = false; }; } //namespace source } //namespace vtkm diff --git a/vtkm/source/Tangle.cxx b/vtkm/source/Tangle.cxx index e8b8fdd72..79990ff90 100644 --- a/vtkm/source/Tangle.cxx +++ b/vtkm/source/Tangle.cxx @@ -66,23 +66,25 @@ vtkm::cont::DataSet Tangle::DoExecute() const vtkm::cont::DataSet dataSet; - const vtkm::Id3 pdims{ this->Dims + vtkm::Id3{ 1, 1, 1 } }; const vtkm::Vec3f mins = { -1.0f, -1.0f, -1.0f }; const vtkm::Vec3f maxs = { 1.0f, 1.0f, 1.0f }; vtkm::cont::CellSetStructured<3> cellSet; - cellSet.SetPointDimensions(pdims); + cellSet.SetPointDimensions(this->PointDimensions); dataSet.SetCellSet(cellSet); + vtkm::Id3 cellDims = this->GetCellDimensions(); + vtkm::cont::ArrayHandle pointFieldArray; - this->Invoke(tangle::TangleField{ this->Dims, mins, maxs }, cellSet, pointFieldArray); + this->Invoke(tangle::TangleField{ cellDims, mins, maxs }, cellSet, pointFieldArray); const vtkm::Vec3f origin(0.0f, 0.0f, 0.0f); - const vtkm::Vec3f spacing(1.0f / static_cast(this->Dims[0]), - 1.0f / static_cast(this->Dims[1]), - 1.0f / static_cast(this->Dims[2])); + const vtkm::Vec3f spacing(1.0f / static_cast(cellDims[0]), + 1.0f / static_cast(cellDims[1]), + 1.0f / static_cast(cellDims[2])); - vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(pdims, origin, spacing); + vtkm::cont::ArrayHandleUniformPointCoordinates coordinates( + this->PointDimensions, origin, spacing); dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); dataSet.AddField(vtkm::cont::make_FieldPoint("tangle", pointFieldArray)); diff --git a/vtkm/source/Tangle.h b/vtkm/source/Tangle.h index f4da5448f..d1b154ae9 100644 --- a/vtkm/source/Tangle.h +++ b/vtkm/source/Tangle.h @@ -35,17 +35,25 @@ namespace source class VTKM_SOURCE_EXPORT Tangle final : public vtkm::source::Source { public: - ///Construct a Tangle with Cell Dimensions - VTKM_CONT - Tangle(vtkm::Id3 dims) - : Dims(dims) + VTKM_CONT Tangle() = default; + VTKM_CONT ~Tangle() = default; + + VTKM_DEPRECATED(2.0, "Use SetCellDimensions or SetPointDimensions.") + VTKM_CONT Tangle(vtkm::Id3 dims) + : PointDimensions(dims + vtkm::Id3(1)) { } + VTKM_CONT vtkm::Id3 GetPointDimensions() const { return this->PointDimensions; } + VTKM_CONT void SetPointDimensions(vtkm::Id3 dims) { this->PointDimensions = dims; } + + VTKM_CONT vtkm::Id3 GetCellDimensions() const { return this->PointDimensions - vtkm::Id3(1); } + VTKM_CONT void SetCellDimensions(vtkm::Id3 dims) { this->PointDimensions = dims + vtkm::Id3(1); } + private: vtkm::cont::DataSet DoExecute() const override; - vtkm::Id3 Dims; + vtkm::Id3 PointDimensions = { 16, 16, 16 }; }; } //namespace source } //namespace vtkm diff --git a/vtkm/source/Wavelet.cxx b/vtkm/source/Wavelet.cxx index 393ae01e8..d4abd183c 100644 --- a/vtkm/source/Wavelet.cxx +++ b/vtkm/source/Wavelet.cxx @@ -97,15 +97,8 @@ struct WaveletField : public vtkm::worklet::WorkletVisitPointsWithCells } // namespace wavelet Wavelet::Wavelet(vtkm::Id3 minExtent, vtkm::Id3 maxExtent) - : Center{ minExtent - ((minExtent - maxExtent) / 2) } - , Origin{ minExtent } - , Spacing{ 1. } - , Frequency{ 60., 30., 40. } - , Magnitude{ 10., 18., 5. } - , MinimumExtent{ minExtent } - , MaximumExtent{ maxExtent } - , MaximumValue{ 255. } - , StandardDeviation{ 0.5 } + : MinimumExtent(minExtent) + , MaximumExtent(maxExtent) { } @@ -139,7 +132,7 @@ vtkm::cont::DataSet Wavelet::DoExecute() const // Create points: const vtkm::Id3 dims{ this->MaximumExtent - this->MinimumExtent + vtkm::Id3{ 1 } }; - vtkm::cont::CoordinateSystem coords{ "coordinates", dims, this->Origin, this->Spacing }; + vtkm::cont::CoordinateSystem coords{ "coordinates", dims, this->GetOrigin(), this->Spacing }; // Compile the dataset: if (this->MaximumExtent[2] - this->MinimumExtent[2] < vtkm::Epsilon()) diff --git a/vtkm/source/Wavelet.h b/vtkm/source/Wavelet.h index 824b8f653..faf708638 100644 --- a/vtkm/source/Wavelet.h +++ b/vtkm/source/Wavelet.h @@ -13,6 +13,8 @@ #include +#include + namespace vtkm { namespace source @@ -59,28 +61,54 @@ namespace source class VTKM_SOURCE_EXPORT Wavelet final : public vtkm::source::Source { public: - VTKM_CONT - Wavelet(vtkm::Id3 minExtent = { -10 }, vtkm::Id3 maxExtent = { 10 }); + VTKM_CONT Wavelet() = default; + VTKM_CONT ~Wavelet() = default; - VTKM_CONT void SetCenter(const vtkm::Vec& center) { this->Center = center; } + VTKM_DEPRECATED(2.0, "Use SetExtent.") + VTKM_CONT Wavelet(vtkm::Id3 minExtent, vtkm::Id3 maxExtent = { 10 }); - VTKM_CONT void SetOrigin(const vtkm::Vec& origin) { this->Origin = origin; } + ///@{ + /// \brief Specifies the center of the wavelet function. + /// + /// Note that the center of the function can be anywhere in space including + /// outside the domain of the data created (as specified by the origin, + /// spacing and extent). + VTKM_CONT void SetCenter(const vtkm::Vec3f& center) { this->Center = center; } + VTKM_CONT vtkm::Vec3f GetCenter() const { return this->Center; } + ///@} - VTKM_CONT void SetSpacing(const vtkm::Vec& spacing) { this->Spacing = spacing; } - - VTKM_CONT void SetFrequency(const vtkm::Vec& frequency) + ///@{ + /// \brief Specifies the origin (lower left corner) of the dataset created. + /// + /// If the origin is not specified, it will be placed such that extent + /// index (0, 0, 0) is at the coordinate system origin. + VTKM_CONT void SetOrigin(const vtkm::Vec3f& origin) { this->Origin = origin; } + VTKM_CONT vtkm::Vec3f GetOrigin() const { - this->Frequency = frequency; + if (!vtkm::IsNan(this->Origin[0])) + { + return this->Origin; + } + else + { + return this->MinimumExtent * this->Spacing; + } } - VTKM_CONT void SetMagnitude(const vtkm::Vec& magnitude) - { - this->Magnitude = magnitude; - } + VTKM_CONT void SetSpacing(const vtkm::Vec3f& spacing) { this->Spacing = spacing; } + VTKM_CONT vtkm::Vec3f GetSpacing() const { return this->Spacing; } + + VTKM_CONT void SetFrequency(const vtkm::Vec3f& frequency) { this->Frequency = frequency; } + VTKM_CONT vtkm::Vec3f GetFrequency() const { return this->Frequency; } + + VTKM_CONT void SetMagnitude(const vtkm::Vec3f& magnitude) { this->Magnitude = magnitude; } + VTKM_CONT vtkm::Vec3f GetMagnitude() const { return this->Magnitude; } VTKM_CONT void SetMinimumExtent(const vtkm::Id3& minExtent) { this->MinimumExtent = minExtent; } + VTKM_CONT vtkm::Id3 GetMinimumExtent() const { return this->MinimumExtent; } VTKM_CONT void SetMaximumExtent(const vtkm::Id3& maxExtent) { this->MaximumExtent = maxExtent; } + VTKM_CONT vtkm::Id3 GetMaximumExtent() const { return this->MaximumExtent; } VTKM_CONT void SetExtent(const vtkm::Id3& minExtent, const vtkm::Id3& maxExtent) { @@ -89,11 +117,13 @@ public: } VTKM_CONT void SetMaximumValue(const vtkm::FloatDefault& maxVal) { this->MaximumValue = maxVal; } + VTKM_CONT vtkm::FloatDefault GetMaximumValue() const { return this->MaximumValue; } VTKM_CONT void SetStandardDeviation(const vtkm::FloatDefault& stdev) { this->StandardDeviation = stdev; } + VTKM_CONT vtkm::FloatDefault GetStandardDeviation() const { return this->StandardDeviation; } private: vtkm::cont::DataSet DoExecute() const override; @@ -105,15 +135,15 @@ private: template vtkm::cont::DataSet GenerateDataSet(vtkm::cont::CoordinateSystem coords) const; - vtkm::Vec3f Center; - vtkm::Vec3f Origin; - vtkm::Vec3f Spacing; - vtkm::Vec3f Frequency; - vtkm::Vec3f Magnitude; - vtkm::Id3 MinimumExtent; - vtkm::Id3 MaximumExtent; - vtkm::FloatDefault MaximumValue; - vtkm::FloatDefault StandardDeviation; + vtkm::Vec3f Center = { 0, 0, 0 }; + vtkm::Vec3f Origin = { vtkm::Nan() }; + vtkm::Vec3f Spacing = { 1, 1, 1 }; + vtkm::Vec3f Frequency = { 60.0f, 30.0f, 40.0f }; + vtkm::Vec3f Magnitude = { 10.0f, 18.0f, 5.0f }; + vtkm::Id3 MinimumExtent = { -10, -10, -10 }; + vtkm::Id3 MaximumExtent = { 10, 10, 10 }; + vtkm::FloatDefault MaximumValue = 255.0f; + vtkm::FloatDefault StandardDeviation = 0.5f; }; } //namespace source } //namespace vtkm diff --git a/vtkm/source/testing/RenderTestPerlinNoise.cxx b/vtkm/source/testing/RenderTestPerlinNoise.cxx index 6331d3f85..c48a1acd0 100644 --- a/vtkm/source/testing/RenderTestPerlinNoise.cxx +++ b/vtkm/source/testing/RenderTestPerlinNoise.cxx @@ -24,7 +24,9 @@ namespace void TestPerlinNoise() { - vtkm::source::PerlinNoise noiseSource(vtkm::Id3(16), 77698); + vtkm::source::PerlinNoise noiseSource; + noiseSource.SetCellDimensions(vtkm::Id3(16)); + noiseSource.SetSeed(77698); vtkm::cont::DataSet noise = noiseSource.Execute(); noise.PrintSummary(std::cout); diff --git a/vtkm/source/testing/UnitTestOscillatorSource.cxx b/vtkm/source/testing/UnitTestOscillatorSource.cxx index 5ffb596bb..142888535 100644 --- a/vtkm/source/testing/UnitTestOscillatorSource.cxx +++ b/vtkm/source/testing/UnitTestOscillatorSource.cxx @@ -18,7 +18,8 @@ void OscillatorSourceTest() vtkm::cont::Timer timer; timer.Start(); - vtkm::source::Oscillator source(vtkm::Id3{ 20, 20, 20 }); + vtkm::source::Oscillator source; + source.SetPointDimensions({ 21, 21, 21 }); source.SetTime(0.5); source.AddDamped(0.25f, 0.25f, 0.25f, 0.5f, 0.1f, 0.2f); source.AddDecaying(0.5f, 0.5f, 0.5f, 0.35f, 0.2f, 0.1f); diff --git a/vtkm/source/testing/UnitTestTangleSource.cxx b/vtkm/source/testing/UnitTestTangleSource.cxx index 6e11a83e1..9107a55c5 100644 --- a/vtkm/source/testing/UnitTestTangleSource.cxx +++ b/vtkm/source/testing/UnitTestTangleSource.cxx @@ -18,7 +18,8 @@ void TangleSourceTest() vtkm::cont::Timer timer; timer.Start(); - vtkm::source::Tangle source(vtkm::Id3{ 20, 20, 20 }); + vtkm::source::Tangle source; + source.SetCellDimensions({ 20, 20, 20 }); vtkm::cont::DataSet ds = source.Execute(); diff --git a/vtkm/source/vtkm.module b/vtkm/source/vtkm.module new file mode 100644 index 000000000..033139b0b --- /dev/null +++ b/vtkm/source/vtkm.module @@ -0,0 +1,12 @@ +NAME + vtkm_source +GROUPS + Sources +DEPENDS + vtkm_cont + vtkm_filter_field_conversion + vtkm_filter_multi_block +TEST_DEPENDS + vtkm_filter_contour +TEST_OPTIONAL_DEPENDS + vtkm_rendering_testing diff --git a/vtkm/testing/CMakeLists.txt b/vtkm/testing/CMakeLists.txt index 62104023a..405d9df61 100644 --- a/vtkm/testing/CMakeLists.txt +++ b/vtkm/testing/CMakeLists.txt @@ -8,24 +8,21 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -set(headers - Testing.h - VecTraitsTests.h - ) - -VTKM_declare_headers(${headers}) - if(VTKm_ENABLE_TESTING) set(unit_tests + UnitTestArrayPortalBasic.cxx + UnitTestArrayPortalValueReference.cxx UnitTestBinaryPredicates.cxx UnitTestBinaryOperators.cxx UnitTestBounds.cxx UnitTestCellShape.cxx + UnitTestConfigureFor32.cxx + UnitTestConfigureFor64.cxx UnitTestDeprecated.cxx UnitTestExceptions.cxx + #UnitTestFunctionInterface.cxx #FIXME UnitTestHash.cxx UnitTestList.cxx - UnitTestListTag.cxx UnitTestMatrix.cxx UnitTestNewtonsMethod.cxx UnitTestNoAssert.cxx @@ -35,7 +32,6 @@ if(VTKm_ENABLE_TESTING) UnitTestTransform3D.cxx UnitTestTuple.cxx UnitTestTypeList.cxx - UnitTestTypeListTag.cxx UnitTestTypes.cxx UnitTestTypeTraits.cxx UnitTestUnaryPredicates.cxx @@ -50,7 +46,6 @@ if(VTKm_ENABLE_TESTING) # Unit tests that have device-specific code to be tested set(unit_tests_device - UnitTestAlgorithms.cxx UnitTestAtomic.cxx UnitTestGeometry.cxx UnitTestLowerBound.cxx diff --git a/vtkm/testing/UnitTestAlgorithms.cxx b/vtkm/testing/UnitTestAlgorithms.cxx deleted file mode 100644 index c76402047..000000000 --- a/vtkm/testing/UnitTestAlgorithms.cxx +++ /dev/null @@ -1,91 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include - -VTKM_DEPRECATED_SUPPRESS_BEGIN -#include - -#include -#include - -#include - -#include - -namespace -{ - -using IdArray = vtkm::cont::ArrayHandle; - -struct TestBinarySearch -{ - struct Impl : public vtkm::worklet::WorkletMapField - { - using ControlSignature = void(FieldIn needles, WholeArrayIn haystack, FieldOut results); - using ExecutionSignature = _3(_1, _2); - using InputDomain = _1; - - template - VTKM_EXEC vtkm::Id operator()(vtkm::Id needle, const HaystackPortal& haystack) const - { - return vtkm::BinarySearch(haystack, needle); - } - }; - - static void Run() - { - IdArray needles = vtkm::cont::make_ArrayHandle({ -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 }); - IdArray haystack = - vtkm::cont::make_ArrayHandle({ -3, -2, -2, -2, 0, 0, 1, 1, 1, 4, 4 }); - IdArray results; - - std::vector expectedFound{ - false, true, true, false, true, true, false, false, true, false - }; - - vtkm::cont::Invoker invoke; - invoke(Impl{}, needles, haystack, results); - - // Verify: - auto needlesPortal = needles.ReadPortal(); - auto haystackPortal = haystack.ReadPortal(); - auto resultsPortal = results.ReadPortal(); - for (vtkm::Id i = 0; i < needles.GetNumberOfValues(); ++i) - { - if (expectedFound[static_cast(i)]) - { - const auto resIdx = resultsPortal.Get(i); - const auto expVal = needlesPortal.Get(i); - VTKM_TEST_ASSERT(resIdx >= 0); - VTKM_TEST_ASSERT(haystackPortal.Get(resIdx) == expVal); - } - else - { - VTKM_TEST_ASSERT(resultsPortal.Get(i) == -1); - } - } - } -}; - -void RunAlgorithmsTests() -{ - std::cout << "Testing binary search." << std::endl; - TestBinarySearch::Run(); -} - -} // anon namespace - -VTKM_DEPRECATED_SUPPRESS_END - -int UnitTestAlgorithms(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(RunAlgorithmsTests, argc, argv); -} diff --git a/vtkm/internal/testing/UnitTestArrayPortalBasic.cxx b/vtkm/testing/UnitTestArrayPortalBasic.cxx similarity index 100% rename from vtkm/internal/testing/UnitTestArrayPortalBasic.cxx rename to vtkm/testing/UnitTestArrayPortalBasic.cxx diff --git a/vtkm/internal/testing/UnitTestArrayPortalValueReference.cxx b/vtkm/testing/UnitTestArrayPortalValueReference.cxx similarity index 100% rename from vtkm/internal/testing/UnitTestArrayPortalValueReference.cxx rename to vtkm/testing/UnitTestArrayPortalValueReference.cxx diff --git a/vtkm/internal/testing/UnitTestConfigureFor32.cxx b/vtkm/testing/UnitTestConfigureFor32.cxx similarity index 100% rename from vtkm/internal/testing/UnitTestConfigureFor32.cxx rename to vtkm/testing/UnitTestConfigureFor32.cxx diff --git a/vtkm/internal/testing/UnitTestConfigureFor64.cxx b/vtkm/testing/UnitTestConfigureFor64.cxx similarity index 100% rename from vtkm/internal/testing/UnitTestConfigureFor64.cxx rename to vtkm/testing/UnitTestConfigureFor64.cxx diff --git a/vtkm/internal/testing/UnitTestFunctionInterface.cxx b/vtkm/testing/UnitTestFunctionInterface.cxx similarity index 100% rename from vtkm/internal/testing/UnitTestFunctionInterface.cxx rename to vtkm/testing/UnitTestFunctionInterface.cxx diff --git a/vtkm/testing/UnitTestListTag.cxx b/vtkm/testing/UnitTestListTag.cxx deleted file mode 100644 index d00e9221e..000000000 --- a/vtkm/testing/UnitTestListTag.cxx +++ /dev/null @@ -1,340 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -// ListTag has been depricated. Until it is officially removed, we continue to test it, but -// disable the deprecated warnings while doing so. Once ListTag is officially removed, -// this entire test can be deleted. -#include -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -#include - -#include - -#include -#include - -namespace -{ - -template -struct TestClass -{ -}; - -struct TestListTag1 : vtkm::ListTagBase> -{ -}; -using TestListTagBackward1 = vtkm::List>; - -struct TestListTag2 : vtkm::ListTagBase, TestClass<22>> -{ -}; -using TestListTagBackward2 = vtkm::List, TestClass<22>>; - -struct TestListTag3 : vtkm::ListTagBase, TestClass<32>, TestClass<33>> -{ -}; -using TestListTagBackward3 = vtkm::List, TestClass<32>, TestClass<33>>; - -struct TestListTag4 : vtkm::ListTagBase, TestClass<42>, TestClass<43>, TestClass<44>> -{ -}; -using TestListTagBackward4 = vtkm::List, TestClass<42>, TestClass<43>, TestClass<44>>; - -struct TestListTagJoin : vtkm::ListTagJoin -{ -}; -struct TestListTagJoinBackward : vtkm::ListTagJoin -{ -}; - -struct TestListTagIntersect : vtkm::ListTagIntersect -{ -}; -struct TestListTagIntersectBackward - : vtkm::ListTagIntersect -{ -}; - -struct TestListTagCrossProduct : vtkm::ListCrossProduct -{ -}; -struct TestListTagCrossProductBackward - : vtkm::ListCrossProduct -{ -}; - -struct TestListTagUniversal : vtkm::ListTagUniversal -{ -}; - -struct TestListTagAppend : vtkm::ListTagAppend> -{ -}; -struct TestListTagAppendBackward : vtkm::ListTagAppend> -{ -}; - -struct TestListTagAppendUnique1 : vtkm::ListTagAppendUnique> -{ -}; -struct TestListTagAppendUniqueBackward1 - : vtkm::ListTagAppendUnique> -{ -}; - -struct TestListTagAppendUnique2 : vtkm::ListTagAppendUnique> -{ -}; -struct TestListTagAppendUniqueBackward2 - : vtkm::ListTagAppendUnique> -{ -}; - -template -struct DoubleTransformImpl; -template -struct DoubleTransformImpl> -{ - using type = TestClass<2 * N>; -}; - -template -using DoubleTransform = typename DoubleTransformImpl::type; - -struct TestListTagTransform : vtkm::ListTagTransform -{ -}; -struct TestListTagTransformBackward : vtkm::ListTagTransform -{ -}; - -template -struct EvenPredicate; -template -struct EvenPredicate> : std::integral_constant -{ -}; - -struct TestListTagRemoveIf : vtkm::ListTagRemoveIf -{ -}; -struct TestListTagRemoveIfBackward : vtkm::ListTagRemoveIf -{ -}; - -template -std::pair test_number(vtkm::List, TestClass>) -{ - return std::make_pair(N, M); -} - -template -int test_number(TestClass) -{ - return N; -} - -template -struct MutableFunctor -{ - std::vector FoundTypes; - - template - VTKM_CONT void operator()(U u) - { - this->FoundTypes.push_back(test_number(u)); - } -}; - -template -struct ConstantFunctor -{ - template - VTKM_CONT void operator()(U u, VectorType& vector) const - { - vector.push_back(test_number(u)); - } -}; - -template -void CheckSame(const vtkm::Vec& expected, const std::vector& found) -{ - VTKM_TEST_ASSERT(static_cast(found.size()) == N, "Got wrong number of items."); - - for (vtkm::IdComponent index = 0; index < N; index++) - { - vtkm::UInt32 i = static_cast(index); - VTKM_TEST_ASSERT(expected[index] == found[i], "Got wrong type."); - } -} - -template -void CheckContains(TestClass, ListTag, const std::vector& contents) -{ - bool listContains = vtkm::ListContains>::value; - bool shouldContain = std::find(contents.begin(), contents.end(), N) != contents.end(); - - VTKM_TEST_ASSERT(listContains == shouldContain, "ListContains check failed."); -} - -template -void CheckContains(TestClass, TestListTagUniversal, const std::vector&) -{ - //Use intersect to verify at compile time that ListTag contains TestClass - using intersectWith = vtkm::ListTagBase>; - using intersectResult = vtkm::ListTagIntersect; - constexpr bool intersectContains = (vtkm::ListSize::value != 0); - constexpr bool listContains = vtkm::ListContains>::value; - - VTKM_TEST_ASSERT(intersectContains == listContains, "ListTagIntersect check failed."); -} - -template -void TryList(const vtkm::Vec& expected, ListTag) -{ - VTKM_IS_LIST_TAG(ListTag); - - VTKM_STATIC_ASSERT(vtkm::ListSize::value == N); - - std::cout << " Try mutable for each" << std::endl; - MutableFunctor functor; - vtkm::ListForEach(functor, ListTag()); - CheckSame(expected, functor.FoundTypes); - - std::cout << " Try constant for each" << std::endl; - std::vector foundTypes; - ConstantFunctor cfunc; - vtkm::ListForEach(cfunc, ListTag(), foundTypes); - CheckSame(expected, foundTypes); - - std::cout << " Try checking contents" << std::endl; - CheckContains(TestClass<11>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<21>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<22>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<31>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<32>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<33>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<41>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<42>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<43>(), ListTag(), functor.FoundTypes); - CheckContains(TestClass<44>(), ListTag(), functor.FoundTypes); -} -template -void TryList(const vtkm::Vec, N>& expected, ListTag) -{ - VTKM_IS_LIST_TAG(ListTag); - - std::cout << " Try mutable for each" << std::endl; - MutableFunctor> functor; - vtkm::ListForEach(functor, ListTag()); - CheckSame(expected, functor.FoundTypes); - - std::cout << " Try constant for each" << std::endl; - std::vector> foundTypes; - ConstantFunctor> cfunc; - vtkm::ListForEach(cfunc, ListTag(), foundTypes); - CheckSame(expected, foundTypes); -} - -template -void TryList(const vtkm::Vec&, TestListTagUniversal tag) -{ - VTKM_IS_LIST_TAG(TestListTagUniversal); - - //TestListTagUniversal can't be used with for_each on purpose - - std::vector found; - std::cout << " Try checking contents" << std::endl; - CheckContains(TestClass<11>(), tag, found); - CheckContains(TestClass<21>(), tag, found); - CheckContains(TestClass<22>(), tag, found); - CheckContains(TestClass<31>(), tag, found); - CheckContains(TestClass<32>(), tag, found); - CheckContains(TestClass<33>(), tag, found); - CheckContains(TestClass<41>(), tag, found); - CheckContains(TestClass<42>(), tag, found); - CheckContains(TestClass<43>(), tag, found); - CheckContains(TestClass<44>(), tag, found); -} - -void TestLists() -{ - std::cout << "Valid List Tag Checks" << std::endl; - VTKM_TEST_ASSERT(vtkm::internal::ListTagCheck::value, "Failed list tag check"); - VTKM_TEST_ASSERT(vtkm::internal::ListTagCheck::value, "Failed list tag check"); - VTKM_TEST_ASSERT(!vtkm::internal::ListTagCheck>::value, "Failed list tag check"); - - std::cout << "ListTagEmpty" << std::endl; - TryList(vtkm::Vec(), vtkm::ListTagEmpty()); - - std::cout << "ListTagBase" << std::endl; - TryList(vtkm::Vec(11), TestListTag1()); - - std::cout << "ListTagBase2" << std::endl; - TryList(vtkm::Vec(21, 22), TestListTag2()); - - std::cout << "ListTagBase3" << std::endl; - TryList(vtkm::Vec(31, 32, 33), TestListTag3()); - - std::cout << "ListTagBase4" << std::endl; - TryList(vtkm::Vec(41, 42, 43, 44), TestListTag4()); - - std::cout << "ListTagJoin" << std::endl; - TryList(vtkm::Vec(31, 32, 33, 11), TestListTagJoin()); - TryList(vtkm::Vec(31, 32, 33, 11), TestListTagJoinBackward()); - - std::cout << "ListTagIntersect" << std::endl; - TryList(vtkm::Vec(31, 32, 33), TestListTagIntersect()); - TryList(vtkm::Vec(31, 32, 33), TestListTagIntersectBackward()); - - std::cout << "ListTagCrossProduct" << std::endl; - TryList(vtkm::Vec, 3>({ 31, 11 }, { 32, 11 }, { 33, 11 }), - TestListTagCrossProduct()); - TryList(vtkm::Vec, 3>({ 31, 11 }, { 32, 11 }, { 33, 11 }), - TestListTagCrossProductBackward()); - - std::cout << "ListTagAppend" << std::endl; - TryList(vtkm::Vec(31, 32, 33, 34), TestListTagAppend()); - TryList(vtkm::Vec(31, 32, 33, 34), TestListTagAppendBackward()); - - std::cout << "ListTagAppendUnique1" << std::endl; - TryList(vtkm::Vec(31, 32, 33), TestListTagAppendUnique1()); - TryList(vtkm::Vec(31, 32, 33), TestListTagAppendUniqueBackward1()); - - std::cout << "ListTagAppendUnique2" << std::endl; - TryList(vtkm::Vec(31, 32, 33, 34), TestListTagAppendUnique2()); - TryList(vtkm::Vec(31, 32, 33, 34), TestListTagAppendUniqueBackward2()); - - std::cout << "ListTagTransform" << std::endl; - TryList(vtkm::Vec(82, 84, 86, 88), TestListTagTransform()); - TryList(vtkm::Vec(82, 84, 86, 88), TestListTagTransformBackward()); - - std::cout << "ListTagRemoveIf" << std::endl; - TryList(vtkm::Vec(41, 43), TestListTagRemoveIf()); - TryList(vtkm::Vec(41, 43), TestListTagRemoveIfBackward()); - - - - std::cout << "ListTagUniversal" << std::endl; - TryList(vtkm::Vec(1, 2, 3, 4), TestListTagUniversal()); -} - -} // anonymous namespace - -int UnitTestListTag(int argc, char* argv[]) -{ - return vtkm::testing::Testing::Run(TestLists, argc, argv); -} - -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/testing/UnitTestTypeListTag.cxx b/vtkm/testing/UnitTestTypeListTag.cxx deleted file mode 100644 index d332a5b0d..000000000 --- a/vtkm/testing/UnitTestTypeListTag.cxx +++ /dev/null @@ -1,305 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -// This tests deprecated code until it is deleted. -#include - -VTKM_DEPRECATED_SUPPRESS_BEGIN - -#include - -#include - -#include - -#include -#include - -namespace -{ - -class TypeSet -{ - using NameSetType = std::set; - NameSetType NameSet; - -public: - template - void AddExpected(T) - { - this->NameSet.insert(vtkm::testing::TypeName::Name()); - } - - template - void Found(T) - { - std::string name = vtkm::testing::TypeName::Name(); - //std::cout << " found " << name << std::endl; - NameSetType::iterator typeLocation = this->NameSet.find(name); - if (typeLocation != this->NameSet.end()) - { - // This type is expected. Remove it to mark it found. - this->NameSet.erase(typeLocation); - } - else - { - std::cout << "**** Did not expect to get type " << name << std::endl; - VTKM_TEST_FAIL("Got unexpected type."); - } - } - - void CheckFound() - { - for (NameSetType::iterator typeP = this->NameSet.begin(); typeP != this->NameSet.end(); typeP++) - { - std::cout << "**** Failed to find " << *typeP << std::endl; - } - VTKM_TEST_ASSERT(this->NameSet.empty(), "List did not call functor on all expected types."); - } -}; - -struct TestFunctor -{ - TypeSet ExpectedTypes; - - TestFunctor(const TypeSet& expectedTypes) - : ExpectedTypes(expectedTypes) - { - } - - template - VTKM_CONT void operator()(T) - { - this->ExpectedTypes.Found(T()); - } -}; - -template -void TryList(const TypeSet& expected, ListTag) -{ - TestFunctor functor(expected); - vtkm::ListForEach(functor, ListTag()); - functor.ExpectedTypes.CheckFound(); -} - -void TestLists() -{ - std::cout << "TypeListTagId" << std::endl; - TypeSet id; - id.AddExpected(vtkm::Id()); - TryList(id, vtkm::TypeListTagId()); - - std::cout << "TypeListTagId2" << std::endl; - TypeSet id2; - id2.AddExpected(vtkm::Id2()); - TryList(id2, vtkm::TypeListTagId2()); - - std::cout << "TypeListTagId3" << std::endl; - TypeSet id3; - id3.AddExpected(vtkm::Id3()); - TryList(id3, vtkm::TypeListTagId3()); - - std::cout << "TypeListTagIndex" << std::endl; - TypeSet index; - index.AddExpected(vtkm::Id()); - index.AddExpected(vtkm::Id2()); - index.AddExpected(vtkm::Id3()); - TryList(index, vtkm::TypeListTagIndex()); - - std::cout << "TypeListTagFieldScalar" << std::endl; - TypeSet scalar; - scalar.AddExpected(vtkm::Float32()); - scalar.AddExpected(vtkm::Float64()); - TryList(scalar, vtkm::TypeListTagFieldScalar()); - - std::cout << "TypeListTagFieldVec2" << std::endl; - TypeSet vec2; - vec2.AddExpected(vtkm::Vec2f_32()); - vec2.AddExpected(vtkm::Vec2f_64()); - TryList(vec2, vtkm::TypeListTagFieldVec2()); - - std::cout << "TypeListTagFieldVec3" << std::endl; - TypeSet vec3; - vec3.AddExpected(vtkm::Vec3f_32()); - vec3.AddExpected(vtkm::Vec3f_64()); - TryList(vec3, vtkm::TypeListTagFieldVec3()); - - std::cout << "TypeListTagFieldVec4" << std::endl; - TypeSet vec4; - vec4.AddExpected(vtkm::Vec4f_32()); - vec4.AddExpected(vtkm::Vec4f_64()); - TryList(vec4, vtkm::TypeListTagFieldVec4()); - - std::cout << "TypeListTagField" << std::endl; - TypeSet field; - field.AddExpected(vtkm::Float32()); - field.AddExpected(vtkm::Float64()); - field.AddExpected(vtkm::Vec2f_32()); - field.AddExpected(vtkm::Vec2f_64()); - field.AddExpected(vtkm::Vec3f_32()); - field.AddExpected(vtkm::Vec3f_64()); - field.AddExpected(vtkm::Vec4f_32()); - field.AddExpected(vtkm::Vec4f_64()); - TryList(field, vtkm::TypeListTagField()); - - std::cout << "TypeListTagCommon" << std::endl; - TypeSet common; - common.AddExpected(vtkm::Float32()); - common.AddExpected(vtkm::Float64()); - common.AddExpected(vtkm::UInt8()); - common.AddExpected(vtkm::Int32()); - common.AddExpected(vtkm::Int64()); - common.AddExpected(vtkm::Vec3f_32()); - common.AddExpected(vtkm::Vec3f_64()); - TryList(common, vtkm::TypeListTagCommon()); - - std::cout << "TypeListTagScalarAll" << std::endl; - TypeSet scalarsAll; - scalarsAll.AddExpected(vtkm::Float32()); - scalarsAll.AddExpected(vtkm::Float64()); - scalarsAll.AddExpected(vtkm::Int8()); - scalarsAll.AddExpected(vtkm::UInt8()); - scalarsAll.AddExpected(vtkm::Int16()); - scalarsAll.AddExpected(vtkm::UInt16()); - scalarsAll.AddExpected(vtkm::Int32()); - scalarsAll.AddExpected(vtkm::UInt32()); - scalarsAll.AddExpected(vtkm::Int64()); - scalarsAll.AddExpected(vtkm::UInt64()); - TryList(scalarsAll, vtkm::TypeListTagScalarAll()); - - std::cout << "TypeListBaseC" << std::endl; - TypeSet baseC; - baseC.AddExpected(vtkm::Float32()); - baseC.AddExpected(vtkm::Float64()); - baseC.AddExpected(vtkm::Int8()); - baseC.AddExpected(vtkm::UInt8()); - baseC.AddExpected(vtkm::Int16()); - baseC.AddExpected(vtkm::UInt16()); - baseC.AddExpected(vtkm::Int32()); - baseC.AddExpected(vtkm::UInt32()); - baseC.AddExpected(vtkm::Int64()); - baseC.AddExpected(vtkm::UInt64()); - // Extra types with same layout as above but considered different by C - baseC.AddExpected(bool()); - baseC.AddExpected(char()); - baseC.AddExpected((signed int)0); - baseC.AddExpected((unsigned int)0); - baseC.AddExpected((signed long)0); - baseC.AddExpected((unsigned long)0); - baseC.AddExpected((signed long long)0); - baseC.AddExpected((unsigned long long)0); - TryList(baseC, vtkm::TypeListBaseC()); - - std::cout << "TypeListTagVecCommon" << std::endl; - TypeSet vecCommon; - vecCommon.AddExpected(vtkm::Vec2f_32()); - vecCommon.AddExpected(vtkm::Vec2f_64()); - vecCommon.AddExpected(vtkm::Vec2ui_8()); - vecCommon.AddExpected(vtkm::Vec2i_32()); - vecCommon.AddExpected(vtkm::Vec2i_64()); - vecCommon.AddExpected(vtkm::Vec3f_32()); - vecCommon.AddExpected(vtkm::Vec3f_64()); - vecCommon.AddExpected(vtkm::Vec3ui_8()); - vecCommon.AddExpected(vtkm::Vec3i_32()); - vecCommon.AddExpected(vtkm::Vec3i_64()); - vecCommon.AddExpected(vtkm::Vec4f_32()); - vecCommon.AddExpected(vtkm::Vec4f_64()); - vecCommon.AddExpected(vtkm::Vec4ui_8()); - vecCommon.AddExpected(vtkm::Vec4i_32()); - vecCommon.AddExpected(vtkm::Vec4i_64()); - TryList(vecCommon, vtkm::TypeListTagVecCommon()); - - std::cout << "TypeListTagVecAll" << std::endl; - TypeSet vecAll; - vecAll.AddExpected(vtkm::Vec2f_32()); - vecAll.AddExpected(vtkm::Vec2f_64()); - vecAll.AddExpected(vtkm::Vec2i_8()); - vecAll.AddExpected(vtkm::Vec2i_16()); - vecAll.AddExpected(vtkm::Vec2i_32()); - vecAll.AddExpected(vtkm::Vec2i_64()); - vecAll.AddExpected(vtkm::Vec2ui_8()); - vecAll.AddExpected(vtkm::Vec2ui_16()); - vecAll.AddExpected(vtkm::Vec2ui_32()); - vecAll.AddExpected(vtkm::Vec2ui_64()); - vecAll.AddExpected(vtkm::Vec3f_32()); - vecAll.AddExpected(vtkm::Vec3f_64()); - vecAll.AddExpected(vtkm::Vec3i_8()); - vecAll.AddExpected(vtkm::Vec3i_16()); - vecAll.AddExpected(vtkm::Vec3i_32()); - vecAll.AddExpected(vtkm::Vec3i_64()); - vecAll.AddExpected(vtkm::Vec3ui_8()); - vecAll.AddExpected(vtkm::Vec3ui_16()); - vecAll.AddExpected(vtkm::Vec3ui_32()); - vecAll.AddExpected(vtkm::Vec3ui_64()); - vecAll.AddExpected(vtkm::Vec4f_32()); - vecAll.AddExpected(vtkm::Vec4f_64()); - vecAll.AddExpected(vtkm::Vec4i_8()); - vecAll.AddExpected(vtkm::Vec4i_16()); - vecAll.AddExpected(vtkm::Vec4i_32()); - vecAll.AddExpected(vtkm::Vec4i_64()); - vecAll.AddExpected(vtkm::Vec4ui_8()); - vecAll.AddExpected(vtkm::Vec4ui_16()); - vecAll.AddExpected(vtkm::Vec4ui_32()); - vecAll.AddExpected(vtkm::Vec4ui_64()); - TryList(vecAll, vtkm::TypeListTagVecAll()); - - std::cout << "TypeListTagAll" << std::endl; - TypeSet all; - all.AddExpected(vtkm::Float32()); - all.AddExpected(vtkm::Float64()); - all.AddExpected(vtkm::Int8()); - all.AddExpected(vtkm::UInt8()); - all.AddExpected(vtkm::Int16()); - all.AddExpected(vtkm::UInt16()); - all.AddExpected(vtkm::Int32()); - all.AddExpected(vtkm::UInt32()); - all.AddExpected(vtkm::Int64()); - all.AddExpected(vtkm::UInt64()); - all.AddExpected(vtkm::Vec2f_32()); - all.AddExpected(vtkm::Vec2f_64()); - all.AddExpected(vtkm::Vec2i_8()); - all.AddExpected(vtkm::Vec2i_16()); - all.AddExpected(vtkm::Vec2i_32()); - all.AddExpected(vtkm::Vec2i_64()); - all.AddExpected(vtkm::Vec2ui_8()); - all.AddExpected(vtkm::Vec2ui_16()); - all.AddExpected(vtkm::Vec2ui_32()); - all.AddExpected(vtkm::Vec2ui_64()); - all.AddExpected(vtkm::Vec3f_32()); - all.AddExpected(vtkm::Vec3f_64()); - all.AddExpected(vtkm::Vec3i_8()); - all.AddExpected(vtkm::Vec3i_16()); - all.AddExpected(vtkm::Vec3i_32()); - all.AddExpected(vtkm::Vec3i_64()); - all.AddExpected(vtkm::Vec3ui_8()); - all.AddExpected(vtkm::Vec3ui_16()); - all.AddExpected(vtkm::Vec3ui_32()); - all.AddExpected(vtkm::Vec3ui_64()); - all.AddExpected(vtkm::Vec4f_32()); - all.AddExpected(vtkm::Vec4f_64()); - all.AddExpected(vtkm::Vec4i_8()); - all.AddExpected(vtkm::Vec4i_16()); - all.AddExpected(vtkm::Vec4i_32()); - all.AddExpected(vtkm::Vec4i_64()); - all.AddExpected(vtkm::Vec4ui_8()); - all.AddExpected(vtkm::Vec4ui_16()); - all.AddExpected(vtkm::Vec4ui_32()); - all.AddExpected(vtkm::Vec4ui_64()); - TryList(all, vtkm::TypeListTagAll()); -} - -} // anonymous namespace - -int UnitTestTypeListTag(int argc, char* argv[]) -{ - return vtkm::testing::Testing::Run(TestLists, argc, argv); -} - -VTKM_DEPRECATED_SUPPRESS_END diff --git a/vtkm/thirdparty/diy/CMakeLists.txt b/vtkm/thirdparty/diy/CMakeLists.txt index 2e273ecd9..610548e5f 100644 --- a/vtkm/thirdparty/diy/CMakeLists.txt +++ b/vtkm/thirdparty/diy/CMakeLists.txt @@ -58,7 +58,11 @@ set(VTKM_USE_EXTERNAL_DIY OFF) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in ${VTKm_BINARY_INCLUDE_DIR}/${kit_dir}/Configure.h) -function(vtkm_diy_set_target_output_directory target) +function(vtkm_diy_set_target_properties target) + if (NOT VTKm_SKIP_LIBRARY_VERSIONS) + set_property(TARGET ${target} PROPERTY VERSION ${VTKm_VERSION}.${VTKm_VERSION_PATCH}) + set_property(TARGET ${target} PROPERTY SOVERSION ${VTKm_VERSION}) + endif() set_property(TARGET ${target} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}) set_property(TARGET ${target} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}) set_property(TARGET ${target} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}) @@ -69,15 +73,16 @@ add_subdirectory(vtkmdiy) # move diy libraries if (TARGET vtkmdiympi) - vtkm_diy_set_target_output_directory(vtkmdiympi) + vtkm_diy_set_target_properties(vtkmdiympi) endif() if (TARGET vtkmdiympi_nompi) - vtkm_diy_set_target_output_directory(vtkmdiympi_nompi) + vtkm_diy_set_target_properties(vtkmdiympi_nompi) endif() include(VTKmDIYUtils) add_library(vtkm_diy INTERFACE) + vtkm_diy_init_target() target_include_directories(vtkm_diy INTERFACE $ @@ -109,7 +114,7 @@ else() endif() #----------------------------------------------------------------------------- -install(TARGETS vtkm_diy EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_diy) ## Install headers if (NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/thirdparty/diy/vtkm.module b/vtkm/thirdparty/diy/vtkm.module new file mode 100644 index 000000000..e4e721dc5 --- /dev/null +++ b/vtkm/thirdparty/diy/vtkm.module @@ -0,0 +1,3 @@ +NAME + vtkm_diy +NO_TESTING diff --git a/vtkm/thirdparty/lcl/CMakeLists.txt b/vtkm/thirdparty/lcl/CMakeLists.txt index bbfe16784..df45b77ee 100644 --- a/vtkm/thirdparty/lcl/CMakeLists.txt +++ b/vtkm/thirdparty/lcl/CMakeLists.txt @@ -18,8 +18,7 @@ target_include_directories(vtkm_lcl INTERFACE $ $) -install(TARGETS vtkm_lcl - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_lcl) ## Install headers if(NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/thirdparty/lcl/vtkm.module b/vtkm/thirdparty/lcl/vtkm.module new file mode 100644 index 000000000..db90bd98f --- /dev/null +++ b/vtkm/thirdparty/lcl/vtkm.module @@ -0,0 +1,3 @@ +NAME + vtkm_lcl +NO_TESTING diff --git a/vtkm/thirdparty/lodepng/CMakeLists.txt b/vtkm/thirdparty/lodepng/CMakeLists.txt index 3db33f6d6..a4b8c29c7 100644 --- a/vtkm/thirdparty/lodepng/CMakeLists.txt +++ b/vtkm/thirdparty/lodepng/CMakeLists.txt @@ -15,4 +15,4 @@ set_target_properties(vtkm_lodepng PROPERTIES POSITION_INDEPENDENT_CODE ON) # This will not install anything but it is needed for CMake <= 3.21 since it # does not fully support $ in target_link_library. -install(TARGETS vtkm_lodepng EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_lodepng) diff --git a/vtkm/thirdparty/lodepng/vtkm.module b/vtkm/thirdparty/lodepng/vtkm.module new file mode 100644 index 000000000..b2fcbdf3b --- /dev/null +++ b/vtkm/thirdparty/lodepng/vtkm.module @@ -0,0 +1,3 @@ +NAME + vtkm_lodepng +NO_TESTING diff --git a/vtkm/thirdparty/loguru/CMakeLists.txt b/vtkm/thirdparty/loguru/CMakeLists.txt index 0b996afc9..e75b2a7e1 100644 --- a/vtkm/thirdparty/loguru/CMakeLists.txt +++ b/vtkm/thirdparty/loguru/CMakeLists.txt @@ -20,5 +20,4 @@ target_include_directories(vtkm_loguru INTERFACE target_link_libraries(vtkm_loguru INTERFACE ${CMAKE_DL_LIBS} Threads::Threads) -install(TARGETS vtkm_loguru - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_loguru) diff --git a/vtkm/thirdparty/loguru/vtkm.module b/vtkm/thirdparty/loguru/vtkm.module new file mode 100644 index 000000000..ca163688c --- /dev/null +++ b/vtkm/thirdparty/loguru/vtkm.module @@ -0,0 +1,5 @@ +NAME + vtkm_loguru +GROUPS + Logging +NO_TESTING diff --git a/vtkm/thirdparty/optionparser/CMakeLists.txt b/vtkm/thirdparty/optionparser/CMakeLists.txt index 668cf867e..8037c9adb 100644 --- a/vtkm/thirdparty/optionparser/CMakeLists.txt +++ b/vtkm/thirdparty/optionparser/CMakeLists.txt @@ -15,8 +15,7 @@ target_include_directories(vtkm_optionparser INTERFACE $ $) -install(TARGETS vtkm_optionparser - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_optionparser) ## Install headers if(NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/thirdparty/optionparser/vtkm.module b/vtkm/thirdparty/optionparser/vtkm.module new file mode 100644 index 000000000..b49d8ffaa --- /dev/null +++ b/vtkm/thirdparty/optionparser/vtkm.module @@ -0,0 +1,3 @@ +NAME + vtkm_optionparser +NO_TESTING diff --git a/vtkm/vtkm.module b/vtkm/vtkm.module new file mode 100644 index 000000000..58ad2bbc9 --- /dev/null +++ b/vtkm/vtkm.module @@ -0,0 +1,4 @@ +NAME + vtkm +GROUPS + Core diff --git a/vtkm/worklet/CMakeLists.txt b/vtkm/worklet/CMakeLists.txt index 05508a6a5..a82f03083 100644 --- a/vtkm/worklet/CMakeLists.txt +++ b/vtkm/worklet/CMakeLists.txt @@ -20,7 +20,6 @@ set(headers DispatcherPointNeighborhood.h DispatcherReduceByKey.h FieldStatistics.h - KdTree3D.h # Deprecated KernelSplatter.h Keys.h MaskIndices.h @@ -84,11 +83,5 @@ vtkm_library( DEVICE_SOURCES ${sources_device} USE_VTKM_JOB_POOL ) -target_link_libraries(vtkm_worklet PUBLIC vtkm_cont) set_source_files_properties(${sources_device} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) - -#----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/worklet/CellDeepCopy.h b/vtkm/worklet/CellDeepCopy.h index b3741f067..39e8460c6 100644 --- a/vtkm/worklet/CellDeepCopy.h +++ b/vtkm/worklet/CellDeepCopy.h @@ -67,7 +67,8 @@ struct CellDeepCopy typename OffsetsStorage> VTKM_CONT static void Run( const InCellSetType& inCellSet, - vtkm::cont::CellSetExplicit& outCellSet) + vtkm::cont::CellSetExplicit& outCellSet, + vtkm::Id numberOfPoints) { VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(InCellSetType); @@ -89,10 +90,21 @@ struct CellDeepCopy inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets)); vtkm::cont::CellSetExplicit newCellSet; - newCellSet.Fill(inCellSet.GetNumberOfPoints(), shapes, connectivity, offsets); + newCellSet.Fill(numberOfPoints, shapes, connectivity, offsets); outCellSet = newCellSet; } + template + VTKM_CONT static void Run( + const InCellSetType& inCellSet, + vtkm::cont::CellSetExplicit& outCellSet) + { + Run(inCellSet, outCellSet, inCellSet.GetNumberOfPoints()); + } + template VTKM_CONT static vtkm::cont::CellSetExplicit<> Run(const InCellSetType& inCellSet) { diff --git a/vtkm/worklet/KdTree3D.h b/vtkm/worklet/KdTree3D.h deleted file mode 100644 index e43f065dd..000000000 --- a/vtkm/worklet/KdTree3D.h +++ /dev/null @@ -1,77 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtkm_m_worklet_KdTree3D_h -#define vtkm_m_worklet_KdTree3D_h - -#include -#include - -namespace vtkm -{ -namespace worklet -{ - -class VTKM_DEPRECATED(1.7, - "K-D tree recursive searches are not well supported on GPU devices.") KdTree3D -{ -public: - KdTree3D() = default; - - /// \brief Construct a 3D KD-tree for 3D point positions. - /// - /// \tparam CoordType type of the x, y, z component of the point coordinates. - /// \tparam CoordStorageTag - /// \param coords An ArrayHandle of x, y, z coordinates of input points. - /// - template - void Build(const vtkm::cont::ArrayHandle, CoordStorageTag>& coords) - { - vtkm::worklet::spatialstructure::KdTree3DConstruction().Run( - coords, this->PointIds, this->SplitIds); - } - - /// \brief Nearest neighbor search using KD-Tree - /// - /// Parallel search of nearest neighbor for each point in the \c queryPoints in the the set of - /// \c coords. Returns nearest neighbor in \c nearestNeighborId and distance to nearest neighbor - /// in \c distances. - /// - /// \tparam CoordType - /// \tparam CoordStorageTag1 - /// \tparam CoordStorageTag2 - /// \tparam DeviceAdapter - /// \param coords Point coordinates for training data set (haystack) - /// \param queryPoints Point coordinates to query for nearest neighbor (needles). - /// \param nearestNeighborIds Nearest neighbor in the traning data set for each points in the - /// testing set - /// \param distances Distances between query points and their nearest neighbors. - /// \param deviceId Tag for selecting device adapter. - template - void Run(const vtkm::cont::ArrayHandle, CoordStorageTag1>& coords, - const vtkm::cont::ArrayHandle, CoordStorageTag2>& queryPoints, - vtkm::cont::ArrayHandle& nearestNeighborIds, - vtkm::cont::ArrayHandle& distances, - DeviceAdapter deviceId) - { - vtkm::worklet::spatialstructure::KdTree3DNNSearch().Run( - coords, this->PointIds, this->SplitIds, queryPoints, nearestNeighborIds, distances, deviceId); - } - -private: - vtkm::cont::ArrayHandle PointIds; - vtkm::cont::ArrayHandle SplitIds; -}; -} -} // namespace vtkm::worklet - -#endif // vtkm_m_worklet_Kdtree3D_h diff --git a/vtkm/worklet/Keys.h b/vtkm/worklet/Keys.h index 5cc0a61a7..e19562065 100644 --- a/vtkm/worklet/Keys.h +++ b/vtkm/worklet/Keys.h @@ -70,12 +70,6 @@ public: typename vtkm::cont::ArrayHandle::ReadPortalType, typename vtkm::cont::ArrayHandle::ReadPortalType>; - template - struct VTKM_DEPRECATED(1.6, "Replace ExecutionTypes::Lookup with ExecLookup.") ExecutionTypes - { - using Lookup = ExecLookup; - }; - VTKM_CONT ExecLookup PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const { @@ -84,14 +78,6 @@ public: this->Counts.PrepareForInput(device, token)); } - VTKM_CONT VTKM_DEPRECATED(1.6, - "PrepareForInput now requires a vtkm::cont::Token object.") ExecLookup - PrepareForInput(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, token); - } - VTKM_CONT bool operator==(const vtkm::worklet::internal::KeysBase& other) const { @@ -193,12 +179,6 @@ public: typename vtkm::cont::ArrayHandle::ReadPortalType, typename vtkm::cont::ArrayHandle::ReadPortalType>; - template - struct VTKM_DEPRECATED(1.6, "Replace ExecutionTypes::Lookup with ExecLookup.") ExecutionTypes - { - using Lookup = ExecLookup; - }; - VTKM_CONT ExecLookup PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const { @@ -208,14 +188,6 @@ public: this->Counts.PrepareForInput(device, token)); } - VTKM_CONT VTKM_DEPRECATED(1.6, - "PrepareForInput now requires a vtkm::cont::Token object.") ExecLookup - PrepareForInput(vtkm::cont::DeviceAdapterId device) const - { - vtkm::cont::Token token; - return this->PrepareForInput(device, token); - } - VTKM_CONT bool operator==(const vtkm::worklet::Keys& other) const { diff --git a/vtkm/worklet/WorkletMapTopology.h b/vtkm/worklet/WorkletMapTopology.h index 785c25a8b..1d2c7a244 100644 --- a/vtkm/worklet/WorkletMapTopology.h +++ b/vtkm/worklet/WorkletMapTopology.h @@ -288,12 +288,6 @@ public: using CellIndices = IncidentElementIndices; }; -// Deprecated signatures for legacy support. These will be removed at some -// point. -using WorkletMapCellToPoint VTKM_DEPRECATED(1.5, "Use WorkletVisitPointsWithCells.") = - WorkletVisitPointsWithCells; -using WorkletMapPointToCell VTKM_DEPRECATED(1.5, "Use WorkletVisitCellsWithPoints.") = - WorkletVisitCellsWithPoints; } } // namespace vtkm::worklet diff --git a/vtkm/worklet/internal/CMakeLists.txt b/vtkm/worklet/internal/CMakeLists.txt index 7ca14a166..fbc24c06d 100644 --- a/vtkm/worklet/internal/CMakeLists.txt +++ b/vtkm/worklet/internal/CMakeLists.txt @@ -18,7 +18,3 @@ set(headers ) vtkm_declare_headers(${headers}) - -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () diff --git a/vtkm/worklet/internal/testing/CMakeLists.txt b/vtkm/worklet/internal/testing/CMakeLists.txt deleted file mode 100644 index c4a8c70bf..000000000 --- a/vtkm/worklet/internal/testing/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -##============================================================================ -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -##============================================================================ - -set(unit_tests - UnitTestDispatcherBase.cxx - ) - -vtkm_unit_tests(DEVICE_SOURCES ${unit_tests}) diff --git a/vtkm/worklet/spatialstructure/BoundingIntervalHierarchy.h b/vtkm/worklet/spatialstructure/BoundingIntervalHierarchy.h index 167c7c810..3ab0821a7 100644 --- a/vtkm/worklet/spatialstructure/BoundingIntervalHierarchy.h +++ b/vtkm/worklet/spatialstructure/BoundingIntervalHierarchy.h @@ -281,7 +281,7 @@ public: choice = 1; using Split = SplitProperties; vtkm::FloatDefault minCost = vtkm::Infinity(); - const Split& xSplit = xSplits[ArgMin(xSplits, index * Stride, Stride)]; + const Split& xSplit = xSplits.Get(ArgMin(xSplits, index * Stride, Stride)); bool found = false; if (xSplit.Cost < minCost && xSplit.NumLeftPoints != 0 && xSplit.NumRightPoints != 0) { @@ -292,7 +292,7 @@ public: plane = xSplit.Plane; found = true; } - const Split& ySplit = ySplits[ArgMin(ySplits, index * Stride, Stride)]; + const Split& ySplit = ySplits.Get(ArgMin(ySplits, index * Stride, Stride)); if (ySplit.Cost < minCost && ySplit.NumLeftPoints != 0 && ySplit.NumRightPoints != 0) { minCost = ySplit.Cost; @@ -302,7 +302,7 @@ public: plane = ySplit.Plane; found = true; } - const Split& zSplit = zSplits[ArgMin(zSplits, index * Stride, Stride)]; + const Split& zSplit = zSplits.Get(ArgMin(zSplits, index * Stride, Stride)); if (zSplit.Cost < minCost && zSplit.NumLeftPoints != 0 && zSplit.NumRightPoints != 0) { minCost = zSplit.Cost; @@ -314,13 +314,13 @@ public: } if (!found) { - const Split& xMSplit = xSplits[NumPlanes]; + const Split& xMSplit = xSplits.Get(NumPlanes); minCost = xMSplit.Cost; node.Dimension = 0; node.LMax = xMSplit.LMax; node.RMin = xMSplit.RMin; plane = xMSplit.Plane; - const Split& yMSplit = ySplits[NumPlanes]; + const Split& yMSplit = ySplits.Get(NumPlanes); if (yMSplit.Cost < minCost && yMSplit.NumLeftPoints != 0 && yMSplit.NumRightPoints != 0) { minCost = yMSplit.Cost; @@ -329,7 +329,7 @@ public: node.RMin = yMSplit.RMin; plane = yMSplit.Plane; } - const Split& zMSplit = zSplits[NumPlanes]; + const Split& zMSplit = zSplits.Get(NumPlanes); if (zMSplit.Cost < minCost && zMSplit.NumLeftPoints != 0 && zMSplit.NumRightPoints != 0) { minCost = zMSplit.Cost; @@ -348,7 +348,7 @@ public: vtkm::Id minIdx = start; for (vtkm::Id i = start; i < (start + length); ++i) { - if (values[i].Cost < values[minIdx].Cost) + if (values.Get(i).Cost < values.Get(minIdx).Cost) { minIdx = i; } diff --git a/vtkm/worklet/spatialstructure/CMakeLists.txt b/vtkm/worklet/spatialstructure/CMakeLists.txt index fa96283cf..9ae236f4b 100644 --- a/vtkm/worklet/spatialstructure/CMakeLists.txt +++ b/vtkm/worklet/spatialstructure/CMakeLists.txt @@ -10,8 +10,6 @@ set(headers BoundingIntervalHierarchy.h - KdTree3DConstruction.h # Deprecated - KdTree3DNNSearch.h # Deprecated ) vtkm_declare_headers(${headers}) diff --git a/vtkm/worklet/spatialstructure/KdTree3DConstruction.h b/vtkm/worklet/spatialstructure/KdTree3DConstruction.h deleted file mode 100644 index b6cd0c793..000000000 --- a/vtkm/worklet/spatialstructure/KdTree3DConstruction.h +++ /dev/null @@ -1,601 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_worklet_KdTree3DConstruction_h -#define vtk_m_worklet_KdTree3DConstruction_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace vtkm -{ -namespace worklet -{ -namespace spatialstructure -{ - -class VTKM_DEPRECATED(1.7, "K-D tree recursive searches are not well supported on GPU devices.") - KdTree3DConstruction -{ -public: - ////////// General WORKLET for Kd-tree ////// - class ComputeFlag : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn rank, FieldIn pointCountInSeg, FieldOut flag); - using ExecutionSignature = void(_1, _2, _3); - - VTKM_CONT - ComputeFlag() {} - - template - VTKM_EXEC void operator()(const T& rank, const T& pointCountInSeg, T& flag) const - { - if (static_cast(rank) >= static_cast(pointCountInSeg) / 2.0f) - flag = 1; //right subtree - else - flag = 0; //left subtree - } - }; - - class InverseArray : public vtkm::worklet::WorkletMapField - { //only for 0/1 array - public: - using ControlSignature = void(FieldIn in, FieldOut out); - using ExecutionSignature = void(_1, _2); - - VTKM_CONT - InverseArray() {} - - template - VTKM_EXEC void operator()(const T& in, T& out) const - { - if (in == 0) - out = 1; - else - out = 0; - } - }; - - class SegmentedSplitTransform : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = - void(FieldIn B, FieldIn D, FieldIn F, FieldIn G, FieldIn H, FieldOut I); - using ExecutionSignature = void(_1, _2, _3, _4, _5, _6); - - VTKM_CONT - SegmentedSplitTransform() {} - - template - VTKM_EXEC void operator()(const T& B, const T& D, const T& F, const T& G, const T& H, T& I) - const - { - if (B == 1) - { - I = F + H + D; - } - else - { - I = F + G - 1; - } - } - }; - - class ScatterArray : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn in, FieldIn index, WholeArrayOut out); - using ExecutionSignature = void(_1, _2, _3); - - VTKM_CONT - ScatterArray() {} - - template - VTKM_EXEC void operator()(const T& in, - const T& index, - const OutputArrayPortalType& outputPortal) const - { - outputPortal.Set(index, in); - } - }; - - class NewSegmentId : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn inSegmentId, FieldIn flag, FieldOut outSegmentId); - using ExecutionSignature = void(_1, _2, _3); - - VTKM_CONT - NewSegmentId() {} - - template - VTKM_EXEC void operator()(const T& oldSegId, const T& flag, T& newSegId) const - { - if (flag == 0) - newSegId = oldSegId * 2; - else - newSegId = oldSegId * 2 + 1; - } - }; - - class SaveSplitPointId : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn pointId, - FieldIn flag, - FieldIn oldSplitPointId, - FieldOut newSplitPointId); - using ExecutionSignature = void(_1, _2, _3, _4); - - VTKM_CONT - SaveSplitPointId() {} - - template - VTKM_EXEC void operator()(const T& pointId, - const T& flag, - const T& oldSplitPointId, - T& newSplitPointId) const - { - if (flag == 0) //do not change - newSplitPointId = oldSplitPointId; - else //split point id - newSplitPointId = pointId; - } - }; - - class FindSplitPointId : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn pointId, FieldIn rank, FieldOut splitIdInsegment); - using ExecutionSignature = void(_1, _2, _3); - - VTKM_CONT - FindSplitPointId() {} - - template - VTKM_EXEC void operator()(const T& pointId, const T& rank, T& splitIdInsegment) const - { - if (rank == 0) //do not change - splitIdInsegment = pointId; - else //split point id - splitIdInsegment = -1; //indicate this is not split point - } - }; - - class ArrayAdd : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn inArray0, FieldIn inArray1, FieldOut outArray); - using ExecutionSignature = void(_1, _2, _3); - - VTKM_CONT - ArrayAdd() {} - - template - VTKM_EXEC void operator()(const T& in0, const T& in1, T& out) const - { - out = in0 + in1; - } - }; - - class SeprateVec3AryHandle : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn inVec3, FieldOut out0, FieldOut out1, FieldOut out2); - using ExecutionSignature = void(_1, _2, _3, _4); - - VTKM_CONT - SeprateVec3AryHandle() {} - - template - VTKM_EXEC void operator()(const Vec& inVec3, T& out0, T& out1, T& out2) const - { - out0 = inVec3[0]; - out1 = inVec3[1]; - out2 = inVec3[2]; - } - }; - - ////////// General worklet WRAPPER for Kd-tree ////// - template - vtkm::cont::ArrayHandle ReverseScanInclusiveByKey(vtkm::cont::ArrayHandle& keyHandle, - vtkm::cont::ArrayHandle& dataHandle, - BinaryFunctor binary_functor) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::cont::ArrayHandle resultHandle; - - auto reversedResultHandle = vtkm::cont::make_ArrayHandleReverse(resultHandle); - - Algorithm::ScanInclusiveByKey(vtkm::cont::make_ArrayHandleReverse(keyHandle), - vtkm::cont::make_ArrayHandleReverse(dataHandle), - reversedResultHandle, - binary_functor); - - return resultHandle; - } - - template - vtkm::cont::ArrayHandle Inverse01ArrayWrapper(vtkm::cont::ArrayHandle& inputHandle) - { - vtkm::cont::ArrayHandle InverseHandle; - InverseArray invWorklet; - vtkm::worklet::DispatcherMapField inverseArrayDispatcher(invWorklet); - inverseArrayDispatcher.Invoke(inputHandle, InverseHandle); - return InverseHandle; - } - - template - vtkm::cont::ArrayHandle ScatterArrayWrapper(vtkm::cont::ArrayHandle& inputHandle, - vtkm::cont::ArrayHandle& indexHandle) - { - vtkm::cont::ArrayHandle outputHandle; - outputHandle.Allocate(inputHandle.GetNumberOfValues()); - ScatterArray scatterWorklet; - vtkm::worklet::DispatcherMapField scatterArrayDispatcher(scatterWorklet); - scatterArrayDispatcher.Invoke(inputHandle, indexHandle, outputHandle); - return outputHandle; - } - - template - vtkm::cont::ArrayHandle NewKeyWrapper(vtkm::cont::ArrayHandle& oldSegIdHandle, - vtkm::cont::ArrayHandle& flagHandle) - { - vtkm::cont::ArrayHandle newSegIdHandle; - NewSegmentId newsegidWorklet; - vtkm::worklet::DispatcherMapField newSegIdDispatcher(newsegidWorklet); - newSegIdDispatcher.Invoke(oldSegIdHandle, flagHandle, newSegIdHandle); - return newSegIdHandle; - } - - template - vtkm::cont::ArrayHandle SaveSplitPointIdWrapper(vtkm::cont::ArrayHandle& pointIdHandle, - vtkm::cont::ArrayHandle& flagHandle, - vtkm::cont::ArrayHandle& rankHandle, - vtkm::cont::ArrayHandle& oldSplitIdHandle) - { - vtkm::cont::ArrayHandle splitIdInSegmentHandle; - FindSplitPointId findSplitPointIdWorklet; - vtkm::worklet::DispatcherMapField findSplitPointIdWorkletDispatcher( - findSplitPointIdWorklet); - findSplitPointIdWorkletDispatcher.Invoke(pointIdHandle, rankHandle, splitIdInSegmentHandle); - - vtkm::cont::ArrayHandle splitIdInSegmentByScanHandle = - ReverseScanInclusiveByKey(flagHandle, splitIdInSegmentHandle, vtkm::Maximum()); - - vtkm::cont::ArrayHandle splitIdHandle; - SaveSplitPointId saveSplitPointIdWorklet; - vtkm::worklet::DispatcherMapField saveSplitPointIdWorkletDispatcher( - saveSplitPointIdWorklet); - saveSplitPointIdWorkletDispatcher.Invoke( - splitIdInSegmentByScanHandle, flagHandle, oldSplitIdHandle, splitIdHandle); - - return splitIdHandle; - } - - template - vtkm::cont::ArrayHandle ArrayAddWrapper(vtkm::cont::ArrayHandle& array0Handle, - vtkm::cont::ArrayHandle& array1Handle) - { - vtkm::cont::ArrayHandle resultHandle; - ArrayAdd arrayAddWorklet; - vtkm::worklet::DispatcherMapField arrayAddDispatcher(arrayAddWorklet); - arrayAddDispatcher.Invoke(array0Handle, array1Handle, resultHandle); - return resultHandle; - } - - /////////////////////////////////////////////////// - ////////General Kd tree function ////////////////// - /////////////////////////////////////////////////// - template - vtkm::cont::ArrayHandle ComputeFlagProcedure(vtkm::cont::ArrayHandle& rankHandle, - vtkm::cont::ArrayHandle& segIdHandle) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::cont::ArrayHandle segCountAryHandle; - { - vtkm::cont::ArrayHandle tmpAryHandle; - vtkm::cont::ArrayHandleConstant constHandle(1, rankHandle.GetNumberOfValues()); - Algorithm::ScanInclusiveByKey( - segIdHandle, constHandle, tmpAryHandle, vtkm::Add()); //compute ttl segs in segment - - segCountAryHandle = ReverseScanInclusiveByKey(segIdHandle, tmpAryHandle, vtkm::Maximum()); - } - - vtkm::cont::ArrayHandle flagHandle; - vtkm::worklet::DispatcherMapField computeFlagDispatcher; - computeFlagDispatcher.Invoke(rankHandle, segCountAryHandle, flagHandle); - - return flagHandle; - } - - template - vtkm::cont::ArrayHandle SegmentedSplitProcedure(vtkm::cont::ArrayHandle& A_Handle, - vtkm::cont::ArrayHandle& B_Handle, - vtkm::cont::ArrayHandle& C_Handle) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::cont::ArrayHandle D_Handle; - T initValue = 0; - Algorithm::ScanExclusiveByKey(C_Handle, B_Handle, D_Handle, initValue, vtkm::Add()); - - vtkm::cont::ArrayHandleCounting Ecouting_Handle(0, 1, A_Handle.GetNumberOfValues()); - vtkm::cont::ArrayHandle E_Handle; - Algorithm::Copy(Ecouting_Handle, E_Handle); - - vtkm::cont::ArrayHandle F_Handle; - Algorithm::ScanInclusiveByKey(C_Handle, E_Handle, F_Handle, vtkm::Minimum()); - - vtkm::cont::ArrayHandle InvB_Handle = Inverse01ArrayWrapper(B_Handle); - vtkm::cont::ArrayHandle G_Handle; - Algorithm::ScanInclusiveByKey(C_Handle, InvB_Handle, G_Handle, vtkm::Add()); - - vtkm::cont::ArrayHandle H_Handle = - ReverseScanInclusiveByKey(C_Handle, G_Handle, vtkm::Maximum()); - - vtkm::cont::ArrayHandle I_Handle; - SegmentedSplitTransform sstWorklet; - vtkm::worklet::DispatcherMapField segmentedSplitTransformDispatcher( - sstWorklet); - segmentedSplitTransformDispatcher.Invoke( - B_Handle, D_Handle, F_Handle, G_Handle, H_Handle, I_Handle); - - return ScatterArrayWrapper(A_Handle, I_Handle); - } - - template - void RenumberRanksProcedure(vtkm::cont::ArrayHandle& A_Handle, - vtkm::cont::ArrayHandle& B_Handle, - vtkm::cont::ArrayHandle& C_Handle, - vtkm::cont::ArrayHandle& D_Handle) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::Id nPoints = A_Handle.GetNumberOfValues(); - - vtkm::cont::ArrayHandleCounting Ecouting_Handle(0, 1, nPoints); - vtkm::cont::ArrayHandle E_Handle; - Algorithm::Copy(Ecouting_Handle, E_Handle); - - vtkm::cont::ArrayHandle F_Handle; - Algorithm::ScanInclusiveByKey(D_Handle, E_Handle, F_Handle, vtkm::Minimum()); - - vtkm::cont::ArrayHandle G_Handle; - G_Handle = ArrayAddWrapper(A_Handle, F_Handle); - - vtkm::cont::ArrayHandleConstant HConstant_Handle(1, nPoints); - vtkm::cont::ArrayHandle H_Handle; - Algorithm::Copy(HConstant_Handle, H_Handle); - - vtkm::cont::ArrayHandle I_Handle; - T initValue = 0; - Algorithm::ScanExclusiveByKey(C_Handle, H_Handle, I_Handle, initValue, vtkm::Add()); - - vtkm::cont::ArrayHandle J_Handle; - J_Handle = ScatterArrayWrapper(I_Handle, G_Handle); - - vtkm::cont::ArrayHandle K_Handle; - K_Handle = ScatterArrayWrapper(B_Handle, G_Handle); - - vtkm::cont::ArrayHandle L_Handle; - L_Handle = SegmentedSplitProcedure(J_Handle, K_Handle, D_Handle); - - vtkm::cont::ArrayHandle M_Handle; - Algorithm::ScanInclusiveByKey(C_Handle, E_Handle, M_Handle, vtkm::Minimum()); - - vtkm::cont::ArrayHandle N_Handle; - N_Handle = ArrayAddWrapper(L_Handle, M_Handle); - - A_Handle = ScatterArrayWrapper(I_Handle, N_Handle); - } - - /////////////3D construction ///////////////////// - /// \brief Segmented split for 3D x, y, z coordinates - /// - /// Split \c pointId_Handle, \c X_Handle, \c Y_Handle and \c Z_Handle within each segment - /// as indicated by \c segId_Handle according to flags in \c flag_Handle. - /// - /// \tparam T - /// \param pointId_Handle - /// \param flag_Handle - /// \param segId_Handle - /// \param X_Handle - /// \param Y_Handle - /// \param Z_Handle - template - void SegmentedSplitProcedure3D(vtkm::cont::ArrayHandle& pointId_Handle, - vtkm::cont::ArrayHandle& flag_Handle, - vtkm::cont::ArrayHandle& segId_Handle, - vtkm::cont::ArrayHandle& X_Handle, - vtkm::cont::ArrayHandle& Y_Handle, - vtkm::cont::ArrayHandle& Z_Handle) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::cont::ArrayHandle D_Handle; - T initValue = 0; - Algorithm::ScanExclusiveByKey(segId_Handle, flag_Handle, D_Handle, initValue, vtkm::Add()); - - vtkm::cont::ArrayHandleCounting Ecouting_Handle(0, 1, pointId_Handle.GetNumberOfValues()); - vtkm::cont::ArrayHandle E_Handle; - Algorithm::Copy(Ecouting_Handle, E_Handle); - - vtkm::cont::ArrayHandle F_Handle; - Algorithm::ScanInclusiveByKey(segId_Handle, E_Handle, F_Handle, vtkm::Minimum()); - - vtkm::cont::ArrayHandle InvB_Handle = Inverse01ArrayWrapper(flag_Handle); - vtkm::cont::ArrayHandle G_Handle; - Algorithm::ScanInclusiveByKey(segId_Handle, InvB_Handle, G_Handle, vtkm::Add()); - - vtkm::cont::ArrayHandle H_Handle = - ReverseScanInclusiveByKey(segId_Handle, G_Handle, vtkm::Maximum()); - - vtkm::cont::ArrayHandle I_Handle; - SegmentedSplitTransform sstWorklet; - vtkm::worklet::DispatcherMapField segmentedSplitTransformDispatcher( - sstWorklet); - segmentedSplitTransformDispatcher.Invoke( - flag_Handle, D_Handle, F_Handle, G_Handle, H_Handle, I_Handle); - - pointId_Handle = ScatterArrayWrapper(pointId_Handle, I_Handle); - - flag_Handle = ScatterArrayWrapper(flag_Handle, I_Handle); - - X_Handle = ScatterArrayWrapper(X_Handle, I_Handle); - - Y_Handle = ScatterArrayWrapper(Y_Handle, I_Handle); - - Z_Handle = ScatterArrayWrapper(Z_Handle, I_Handle); - } - - /// \brief Perform one level of KD-Tree construction - /// - /// Construct a level of KD-Tree by segemeted splits (partitioning) of \c pointId_Handle, - /// \c xrank_Handle, \c yrank_Handle and \c zrank_Handle according to the medium element - /// in each segment as indicated by \c segId_Handle alone the axis determined by \c level. - /// The split point of each segment will be updated in \c splitId_Handle. - template - void OneLevelSplit3D(vtkm::cont::ArrayHandle& pointId_Handle, - vtkm::cont::ArrayHandle& xrank_Handle, - vtkm::cont::ArrayHandle& yrank_Handle, - vtkm::cont::ArrayHandle& zrank_Handle, - vtkm::cont::ArrayHandle& segId_Handle, - vtkm::cont::ArrayHandle& splitId_Handle, - vtkm::Int32 level) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::cont::ArrayHandle flag_Handle; - if (level % 3 == 0) - { - flag_Handle = ComputeFlagProcedure(xrank_Handle, segId_Handle); - } - else if (level % 3 == 1) - { - flag_Handle = ComputeFlagProcedure(yrank_Handle, segId_Handle); - } - else - { - flag_Handle = ComputeFlagProcedure(zrank_Handle, segId_Handle); - } - - SegmentedSplitProcedure3D( - pointId_Handle, flag_Handle, segId_Handle, xrank_Handle, yrank_Handle, zrank_Handle); - - vtkm::cont::ArrayHandle segIdOld_Handle; - Algorithm::Copy(segId_Handle, segIdOld_Handle); - segId_Handle = NewKeyWrapper(segIdOld_Handle, flag_Handle); - - RenumberRanksProcedure(xrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle); - RenumberRanksProcedure(yrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle); - RenumberRanksProcedure(zrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle); - - if (level % 3 == 0) - { - splitId_Handle = - SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, xrank_Handle, splitId_Handle); - } - else if (level % 3 == 1) - { - splitId_Handle = - SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, yrank_Handle, splitId_Handle); - } - else - { - splitId_Handle = - SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, zrank_Handle, splitId_Handle); - } - } - - /// \brief Construct KdTree from x y z coordinate vector. - /// - /// This method constructs an array based KD-Tree from x, y, z coordinates of points in \c - /// coordi_Handle. The method rotates between x, y and z axis and splits input points into - /// equal halves with respect to the split axis at each level of construction. The indices to - /// the leaf nodes are returned in \c pointId_Handle and indices to internal nodes (splits) - /// are returned in splitId_handle. - /// - /// \param coordi_Handle (in) x, y, z coordinates of input points - /// \param pointId_Handle (out) returns indices to leaf nodes of the KD-tree - /// \param splitId_Handle (out) returns indices to internal nodes of the KD-tree - // Leaf Node vector and internal node (split) vectpr - template - void Run(const vtkm::cont::ArrayHandle, CoordStorageTag>& coordi_Handle, - vtkm::cont::ArrayHandle& pointId_Handle, - vtkm::cont::ArrayHandle& splitId_Handle) - { - using Algorithm = vtkm::cont::Algorithm; - - vtkm::Id nTrainingPoints = coordi_Handle.GetNumberOfValues(); - vtkm::cont::ArrayHandleCounting counting_Handle(0, 1, nTrainingPoints); - Algorithm::Copy(counting_Handle, pointId_Handle); - vtkm::cont::ArrayHandle xorder_Handle; - Algorithm::Copy(counting_Handle, xorder_Handle); - vtkm::cont::ArrayHandle yorder_Handle; - Algorithm::Copy(counting_Handle, yorder_Handle); - vtkm::cont::ArrayHandle zorder_Handle; - Algorithm::Copy(counting_Handle, zorder_Handle); - - splitId_Handle.Allocate(nTrainingPoints); - - vtkm::cont::ArrayHandle xcoordi_Handle; - vtkm::cont::ArrayHandle ycoordi_Handle; - vtkm::cont::ArrayHandle zcoordi_Handle; - - SeprateVec3AryHandle sepVec3Worklet; - vtkm::worklet::DispatcherMapField sepVec3Dispatcher(sepVec3Worklet); - sepVec3Dispatcher.Invoke(coordi_Handle, xcoordi_Handle, ycoordi_Handle, zcoordi_Handle); - - Algorithm::SortByKey(xcoordi_Handle, xorder_Handle); - vtkm::cont::ArrayHandle xrank_Handle = - ScatterArrayWrapper(pointId_Handle, xorder_Handle); - - Algorithm::SortByKey(ycoordi_Handle, yorder_Handle); - vtkm::cont::ArrayHandle yrank_Handle = - ScatterArrayWrapper(pointId_Handle, yorder_Handle); - - Algorithm::SortByKey(zcoordi_Handle, zorder_Handle); - vtkm::cont::ArrayHandle zrank_Handle = - ScatterArrayWrapper(pointId_Handle, zorder_Handle); - - vtkm::cont::ArrayHandle segId_Handle; - vtkm::cont::ArrayHandleConstant constHandle(0, nTrainingPoints); - Algorithm::Copy(constHandle, segId_Handle); - - ///// build kd tree ///// - vtkm::Int32 maxLevel = static_cast(ceil(vtkm::Log2(nTrainingPoints) + 1)); - for (vtkm::Int32 i = 0; i < maxLevel - 1; i++) - { - OneLevelSplit3D( - pointId_Handle, xrank_Handle, yrank_Handle, zrank_Handle, segId_Handle, splitId_Handle, i); - } - } -}; -} -} -} // namespace vtkm::worklet - -#endif // vtk_m_worklet_KdTree3DConstruction_h diff --git a/vtkm/worklet/spatialstructure/KdTree3DNNSearch.h b/vtkm/worklet/spatialstructure/KdTree3DNNSearch.h deleted file mode 100644 index bf5ecbbe4..000000000 --- a/vtkm/worklet/spatialstructure/KdTree3DNNSearch.h +++ /dev/null @@ -1,226 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#ifndef vtk_m_worklet_KdTree3DNNSearch_h -#define vtk_m_worklet_KdTree3DNNSearch_h - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef VTKM_CUDA -#include -#endif - -namespace vtkm -{ -namespace worklet -{ -namespace spatialstructure -{ - -class VTKM_DEPRECATED(1.7, "K-D tree recursive searches are not well supported on GPU devices.") - KdTree3DNNSearch -{ -public: - class NearestNeighborSearch3DWorklet : public vtkm::worklet::WorkletMapField - { - public: - using ControlSignature = void(FieldIn qcIn, - WholeArrayIn treeIdIn, - WholeArrayIn treeSplitIdIn, - WholeArrayIn treeCoordiIn, - FieldOut nnIdOut, - FieldInOut nnDisOut); - using ExecutionSignature = void(_1, _2, _3, _4, _5, _6); - - VTKM_CONT - NearestNeighborSearch3DWorklet() {} - - template - VTKM_EXEC_CONT void NearestNeighborSearch3D(const CooriVecT& qc, - CooriT& dis, - vtkm::Id& nnpIdx, - vtkm::Int32 level, - vtkm::Id sIdx, - vtkm::Id tIdx, - const IdPortalT& treePortal, - const IdPortalT& splitIdPortal, - const CoordiPortalT& coordiPortal) const - { - CooriT qx = qc[0]; - CooriT qy = qc[1]; - CooriT qz = qc[2]; - - if (tIdx - sIdx == 1) - { ///// leaf node - vtkm::Id leafNodeIdx = treePortal.Get(sIdx); - CooriT leafX = coordiPortal.Get(leafNodeIdx)[0]; - CooriT leafY = coordiPortal.Get(leafNodeIdx)[1]; - CooriT leafZ = coordiPortal.Get(leafNodeIdx)[2]; - CooriT _dis = vtkm::Sqrt((leafX - qx) * (leafX - qx) + (leafY - qy) * (leafY - qy) + - (leafZ - qz) * (leafZ - qz)); - if (_dis < dis) - { - dis = _dis; - nnpIdx = leafNodeIdx; - } - } - else - { //normal Node - vtkm::Id splitNodeLoc = static_cast(vtkm::Ceil(double((sIdx + tIdx)) / 2.0)); - CooriT splitX = coordiPortal.Get(splitIdPortal.Get(splitNodeLoc))[0]; - CooriT splitY = coordiPortal.Get(splitIdPortal.Get(splitNodeLoc))[1]; - CooriT splitZ = coordiPortal.Get(splitIdPortal.Get(splitNodeLoc))[2]; - - CooriT splitAxis; - CooriT queryCoordi; - - if (level % 3 == 0) - { //x axis level - splitAxis = splitX; - queryCoordi = qx; - } - else if (level % 3 == 1) - { - splitAxis = splitY; - queryCoordi = qy; - } - else - { - splitAxis = splitZ; - queryCoordi = qz; - } - - if (queryCoordi <= splitAxis) - { //left tree first - if (queryCoordi - dis <= splitAxis) - NearestNeighborSearch3D(qc, - dis, - nnpIdx, - level + 1, - sIdx, - splitNodeLoc, - treePortal, - splitIdPortal, - coordiPortal); - if (queryCoordi + dis > splitAxis) - NearestNeighborSearch3D(qc, - dis, - nnpIdx, - level + 1, - splitNodeLoc, - tIdx, - treePortal, - splitIdPortal, - coordiPortal); - } - else - { //right tree first - if (queryCoordi + dis > splitAxis) - NearestNeighborSearch3D(qc, - dis, - nnpIdx, - level + 1, - splitNodeLoc, - tIdx, - treePortal, - splitIdPortal, - coordiPortal); - if (queryCoordi - dis <= splitAxis) - NearestNeighborSearch3D(qc, - dis, - nnpIdx, - level + 1, - sIdx, - splitNodeLoc, - treePortal, - splitIdPortal, - coordiPortal); - } - } - } - - template - VTKM_EXEC void operator()(const CoordiVecType& qc, - const IdPortalType& treeIdPortal, - const IdPortalType& treeSplitIdPortal, - const CoordiPortalType& treeCoordiPortal, - IdType& nnId, - CoordiType& nnDis) const - { - NearestNeighborSearch3D(qc, - nnDis, - nnId, - 0, - 0, - treeIdPortal.GetNumberOfValues(), - treeIdPortal, - treeSplitIdPortal, - treeCoordiPortal); - } - }; - - /// \brief Execute the Neaseat Neighbor Search given kdtree and search points - /// - /// Given x, y, z coordinate of of training data points in \c coordi_Handle, indices to KD-tree - /// leaf nodes in \c pointId_Handle and indices to internal nodes in \c splitId_Handle, search - /// for nearest neighbors in the training data points for each of testing points in \c qc_Handle. - /// Returns indices to nearest neighbor in \c nnId_Handle and distance to nearest neighbor in - /// \c nnDis_Handle. - - template - void Run(const vtkm::cont::ArrayHandle, CoordStorageTag1>& coordi_Handle, - const vtkm::cont::ArrayHandle& pointId_Handle, - const vtkm::cont::ArrayHandle& splitId_Handle, - const vtkm::cont::ArrayHandle, CoordStorageTag2>& qc_Handle, - vtkm::cont::ArrayHandle& nnId_Handle, - vtkm::cont::ArrayHandle& nnDis_Handle, - DeviceAdapter) - { - //fill the nnDis_Handle handle array with max values before running - auto intialValue = std::numeric_limits::max(); - vtkm::cont::Algorithm::Copy( - vtkm::cont::make_ArrayHandleConstant(intialValue, qc_Handle.GetNumberOfValues()), - nnDis_Handle); - -//set up stack size for cuda environment -#ifdef VTKM_CUDA - vtkm::cont::cuda::internal::ScopedCudaStackSize stack(16 * 1024); - (void)stack; -#endif - - NearestNeighborSearch3DWorklet nns3dWorklet; - vtkm::worklet::DispatcherMapField nns3DDispatcher(nns3dWorklet); - nns3DDispatcher.Invoke( - qc_Handle, pointId_Handle, splitId_Handle, coordi_Handle, nnId_Handle, nnDis_Handle); - } -}; -} -} -} // namespace vtkm::worklet - -#endif // vtk_m_worklet_KdTree3DNNSearch_h diff --git a/vtkm/worklet/testing/CMakeLists.txt b/vtkm/worklet/testing/CMakeLists.txt index cbc6679b0..8683de07d 100644 --- a/vtkm/worklet/testing/CMakeLists.txt +++ b/vtkm/worklet/testing/CMakeLists.txt @@ -20,6 +20,7 @@ set(unit_tests UnitTestContourTreeUniformDistributed.cxx UnitTestCosmoTools.cxx UnitTestDescriptiveStatistics.cxx + UnitTestDispatcherBase.cxx UnitTestFieldStatistics.cxx UnitTestKeys.cxx UnitTestMaskIndices.cxx @@ -52,7 +53,7 @@ vtkm_unit_tests( LIBRARIES vtkm_source vtkm_worklet vtkm_filter vtkm_io USE_VTKM_JOB_POOL ) -if (TARGET vtkm::cuda) +if (TARGET vtkm_cuda) if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0) set(problematic_cuda_srcs diff --git a/vtkm/worklet/testing/GenerateTestDataSets.h b/vtkm/worklet/testing/GenerateTestDataSets.h index cbf13d69b..6ec53a9ec 100644 --- a/vtkm/worklet/testing/GenerateTestDataSets.h +++ b/vtkm/worklet/testing/GenerateTestDataSets.h @@ -193,7 +193,7 @@ inline vtkm::cont::DataSet CreateExplicitFromStructuredDataSet(const vtkm::Bound if (addGhost) { - output.AddGhostCellField(input.GetGhostCellField()); + output.SetGhostCellField(input.GetGhostCellField()); } return output; diff --git a/vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx b/vtkm/worklet/testing/UnitTestDispatcherBase.cxx similarity index 100% rename from vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx rename to vtkm/worklet/testing/UnitTestDispatcherBase.cxx diff --git a/vtkm/worklet/testing/UnitTestKeys.cxx b/vtkm/worklet/testing/UnitTestKeys.cxx index 09004c906..668a130f5 100644 --- a/vtkm/worklet/testing/UnitTestKeys.cxx +++ b/vtkm/worklet/testing/UnitTestKeys.cxx @@ -14,16 +14,6 @@ #include -// Make sure deprecated types still work (while applicable) -VTKM_DEPRECATED_SUPPRESS_BEGIN -VTKM_STATIC_ASSERT((std::is_same::Lookup, - typename vtkm::worklet::internal::KeysBase::ExecLookup>::value)); -VTKM_STATIC_ASSERT((std::is_same::ExecutionTypes< - vtkm::cont::DeviceAdapterTagSerial>::Lookup, - typename vtkm::worklet::Keys::ExecLookup>::value)); -VTKM_DEPRECATED_SUPPRESS_END - namespace { diff --git a/vtkm/worklet/testing/UnitTestNDimsHistMarginalization.cxx b/vtkm/worklet/testing/UnitTestNDimsHistMarginalization.cxx index c1eb83944..176c9be2f 100644 --- a/vtkm/worklet/testing/UnitTestNDimsHistMarginalization.cxx +++ b/vtkm/worklet/testing/UnitTestNDimsHistMarginalization.cxx @@ -206,11 +206,6 @@ struct VariableCondition // void TestNDimsHistMarginalization() { - // Setup and calculate a ND-histogram without marginalization first - // Create the output bin array - vtkm::cont::ArrayHandle range; - vtkm::cont::ArrayHandle delta; - // Data attached is the poisson distribution vtkm::cont::DataSet ds = MakeTestDataSet(); diff --git a/vtkm/worklet/testing/UnitTestNormalize.cxx b/vtkm/worklet/testing/UnitTestNormalize.cxx index 57fe3a858..c8646df02 100644 --- a/vtkm/worklet/testing/UnitTestNormalize.cxx +++ b/vtkm/worklet/testing/UnitTestNormalize.cxx @@ -90,7 +90,6 @@ void TestNormalize() createVectors(inputVecs); vtkm::cont::ArrayHandle> inputArray; - vtkm::cont::ArrayHandle> outputArray; inputArray = vtkm::cont::make_ArrayHandle(inputVecs, vtkm::CopyFlag::On); vtkm::worklet::Normalize normalizeWorklet; diff --git a/vtkm/worklet/vtkm.module b/vtkm/worklet/vtkm.module new file mode 100644 index 000000000..519399a3a --- /dev/null +++ b/vtkm/worklet/vtkm.module @@ -0,0 +1,11 @@ +NAME + vtkm_worklet +GROUPS + Core +DEPENDS + vtkm_cont +TEST_DEPENDS + vtkm_source + vtkm_worklet + vtkm_filter + vtkm_io