Merge topic 'add_gitlab_ci'

d7ab1a608 Improve parallelization when compiling filter tests
142d151ca Update CONTRIBUTING.md to cover gitlab piplines
5bc09b976 Add gitlab-ci infrastructure
ef7ef5fb2 Add documentation for the what/why of using Gitlab ci
36d1a2d6a Add dockerfiles to be used by VTK-m Gitlab ci
b16e4fc17 Add ECP CI support to vtk-m

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1987
This commit is contained in:
Robert Maynard 2020-03-26 19:39:18 +00:00 committed by Kitware Robot
commit f06a5db9af
39 changed files with 2127 additions and 407 deletions

125
.gitlab-ci-ecp.yml Normal file

@ -0,0 +1,125 @@
.slurm_p9_cuda: &slurm_p9_cuda
tags:
- nmc
- slurm
- nmc-xxfe1-sched-001
- xx-fe1
variables:
NMC_FE1_SLURM_PARAMETERS: " -N1 -p ecp-p9-4v100 --extra-node-info=*:*:* -t 1:30:00 "
CC: "gcc"
CXX: "g++"
CUDAHOSTCXX: "g++"
before_script:
# We need gcc-4.8.5, which is the system default compiler but not a compiler
# listed under the module system.
#
# That means to get this to work properly we explicitly do not request
# any compiler.
- module load cuda cmake/3.14.5
.slurm_p9_opemp: &slurm_p9_opemp
tags:
- nmc
- slurm
- nmc-xxfe1-sched-001
- xx-fe1
variables:
NMC_FE1_SLURM_PARAMETERS: " -N1 -p ecp-p9-4v100 --extra-node-info=*:*:* -t 1:30:00 "
before_script:
- module load gcc/8.3.0 openmpi/3.1.4 cmake/3.14.5
.cmake_build_artifacts: &cmake_build_artifacts
artifacts:
expire_in: 24 hours
when: always
paths:
# The artifacts of the build.
- vtkm-build/bin/
- vtkm-build/include/
# CTest files.
# XXX(globbing): Can be simplified with support from
# https://gitlab.com/gitlab-org/gitlab-runner/issues/4840
- vtkm-build/CTestCustom*.cmake
- vtkm-build/CTestTestfile.cmake
- vtkm-build/*/CTestTestfile.cmake
- vtkm-build/*/*/CTestTestfile.cmake
- vtkm-build/*/*/*/CTestTestfile.cmake
- vtkm-build/*/*/*/*/CTestTestfile.cmake
- vtkm-build/*/*/*/*/*/CTestTestfile.cmake
- vtkm-build/Testing/
# CDash files.
- vtkm-build/DartConfiguration.tcl
.cmake_build_p9_cuda: &cmake_build_p9_cuda
stage: build
script:
- srun env | grep SLURM_JOB_NAME
- mkdir vtkm-build
- pushd vtkm-build
- cmake -DCMAKE_BUILD_TYPE=Release -DVTKm_ENABLE_CUDA=ON -S ../
- cmake --build . -j20
- popd
.cmake_build_p9_openmp: &cmake_build_p9_openmp
stage: build
script:
- srun env | grep SLURM_JOB_NAME
- mkdir vtkm-build
- pushd vtkm-build
- cmake -DCMAKE_BUILD_TYPE=Release -DVTKm_ENABLE_OPENMP=ON -S ../
- cmake --build . -j20
- popd
.cmake_test_p9: &cmake_test_p9
stage: test
script:
- echo "running the test using artifacts of the build"
- pushd vtkm-build
# We need to exclude the following tests
# - CopyrightStatement
# - TestInstallSetup
# - SourceInInstall
# Which we can do by using an exclude regex
- ctest -E "Install|CopyrightStatement"
- popd
stages:
- build
- test
build:p9_openmp:
extends:
- .slurm_p9_opemp
- .cmake_build_artifacts
- .cmake_build_p9_openmp
test:p9_openmp:
extends:
- .slurm_p9_opemp
- .cmake_test_p9
dependencies:
- build:p9_openmp
needs:
- build:p9_openmp
build:p9_cuda:
extends:
- .slurm_p9_cuda
- .cmake_build_artifacts
- .cmake_build_p9_cuda
test:p9_cuda:
extends:
- .slurm_p9_cuda
- .cmake_test_p9
dependencies:
- build:p9_cuda
needs:
- build:p9_cuda

143
.gitlab-ci.yml Normal file

@ -0,0 +1,143 @@
# Docker Images:
#
# - CentOS 7
# * .gitlab/ci/docker/centos7/cuda10.2/
# - cuda
# - gcc 4.8.5
# * .gitlab/ci/rhel8/cuda10.2/
# - cuda
# - gcc 8.2.1
# * .gitlab/ci/ubuntu1604/base/
# - gcc 4.8
# - clang 3.8
# - clang 5.0
# - tbb
# - openmpi
# * .gitlab/ci/ubuntu1604/cuda9.2/
# - cuda
# - gcc 5.4
# - tbb
# - openmp
# - openmpi
# * .gitlab/ci/ubuntu1804/base/
# - gcc 7.4
# - gcc 9
# - clang 8
# - tbb
# - openmp
# - mpich2
# * .gitlab/ci/ubuntu1804/cuda10.1/
# - cuda
# - gcc 7.4
# - tbb
# - openmp
# - mpich2
.docker_image: &docker_image
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/gitlab-kitware-sciviz-ci
.centos7: &centos7
image: "kitware/vtkm:ci-centos7_cuda10.2-20200320"
extends:
- .docker_image
.rhel8: &rhel8
image: "kitware/vtkm:ci-rhel8_cuda10.2-20200320"
extends:
- .docker_image
.ubuntu1604: &ubuntu1604
image: "kitware/vtkm:ci-ubuntu1604-20200320"
extends:
- .docker_image
.ubuntu1604_cuda: &ubuntu1604_cuda
image: "kitware/vtkm:ci-ubuntu1604_cuda9.2-20200320"
extends:
- .docker_image
.ubuntu1804: &ubuntu1804
image: "kitware/vtkm:ci-ubuntu1804-20200320"
extends:
- .docker_image
.ubuntu1804_cuda: &ubuntu1804_cuda
image: "kitware/vtkm:ci-ubuntu1804_cuda10.1-20200320"
extends:
- .docker_image
# General Longer Term Tasks:
# - setup asan, and ubsan as sub-pipeline
# - setup clang tidy as sub-pipeline
#
# Current Tasks:
# - Determine if we can get sccache to work with CUDA
# - Setup a machine to replicate the issue in https://gitlab.kitware.com/vtk/vtk-m/issues/447
# Note: Centos7 doesn't work as they ship separate standard library
# headers for each version. We will have to figure out something else
# like using spack or building llvm/clang from source
stages:
- build
- test
.cmake_build_linux: &cmake_build_linux
stage: build
timeout: 2 hours
interruptible: true
before_script:
- .gitlab/ci/config/sccache.sh
- export PATH=$PWD/.gitlab:$PATH
- SCCACHE_IDLE_TIMEOUT=1200 sccache --start-server
- sccache --show-stats
- "cmake --version"
- "cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake"
script:
- "ctest -VV -S .gitlab/ci/ctest_configure.cmake"
- "ctest -VV -S .gitlab/ci/ctest_build.cmake"
- sccache --show-stats
artifacts:
expire_in: 24 hours
when: always
paths:
# The artifacts of the build.
- build/bin/
- build/include/
- build/lib/
# CTest and CMake install files.
# XXX(globbing): Can be simplified with support from
# https://gitlab.com/gitlab-org/gitlab-runner/issues/4840
#
# Note: this also captures our CIState.cmake file
- build/CMakeCache.txt
- build/*.cmake
- build/*/*.cmake
- build/*/*/*.cmake
- build/*/*/*/*.cmake
- build/*/*/*/*/*.cmake
- build/*/*/*/*/*/*.cmake
- build/Testing/
# CDash files.
- build/DartConfiguration.tcl
.cmake_test_linux: &cmake_test_linux
stage: test
timeout: 30 minutes
interruptible: true
script:
#Need to use our custom ctest-latest symlink
#This will allow us to use 3.17+ which has support
#for running failed tests multiple times so failures
#due to system load are not reported
- "ctest-latest -VV -S .gitlab/ci/ctest_test.cmake"
include:
- local: '/.gitlab/ci/centos7.yml'
- local: '/.gitlab/ci/rhel8.yml'
- local: '/.gitlab/ci/ubuntu1604.yml'
- local: '/.gitlab/ci/ubuntu1804.yml'

49
.gitlab/ci/centos7.yml Normal file

@ -0,0 +1,49 @@
# Build on centos7 with CUDA and test on rhel8 and centos7
# gcc 4.8
build:centos7_gcc48:
tags:
- build
- vtkm
- docker
- linux
- large-memory
extends:
- .centos7
- .cmake_build_linux
variables:
CMAKE_BUILD_TYPE: RelWithDebInfo
CMAKE_GENERATOR: "Unix Makefiles"
VTKM_SETTINGS: "cuda+turing+32bit_ids"
test:centos7_gcc48:
tags:
- test
- cuda-rt
- turing
- vtkm
- docker
- linux
extends:
- .centos7
- .cmake_test_linux
dependencies:
- build:centos7_gcc48
needs:
- build:centos7_gcc48
test:rhel8_test_centos7:
tags:
- test
- cuda-rt
- turing
- vtkm
- docker
- linux
extends:
- .rhel8
- .cmake_test_linux
dependencies:
- build:centos7_gcc48
needs:
- build:centos7_gcc48

@ -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.
##
##=============================================================================
if (NOT DEFINED "ENV{GITLAB_CI}")
message(FATAL_ERROR
"This script assumes it is being run inside of GitLab-CI")
endif ()
# Set up the source and build paths.
set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}")
set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
if ("$ENV{VTKM_SETTINGS}" STREQUAL "")
message(FATAL_ERROR
"The VTKM_SETTINGS environment variable is required to know what "
"build options should be used.")
endif ()
# Default to Release builds.
if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_BUILD_TYPE}")
endif ()
if (NOT CTEST_BUILD_CONFIGURATION)
set(CTEST_BUILD_CONFIGURATION "Release")
endif ()
# Set the build metadata.
string(TOLOWER ${CTEST_BUILD_CONFIGURATION} build_type)
set(CTEST_BUILD_NAME "${build_type}+$ENV{VTKM_SETTINGS}")
set(site_name "$ENV{CI_JOB_NAME}")
string(REPLACE "build" "" site_name "${site_name}")
string(REPLACE "test" "" site_name "${site_name}")
string(REPLACE ":" "" site_name "${site_name}")
set(CTEST_SITE ${site_name})
# Default to using Ninja.
if (NOT "$ENV{CMAKE_GENERATOR}" STREQUAL "")
set(CTEST_CMAKE_GENERATOR "$ENV{CMAKE_GENERATOR}")
endif ()
if (NOT CTEST_CMAKE_GENERATOR)
set(CTEST_CMAKE_GENERATOR "Ninja")
endif ()
# Determine the track to submit to.
set(CTEST_TRACK "Experimental")
if ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "master")
set(CTEST_TRACK "Nightly")
endif ()
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
include(ProcessorCount)
ProcessorCount(nproc)
set(CTEST_BUILD_FLAGS "-j${nproc}")
endif ()
#We need to do write this information out to a file in the build directory
set(state
"
set(CTEST_SOURCE_DIRECTORY \"${CTEST_SOURCE_DIRECTORY}\")
set(CTEST_BINARY_DIRECTORY \"${CTEST_BINARY_DIRECTORY}\")
set(CTEST_BUILD_NAME ${CTEST_BUILD_NAME})
set(CTEST_SITE ${CTEST_SITE})
set(CTEST_CMAKE_GENERATOR \"${CTEST_CMAKE_GENERATOR}\")
set(CTEST_BUILD_CONFIGURATION ${CTEST_BUILD_CONFIGURATION})
set(CTEST_BUILD_FLAGS \"${CTEST_BUILD_FLAGS}\")
set(CTEST_TRACK ${CTEST_TRACK})
"
)
file(WRITE ${CTEST_BINARY_DIRECTORY}/CIState.cmake "${state}")

@ -0,0 +1,61 @@
##=============================================================================
##
## 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.
##
##=============================================================================
string(REPLACE "+" ";" options "$ENV{VTKM_SETTINGS}")
foreach(option IN LISTS options)
if(static STREQUAL option)
set(BUILD_SHARED_LIBS "OFF" CACHE STRING "")
elseif(shared STREQUAL option)
set(BUILD_SHARED_LIBS "ON" CACHE STRING "")
elseif(32bit_ids STREQUAL option)
set(VTKm_USE_64BIT_IDS "OFF" CACHE STRING "")
elseif(64bit_floats STREQUAL option)
set(VTKm_USE_DOUBLE_PRECISION "ON" CACHE STRING "")
elseif(mpi STREQUAL option)
set(VTKm_ENABLE_MPI "ON" CACHE STRING "")
elseif(tbb STREQUAL option)
set(VTKm_ENABLE_TBB "ON" CACHE STRING "")
elseif(openmp STREQUAL option)
set(VTKm_ENABLE_OPENMP "ON" CACHE STRING "")
elseif(cuda STREQUAL option)
set(VTKm_ENABLE_CUDA "ON" CACHE STRING "")
elseif(maxwell STREQUAL option)
set(VTKm_CUDA_Architecture "maxwell" CACHE STRING "")
elseif(pascal STREQUAL option)
set(VTKm_CUDA_Architecture "pascal" CACHE STRING "")
elseif(volta STREQUAL option)
set(VTKm_CUDA_Architecture "volta" CACHE STRING "")
elseif(turing STREQUAL option)
set(VTKm_CUDA_Architecture "turing" CACHE STRING "")
endif()
endforeach()
set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "")
set(CMAKE_C_COMPILER_LAUNCHER "sccache" CACHE STRING "")
set(CMAKE_CXX_COMPILER_LAUNCHER "sccache" CACHE STRING "")
if(VTKm_ENABLE_CUDA)
set(CMAKE_CUDA_COMPILER_LAUNCHER "sccache" CACHE STRING "")
endif()

16
.gitlab/ci/config/sccache.sh Executable file

@ -0,0 +1,16 @@
#!/bin/sh
set -e
readonly version="0.2.12"
readonly sha256sum="26fd04c1273952cc2a0f359a71c8a1857137f0ee3634058b3f4a63b69fc8eb7f"
readonly filename="sccache-$version-x86_64-unknown-linux-musl"
readonly tarball="$filename.tar.gz"
cd .gitlab
echo "$sha256sum $tarball" > sccache.sha256sum
curl -OL "https://github.com/mozilla/sccache/releases/download/$version/$tarball"
sha256sum --check sccache.sha256sum
tar xf "$tarball"
mv "$filename/sccache" .

@ -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.
##
##=============================================================================
cmake_minimum_required(VERSION 3.8)
# 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}")
# Pick up from where the configure left off.
ctest_start(APPEND)
message(STATUS "CTEST_BUILD_FLAGS: ${CTEST_BUILD_FLAGS}")
ctest_build(APPEND
NUMBER_WARNINGS num_warnings
RETURN_VALUE build_result)
ctest_submit(PARTS Build)
if (build_result)
message(FATAL_ERROR
"Failed to build")
endif ()

@ -0,0 +1,44 @@
##=============================================================================
##
## 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.
##
##=============================================================================
cmake_minimum_required(VERSION 3.8)
# 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}")
set(cmake_args
-C "${CMAKE_CURRENT_LIST_DIR}/config/initial_config.cmake")
# Create an entry in CDash.
ctest_start(Experimental TRACK "${CTEST_TRACK}")
# Gather update information.
find_package(Git)
set(CTEST_UPDATE_VERSION_ONLY ON)
set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}")
ctest_update()
# Configure the project.
ctest_configure(APPEND
OPTIONS "${cmake_args}"
RETURN_VALUE configure_result)
# We can now submit because we've configured. This is a cmb-superbuild-ism.
ctest_submit(PARTS Update)
ctest_submit(PARTS Configure)
if (configure_result)
message(FATAL_ERROR
"Failed to configure")
endif ()

@ -0,0 +1,41 @@
##=============================================================================
##
## 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.
##
##=============================================================================
# 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}")
# Pick up from where the configure left off.
ctest_start(APPEND)
set(test_exclusions
# placeholder for tests to exclude
)
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
if (test_exclusions)
set(test_exclusions "(${test_exclusions})")
endif ()
ctest_test(APPEND
PARALLEL_LEVEL "10"
RETURN_VALUE test_result
EXCLUDE "${test_exclusions}"
REPEAT "UNTIL_PASS:3"
)
ctest_submit(PARTS Test)
if (test_result)
message(FATAL_ERROR
"Failed to test")
endif ()

@ -0,0 +1,21 @@
FROM nvidia/cuda:10.2-devel-centos7
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
RUN yum install cmake make gcc gcc-c++ -y
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | bash
RUN yum install git git-lfs -y
# Provide a consistent CMake path across all images
# Install CMake 3.13 as it is the minium for cuda builds
RUN mkdir /opt/cmake && \
curl -L https://github.com/Kitware/CMake/releases/download/v3.13.5/cmake-3.13.5-Linux-x86_64.sh > cmake-3.13.5-Linux-x86_64.sh && \
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

@ -0,0 +1,18 @@
FROM nvidia/cuda:10.2-devel-ubi8
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
RUN yum install cmake make gcc gcc-c++ curl -y
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | bash
RUN yum install git git-lfs -y
# Provide a consistent CMake path across all images
RUN mkdir -p /opt/cmake/bin && ln -s /usr/bin/cmake /opt/cmake/bin/cmake
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

@ -0,0 +1,51 @@
FROM ubuntu:16.04
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
# Base dependencies for building VTK-m projects
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
autotools-dev \
clang-3.8 \
clang-5.0 \
curl \
g++ \
g++-4.8 \
libtbb-dev \
make \
ninja-build \
software-properties-common \
ssh
# extra dependencies for dejagore machine
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
RUN apt-get install -y --no-install-recommends \
git \
git-lfs \
&& \
rm -rf /var/lib/apt/lists/*
# Provide a modern OpenMPI verion that supports
# running as root via environment variables
RUN mkdir /opt/openmpi && \
curl -L https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.3.tar.gz > openmpi-4.0.3.tar.gz && \
tar -xf openmpi-4.0.3.tar.gz && \
cd openmpi-4.0.3 && \
./configure --prefix=/opt/openmpi && \
make -j all && \
make install
# Provide a consistent CMake path across all images
# Install CMake 3.8 as it is the minium for non-cuda builds
RUN mkdir /opt/cmake && \
curl -L https://github.com/Kitware/CMake/releases/download/v3.8.2/cmake-3.8.2-Linux-x86_64.sh > cmake-3.8.2-Linux-x86_64.sh && \
sh cmake-3.8.2-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

@ -0,0 +1,49 @@
FROM nvidia/cuda:9.2-devel-ubuntu16.04
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
# Base dependencies for building VTK-m projects
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
autotools-dev \
curl \
g++ \
libomp-dev \
libtbb-dev \
make \
ninja-build \
software-properties-common \
ssh
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
git-lfs \
&& \
rm -rf /var/lib/apt/lists/*
# Provide a modern OpenMPI verion that supports
# running as root via environment variables
RUN mkdir /opt/openmpi && \
curl -L https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.3.tar.gz > openmpi-4.0.3.tar.gz && \
tar -xf openmpi-4.0.3.tar.gz && \
cd openmpi-4.0.3 && \
./configure --prefix=/opt/openmpi && \
make -j all && \
make install
# Provide a consistent CMake path across all images
# Allow tests that require CMake to work correctly
# Install CMake 3.13 as it is the minium for cuda builds
RUN mkdir /opt/cmake && \
curl -L https://github.com/Kitware/CMake/releases/download/v3.13.5/cmake-3.13.5-Linux-x86_64.sh > cmake-3.13.5-Linux-x86_64.sh && \
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

@ -0,0 +1,43 @@
FROM ubuntu:18.04
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
# Base dependencies for building VTK-m projects
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
curl \
g++ \
git \
git-lfs \
libmpich-dev \
libomp-dev \
libtbb-dev \
mpich \
ninja-build \
software-properties-common
# extra dependencies for charm machine
RUN add-apt-repository ppa:jonathonf/gcc-9.2
RUN apt-get update && apt-get install -y --no-install-recommends \
clang-8 \
g++-9 \
&& \
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.4/cmake-3.16.4-Linux-x86_64.sh > cmake-3.16.4-Linux-x86_64.sh && \
sh cmake-3.16.4-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

@ -0,0 +1,35 @@
FROM nvidia/cuda:10.1-devel-ubuntu18.04
LABEL maintainer "Robert Maynard<robert.maynard@kitware.com>"
# Base dependencies for building VTK-m projects
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
g++ \
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.4/cmake-3.16.4-Linux-x86_64.sh > cmake-3.16.4-Linux-x86_64.sh && \
sh cmake-3.16.4-Linux-x86_64.sh --prefix=/opt/cmake/ --exclude-subdir --skip-license
# 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.0/cmake-3.17.0-Linux-x86_64.sh > cmake-3.17.0-Linux-x86_64.sh && \
sh cmake-3.17.0-Linux-x86_64.sh --prefix=/opt/cmake-latest/ --exclude-subdir --skip-license && \
ln -s /opt/cmake-latest/bin/ctest /opt/cmake-latest/bin/ctest-latest
ENV PATH "/opt/cmake/bin:/opt/cmake-latest/bin:${PATH}"

35
.gitlab/ci/docker/update_all.sh Executable file

@ -0,0 +1,35 @@
#!/bin/sh
set -e
set -x
# data is expected to be a string of the form YYYYMMDD
readonly date="$1"
cd centos7/cuda10.2
sudo docker build -t kitware/vtkm:ci-centos7_cuda10.2-$date .
cd ../..
cd rhel8/cuda10.2
sudo docker build -t kitware/vtkm:ci-rhel8_cuda10.2-$date .
cd ../..
cd ubuntu1604/base
sudo docker build -t kitware/vtkm:ci-ubuntu1604-$date .
cd ../..
cd ubuntu1604/cuda9.2
sudo docker build -t kitware/vtkm:ci-ubuntu1604_cuda9.2-$date .
cd ../..
cd ubuntu1804/base
sudo docker build -t kitware/vtkm:ci-ubuntu1804-$date .
cd ../..
cd ubuntu1804/cuda10.1
sudo docker build -t kitware/vtkm:ci-ubuntu1804_cuda10.1-$date .
cd ../..
# sudo docker login --username=<docker_hub_name>
sudo docker push kitware/vtkm
sudo docker system prune

29
.gitlab/ci/rhel8.yml Normal file

@ -0,0 +1,29 @@
# Build on rhel8 with serial and test on rhel8
# Uses gcc 8.2.1
build:rhel8:
tags:
- build
- vtkm
- docker
- linux
extends:
- .rhel8
- .cmake_build_linux
variables:
CMAKE_GENERATOR: "Unix Makefiles"
VTKM_SETTINGS: "serial+shared+64bit_floats+32bit_ids"
test:rhel8:
tags:
- test
- vtkm
- docker
- linux
extends:
- .rhel8
- .cmake_test_linux
dependencies:
- build:rhel8
needs:
- build:rhel8

93
.gitlab/ci/ubuntu1604.yml Normal file

@ -0,0 +1,93 @@
# Build on ubuntu1604 with CUDA 9.2 and test on ubuntu1604 and ubuntu1804
# Uses gcc 5, and build for pascal as CUDA 9.2 doesn't support turing
build:ubuntu1604_gcc5:
tags:
- build
- vtkm
- docker
- linux
- large-memory
extends:
- .ubuntu1604_cuda
- .cmake_build_linux
variables:
CMAKE_BUILD_TYPE: RelWithDebInfo
VTKM_SETTINGS: "cuda+pascal"
# Temporarily disabled as we don't have a pascal hw gitlab-runner
# test:ubuntu1604_gcc5:
# tags:
# - test
# - cuda-rt
# - pascal
# - vtkm
# - docker
# - linux
# extends:
# - .ubuntu1604_cuda
# - .cmake_test_linux
# dependencies:
# - build:ubuntu1604_gcc5
# needs:
# - build:ubuntu1604_gcc5
# test:ubuntu1804_test_ubuntu1604_gcc5:
# tags:
# - test
# - cuda-rt
# - pascal
# - vtkm
# - docker
# - linux
# extends:
# - .ubuntu1804_cuda
# - .cmake_test_linux
# dependencies:
# - build:ubuntu1604_gcc5
# needs:
# - build:ubuntu1604_gcc5
# Build on ubuntu1604 with mpi + tbb and test on ubuntu1604
# Uses gcc 4.8
# Uses OpenMPI
build:ubuntu1604_gcc48:
tags:
- build
- vtkm
- docker
- linux
extends:
#Requires the cuda docker image as it uses a sufficiently new
#enough CMake version that supports mpi
- .ubuntu1604_cuda
- .cmake_build_linux
variables:
CMAKE_BUILD_TYPE: Release
#custom openmpi install location
CMAKE_PREFIX_PATH: "/opt/openmpi/"
VTKM_SETTINGS: "tbb+mpi"
test:ubuntu1604_gcc48:
tags:
- test
- vtkm
- docker
- linux
extends:
- .ubuntu1604
- .cmake_test_linux
variables:
#env flags to allow openmpi to run as root user
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
dependencies:
- build:ubuntu1604_gcc48
needs:
- build:ubuntu1604_gcc48
# Todo:
# Build on ubuntu1604 with TBB and test on ubuntu1804
# Uses clang 3.8
# Build on ubuntu1604 with TBB and test on ubuntu1604 and ubuntu1804
# Uses clang 5.0, Debug??, Static/shared?

97
.gitlab/ci/ubuntu1804.yml Normal file

@ -0,0 +1,97 @@
# Build on ubuntu1804 with TBB and OpenMP and test on ubuntu1804
# Uses gcc 9
# Uses MPICH2
build:ubuntu1804_gcc9:
tags:
- build
- vtkm
- docker
- linux
extends:
- .ubuntu1804
- .cmake_build_linux
variables:
CC: "gcc-9"
CXX: "g++-9"
CMAKE_BUILD_TYPE: Debug
VTKM_SETTINGS: "tbb+openmp+mpi"
test:ubuntu1804_gcc9:
tags:
- test
- vtkm
- docker
- linux
extends:
- .ubuntu1804
- .cmake_test_linux
dependencies:
- build:ubuntu1804_gcc9
needs:
- build:ubuntu1804_gcc9
# Build on ubuntu1804 with CUDA + MPI and test on ubuntu1804
# Uses gcc 7.4
# Uses MPICH2
build:ubuntu1804_gcc7:
tags:
- build
- vtkm
- docker
- linux
- large-memory
extends:
- .ubuntu1804_cuda
- .cmake_build_linux
variables:
CC: "gcc-7"
CXX: "g++-7"
VTKM_SETTINGS: "cuda+turing+mpi+64bit_floats"
test:ubuntu1804_gcc7:
tags:
- test
- cuda-rt
- turing
- vtkm
- docker
- linux
extends:
- .ubuntu1804_cuda
- .cmake_test_linux
dependencies:
- build:ubuntu1804_gcc7
needs:
- build:ubuntu1804_gcc7
# Build on ubuntu1804 with TBB and test on ubuntu1804
# Uses clang 8
build:ubuntu1804_clang8:
tags:
- build
- vtkm
- docker
- linux
extends:
- .ubuntu1804
- .cmake_build_linux
variables:
CC: "clang-8"
CXX: "clang++-8"
CMAKE_BUILD_TYPE: Debug
VTKM_SETTINGS: "tbb+shared"
test:ubuntu1804_clang8:
tags:
- test
- vtkm
- docker
- linux
extends:
- .ubuntu1804
- .cmake_test_linux
dependencies:
- build:ubuntu1804_clang8
needs:
- build:ubuntu1804_clang8

@ -32,14 +32,14 @@ Before you begin, perform initial setup:
This will prompt for your GitLab user name and configure a remote
called `gitlab` to refer to it.
5. (Optional but highly recommended.)
5. (Optional but highly recommended.)
[Register with the VTK-m dashboard] on Kitware's CDash instance to
better know how your code performs in regression tests. After
registering and signing in, click on "All Dashboards" link in the upper
left corner, scroll down and click "Subscribe to this project" on the
right of VTK-m.
6. (Optional but highly recommended.)
6. (Optional but highly recommended.)
[Sign up for the VTK-m mailing list] to communicate with other
developers and users.
@ -108,6 +108,9 @@ idea of the feature or fix to be developed given just the branch name.
This is required as VTK-m uses Git-LFS to efficiently support data
files.
4. If you are adding a new feature or making sigificant changes to API,
make sure to add a entry to `docs/changelog`. This allows release
notes to properly capture all relevant changes.
### Guidelines for Commit Messages ###
@ -203,7 +206,7 @@ will be filled out for you.
5. In the "**Description**" field provide a high-level description of the
change the topic makes and any relevant information about how to try
it.
it.
* Use `@username` syntax to draw attention of specific developers.
This syntax may be used anywhere outside literal text and code
blocks. Or, wait until the [next step](#review-a-merge-request)
@ -226,6 +229,10 @@ will be filled out for you.
6. The "**Assign to**", "**Milestone**", and "**Labels**" fields may be
left blank.
7. Enable the "**Allow commits from members who can merge to the target branch.**" option,
so that reviewers can modify the merge request. This allows reviewers to change
minor style issues without overwhelming the author with change requests.
7. Use the "**Submit merge request**" button to create the merge request
and visit its page.
@ -318,32 +325,49 @@ succeeds.
### Testing ###
VTK-m has a [buildbot](http://buildbot.net) instance watching for merge
requests to test. Each time a merge request is updated the buildbot user
(@buildbot) will automatically trigger a new build on all VTK-m buildbot
workers. The buildbot user (@buildbot) will respond with a comment linking
to the CDash results when it schedules builds.
Each time a merge request is created or updated automated testing
is automatically triggered, and shows up under the pipeline tab.
The buildbot user (@buildbot) will also respond to any comment with the
form:
Developers can track the status of the pipeline for a merge
request by using the Pipeline tab on a merge request or by
clicking on stage icons as shown below:
![alt text](docs/build_stage.png "Pipeline")
When trying to diagnose why a build or tests stage has failed it
generally is easier to look at the pruned information reported
on [VTK-m's CDash Dashboard](https://open.cdash.org/index.php?project=VTKM).
To make it easier to see only the results for a given merge request
you can click the `cdash` link under the external stage ( rightmost pipeline stage icon )
![alt text](docs/external_stage.png "CDash Link")
In addition to the gitlab pipelines the buildbot user (@buildbot) will respond
with a comment linking to the CDash results when it schedules builds.
The builds for VTK-m that show up as part of the `external` stage of the
gitlab pipeline are driven via buildbot, and have a different workflow.
When you need to do things such as retry a build, you must issue commands
via comments of the following form. The buildbot user (@buildbot) will
respond signify that the command has been executed
Do: test
The `Do: test` command accepts the following arguments:
* `--oneshot`
* `--oneshot`
only build the *current* hash of the branch; updates will not be
built using this command
* `--stop`
* `--stop`
clear the list of commands for the merge request
* `--superbuild`
* `--superbuild`
build the superbuilds related to the project
* `--clear`
* `--clear`
clear previous commands before adding this command
* `--regex-include <arg>` or `-i <arg>`
* `--regex-include <arg>` or `-i <arg>`
only build on builders matching `<arg>` (a Python regular
expression)
* `--regex-exclude <arg>` or `-e <arg>`
* `--regex-exclude <arg>` or `-e <arg>`
excludes builds on builders matching `<arg>` (a Python regular
expression)
@ -451,7 +475,7 @@ will stop running so that you can make changes. Make the changes you need,
use `git add` to stage those changes, and then use
$ git rebase --continue
to have git continue the rebase process. You can always run `git status` to
get help about what to do next.

230
docs/CI-README.md Normal file

@ -0,0 +1,230 @@
Gitlab CI
===============
# High level view
1. Kitware Gitlab CI
- Why pipelines
- Gitlab runner tags
2. How to use docker builders locally
- Setting up docker
- Setting up nvidia runtime
- Running docker images
3. How to Add/Update Kitware Gitlab CI
- How to add a new builder
- How to add a new tester
- How to update an existing docker image
4. ECP OSTI CI
- Issues
# Kitware Gitlab CI
GitLab CI/CD allows for software development through continous integration, delivery, and deployment.
VTK-m uses continuous integration to verify every merge request, by running a pipeline of scripts to build, test,
the code changes across a wide range of hardware and configurations before merging them into master.
This workflow allow everyone to easily catch build failures, bugs, and errors before VTK-m is deployed in a
production enviornment. Making sure VTK-m is a robust library provides not only confidence to our users
but to every VTK-m developer. When the system is working developers can be confident that failures
seen during CI are related to the specific changes they have made.
GitLab CI/CD is configured by a file called `.gitlab-ci.yml` located at the root of the VTK-m repository.
The scripts set in this file are executed by the [GitLab Runners](https://docs.gitlab.com/runner/) associated with VTK-m.
## Why pipelines
Pipelines are the top-level component of continuous integration. For VTK-m the pipeline contains build and test stages, with the possibilty of adding subsequent stages such as coverage, or memory checking.
Decomposing the build and test into separate components comes with some significant benifits for VTK-m developers.
The most impactful change is that we now have the ability to compile VTK-m on dedicated 'compilation' machines and
test on machines with less memory or an older CPU improving turnaround time. Additionally since we are heavily
leveraging docker, VTK-m build stages can be better load balanced across the set of builders as we don't have
a tight coupling between a machine and build configuration.
## Gitlab runner tags
Current gitlab runner tags for VTK-m are:
- build
Signifies that this is will be doing compilation
- test
Signifies that this is will be running tests
- vtkm
Allows us to make sure VTK-m ci is only run on VTK-m allocated hardware
- docker
Used to state that the gitlab-runner must support docker based ci
- linux
Used to state that we require a linux based gitlab-runner
- large-memory
Used to state that this step will require a machine that has lots of memory.
This is currently used for cuda `build` requests
- cuda-rt
Used to state that the runner is required to have the cuda runtime enviornment.
This isn't required to `build` VTK-m, only `test`
- maxwell
- pascal
- turing
Only used on a `test` stage to signifiy which GPU hardware is required to
run the VTK-m tests
# How to use docker builders locally
## Setting up docker
## Setting up nvidia runtime
## Running docker images
# How to Add/Update Kitware Gitlab CI
Adding new build or test stages is necessary when a given combination of compiler, platform,
and VTK-m options isn't already captured by existing builders. Each definition is composed via 3 components; tags, variables, and extends.
Tags are used to by gitlab-ci to match a given build to a set of possible execution locations.
Therefore we encode information such as we require docker or the linux kernel into tags.
The full set of VTK-m tags each meaning are found under the `runner tags` section of the document.
Extends is used to compose the execution enviornment of the builder. Basically this means
setting up the correct build/test enviornment and specifying the CMake scripts that need
to be executed. So a linux docker based builder would extend the docker image they want,
plus `.cmake_build_linux`. A MacOS builder would extend `.cmake_build_macos`.
Variables control stage specific information such as runtime enviornment variables,
or VTK-m CMake options.
## How to add a new builder
Each builder definition is placed inside the respective OS `yml` file located in
`.gitlab/ci/`. Therefore if you are adding a builder that will run on Ubuntu 20.04 it
would go into `.gitlab/ci/ubuntu2004.yml`.
Variables are used to control the following components:
- Compiler
- VTK-m CMake Options
- Static / Shared
- Release / Debug / MinSizeRel
An example defitinon of a builder would look like:
```yml
build:ubuntu2004_$<compiler>:
tags:
- build
- vtkm
- docker
- linux
extends:
- .ubuntu2004
- .cmake_build_linux
variables:
CC: "$<c-compiler-command>"
CXX: "$<cxx-compiler-command>"
CMAKE_BUILD_TYPE: "Debug|Release|MinSizeRel"
VTKM_SETTINGS: "tbb+openmp+mpi"
```
If this builder requires a new docker image a coupe of extra steps are required
1. Add the docker image to the proper folder under `.gitlab/ci/docker`. Images
are laid out with the primary folder being the OS and the secondary folder the
primary device adapter it adds. We currently consider `openmp` and `tbb` to
be small enough to be part of any image.
2. Make sure image is part of the `update_all.sh` script, following the convention
of `platform_device`.
3. Update the `.gitlab-ci.yml` comments to list what compiler(s), device adapters,
and other relevant libraries the image has.
4. Verify the image is part of the `.gitlab-ci.yml` file and uses the docker image
pattern, as seen below. This is important as `.docker_image` makes sure we
have consistent paths across all builds to allow us to cache compilation object
files.
```yml
.$<platform>_$<device>: &$<platform>_$<device>
image: "kitware/vtkm:ci-$<platform>_$<device>-$<YYYYMMDD>"
extends:
- .docker_image
```
## How to add a new tester
Each test definition is placed inside the respective OS `yml` file located in
`.gitlab/ci/`. Therefore if you are adding a builder that will run on Ubuntu 20.04 it
would go into `.gitlab/ci/ubuntu2004.yml`.
The primary difference between tests and build definitions are that tests have
the dependencies and needs sections. These are required as by default
gitlab-ci will not run any test stage before ALL the build stages have
completed.
Variables for testers are currently only used for the following things:
- Allowing OpenMPI to run as root
An example defitinon of a tester would look like:
```yml
test:ubuntu2004_$<compiler>:
tags:
- test
- cuda-rt
- turing
- vtkm
- docker
- linux
extends:
- .ubuntu2004_cuda
- .cmake_test_linux
dependencies:
- build:ubuntu2004_$<compiler>
needs:
- build:ubuntu2004_$<compiler>
```
## How to update an existing docker image
Updating an image to be used for CI infrastructure can be done by anyone that
has permissions to the kitware/vtkm dockerhub project, as that is where
images are stored.
Each modification of the docker image requires a new name so that existing open
merge requests can safely trigger pipelines without inadverntly using the
updated images which might break their build.
Therefore the workflow to update images is
1. Start a new git branch
2. Update the associated `Dockerfile`
3. Locally build the docker image
4. Push the docker image to dockerhub
5. Open a Merge Request
To simplify step 3 and 4 of the process, VTK-m has a script (`update_all.sh`) that automates
these stages. This script is required to be run from the `.gitlab/ci/docker` directory, and
needs to have the date string passed to it. An example of running the script:
```sh
sudo docker login --username=<docker_hub_name>
cd .gitlab/ci/docker
sudo ./update_all.sh 20201230
```
# ECP OSTI CI
`.gitlab-ci-ecp.yml` allows for VTK-m to run CI on provided by ECP at NMC.
To have this work properly you will need to make sure that the gitlab repository
has been updated to this non-standard yaml file location
( "Settings" -> "CI/CD" -> "General pipelines" -> "Custom CI configuration path").
The ECP CI is setup to verify VTK-m mainly on Power9 hardware as that currently is
missing from VTK-m standard CI infrastructure.
Currently we verify Power9 support with `cuda` and `openmp` builders. The `cuda` builder
is setup to use the default cuda SDK on the machine and the required `c++` compiler which
currently is `gcc-4.8.5`. The `openmp` builder is setup to use the newest `c++` compiler provided
on the machine so that we maximimze compiler coverage.
## Issues
Currently these builders don't report back to the VTK-m CDash instance.

BIN
docs/build_stage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
docs/external_stage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

@ -147,8 +147,13 @@ set(sources_device
ClipWithField.cxx
ClipWithImplicitFunction.cxx
Contour.cxx
ContourInteger.cxx
ContourScalar.cxx
ExternalFaces.cxx
ExtractStructured.cxx
GradientScalar.cxx
GradientUniformPoints.cxx
GradientVector.cxx
PointAverage.cxx
Threshold.cxx
VectorMagnitude.cxx

@ -67,8 +67,5 @@ VTKM_FILTER_EXPORT vtkm::Float64 Contour::GetIsoValue(vtkm::Id index) const
{
return this->IsoValues[static_cast<std::size_t>(index)];
}
//-----------------------------------------------------------------------------
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(Contour);
}
}

@ -150,8 +150,56 @@ private:
vtkm::worklet::Contour Worklet;
};
#ifndef vtkm_filter_Contour_cxx
VTKM_FILTER_EXPORT_EXECUTE_METHOD(Contour);
#ifndef vtkm_filter_ContourExecute_cxx
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
#endif
}
} // namespace vtkm::filter

@ -0,0 +1,46 @@
//============================================================================
// 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_ContourExecute_cxx
#define vtk_m_filter_ContourExecute_cxx
#include <vtkm/filter/Contour.h>
namespace vtkm
{
namespace filter
{
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
}
}
#endif

@ -0,0 +1,46 @@
//============================================================================
// 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_ContourExecute_cxx
#define vtk_m_filter_ContourExecute_cxx
#include <vtkm/filter/Contour.h>
namespace vtkm
{
namespace filter
{
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
}
}
#endif

@ -11,6 +11,8 @@
#ifndef vtk_m_filter_Gradient_h
#define vtk_m_filter_Gradient_h
#include <vtkm/filter/vtkm_filter_export.h>
#include <vtkm/filter/FilterCell.h>
namespace vtkm
@ -91,7 +93,7 @@ public:
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
vtkm::filter::PolicyBase<DerivedPolicy> policy);
private:
bool ComputePointGradient = false;
@ -106,6 +108,64 @@ private:
std::string QCriterionName = "QCriterion";
std::string VorticityName = "Vorticity";
};
#ifndef vtkm_filter_Gradient_cxx
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
#endif
}
} // namespace vtkm::filter

@ -45,7 +45,7 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
const vtkm::filter::FieldMetadata& fieldMetadata,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
if (!fieldMetadata.IsPointField())
{

@ -0,0 +1,46 @@
//============================================================================
// 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_cxx
#define vtk_m_filter_Gradient_cxx
#include <vtkm/filter/Gradient.h>
namespace vtkm
{
namespace filter
{
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
}
}
#endif

@ -0,0 +1,28 @@
//============================================================================
// 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_cxx
#define vtk_m_filter_Gradient_cxx
#include <vtkm/filter/Gradient.h>
namespace vtkm
{
namespace filter
{
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
}
}
#endif

@ -0,0 +1,46 @@
//============================================================================
// 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_cxx
#define vtk_m_filter_Gradient_cxx
#include <vtkm/filter/Gradient.h>
namespace vtkm
{
namespace filter
{
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagVirtual>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
}
}
#endif

@ -16,6 +16,8 @@ set(unit_tests
UnitTestClipWithFieldFilter.cxx
UnitTestClipWithImplicitFunctionFilter.cxx
UnitTestContourFilter.cxx
UnitTestContourFilterCustomPolicy.cxx
UnitTestContourFilterNormals.cxx
UnitTestContourTreeUniformFilter.cxx
UnitTestContourTreeUniformAugmentedFilter.cxx
UnitTestCoordinateSystemTransform.cxx
@ -29,7 +31,8 @@ set(unit_tests
UnitTestFieldMetadata.cxx
UnitTestFieldSelection.cxx
UnitTestFieldToColors.cxx
UnitTestGradient.cxx
UnitTestGradientExplicit.cxx
UnitTestGradientUniform.cxx
UnitTestGhostCellClassify.cxx
UnitTestGhostCellRemove.cxx
UnitTestHistogramFilter.cxx

@ -9,8 +9,6 @@
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
@ -18,168 +16,10 @@
#include <vtkm/filter/CleanGrid.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/filter/Contour.hxx>
#include <vtkm/source/Tangle.h>
namespace vtkm_ut_mc_filter
{
class EuclideanNorm
{
public:
VTKM_EXEC_CONT
EuclideanNorm()
: Reference(0., 0., 0.)
{
}
VTKM_EXEC_CONT
EuclideanNorm(vtkm::Vec3f_32 reference)
: Reference(reference)
{
}
VTKM_EXEC_CONT
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
{
vtkm::Vec3f_32 d(
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
return vtkm::Magnitude(d);
}
private:
vtkm::Vec3f_32 Reference;
};
class CubeGridConnectivity
{
public:
VTKM_EXEC_CONT
CubeGridConnectivity()
: Dimension(1)
, DimSquared(1)
, DimPlus1Squared(4)
{
}
VTKM_EXEC_CONT
CubeGridConnectivity(vtkm::Id dim)
: Dimension(dim)
, DimSquared(dim * dim)
, DimPlus1Squared((dim + 1) * (dim + 1))
{
}
VTKM_EXEC_CONT
vtkm::Id operator()(vtkm::Id vertex) const
{
using HexTag = vtkm::CellShapeTagHexahedron;
using HexTraits = vtkm::CellTraits<HexTag>;
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
vtkm::Id globalId =
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
switch (localId)
{
case 0:
break;
case 1:
globalId += 1;
break;
case 2:
globalId += this->Dimension + 2;
break;
case 3:
globalId += this->Dimension + 1;
break;
case 4:
globalId += this->DimPlus1Squared;
break;
case 5:
globalId += this->DimPlus1Squared + 1;
break;
case 6:
globalId += this->Dimension + this->DimPlus1Squared + 2;
break;
case 7:
globalId += this->Dimension + this->DimPlus1Squared + 1;
break;
}
return globalId;
}
private:
vtkm::Id Dimension;
vtkm::Id DimSquared;
vtkm::Id DimPlus1Squared;
};
class MakeRadiantDataSet
{
public:
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
using DataArrayHandle =
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
using ConnectivityArrayHandle =
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
CubeGridConnectivity>;
using CellSet = vtkm::cont::CellSetSingleType<
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
CubeGridConnectivity>::StorageTag>;
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
};
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
{
public:
using TypeListRadiantCellSetTypes = vtkm::List<MakeRadiantDataSet::CellSet>;
using AllCellSetList = TypeListRadiantCellSetTypes;
};
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
{
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
// axis, with point values equal to the Euclidean distance from the origin.
vtkm::cont::DataSet dataSet;
using HexTag = vtkm::CellShapeTagHexahedron;
using HexTraits = vtkm::CellTraits<HexTag>;
using CoordType = vtkm::Vec3f_32;
const vtkm::IdComponent nCells = dim * dim * dim;
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
CoordType(-.5, -.5, -.5),
CoordType(spacing, spacing, spacing));
DataArrayHandle distanceToOrigin(coordinates);
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
ConnectivityArrayHandle connectivity(
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
CubeGridConnectivity(dim));
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
//Set point scalar
dataSet.AddField(vtkm::cont::Field(
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
dataSet.AddField(
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
CellSet cellSet;
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
dataSet.SetCellSet(cellSet);
return dataSet;
}
void TestContourUniformGrid()
{
@ -248,176 +88,9 @@ void TestContourUniformGrid()
}
}
void TestContourCustomPolicy()
{
std::cout << "Testing Contour filter with custom field and cellset" << std::endl;
using DataSetGenerator = MakeRadiantDataSet;
DataSetGenerator dataSetGenerator;
const vtkm::IdComponent Dimension = 10;
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
vtkm::filter::Contour mc;
mc.SetGenerateNormals(false);
mc.SetIsoValue(0, 0.45);
mc.SetIsoValue(1, 0.45);
mc.SetIsoValue(2, 0.45);
mc.SetIsoValue(3, 0.45);
//We specify a custom execution policy here, since the "distanceToOrigin" is a
//custom field type
mc.SetActiveField("distanceToOrigin");
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset");
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == (414 * 4), "Should have some coordinates");
}
vtkm::cont::DataSet MakeNormalsTestDataSet()
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::Id3 dimensions(3, 4, 4);
vtkm::cont::DataSet dataSet = dsb.Create(dimensions);
vtkm::cont::DataSetFieldAdd dsf;
const int nVerts = 48;
vtkm::Float32 vars[nVerts] = { 60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f,
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f };
//Set point and cell scalar
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
return dataSet;
}
void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
{
const vtkm::Id numVerts = 16;
//Calculated using PointGradient
const vtkm::Vec3f hq_ug[numVerts] = {
{ 0.1510f, 0.6268f, 0.7644f }, { 0.1333f, -0.3974f, 0.9079f },
{ 0.1626f, 0.7642f, 0.6242f }, { 0.3853f, 0.6643f, 0.6405f },
{ -0.1337f, 0.7136f, 0.6876f }, { 0.7705f, -0.4212f, 0.4784f },
{ -0.7360f, -0.4452f, 0.5099f }, { 0.1234f, -0.8871f, 0.4448f },
{ 0.1626f, 0.7642f, -0.6242f }, { 0.3853f, 0.6643f, -0.6405f },
{ -0.1337f, 0.7136f, -0.6876f }, { 0.1510f, 0.6268f, -0.7644f },
{ 0.7705f, -0.4212f, -0.4784f }, { -0.7360f, -0.4452f, -0.5099f },
{ 0.1234f, -0.8871f, -0.4448f }, { 0.1333f, -0.3974f, -0.9079f }
};
//Calculated using StructuredPointGradient
const vtkm::Vec3f hq_sg[numVerts] = {
{ 0.151008f, 0.626778f, 0.764425f }, { 0.133328f, -0.397444f, 0.907889f },
{ 0.162649f, 0.764163f, 0.624180f }, { 0.385327f, 0.664323f, 0.640467f },
{ -0.133720f, 0.713645f, 0.687626f }, { 0.770536f, -0.421248f, 0.478356f },
{ -0.736036f, -0.445244f, 0.509910f }, { 0.123446f, -0.887088f, 0.444788f },
{ 0.162649f, 0.764163f, -0.624180f }, { 0.385327f, 0.664323f, -0.640467f },
{ -0.133720f, 0.713645f, -0.687626f }, { 0.151008f, 0.626778f, -0.764425f },
{ 0.770536f, -0.421248f, -0.478356f }, { -0.736036f, -0.445244f, -0.509910f },
{ 0.123446f, -0.887088f, -0.444788f }, { 0.133328f, -0.397444f, -0.907889f }
};
//Calculated using normals of the output triangles
const vtkm::Vec3f fast[numVerts] = {
{ -0.1351f, 0.4377f, 0.8889f }, { 0.2863f, -0.1721f, 0.9426f },
{ 0.3629f, 0.8155f, 0.4509f }, { 0.8486f, 0.3560f, 0.3914f },
{ -0.8315f, 0.4727f, 0.2917f }, { 0.9395f, -0.2530f, 0.2311f },
{ -0.9105f, -0.0298f, 0.4124f }, { -0.1078f, -0.9585f, 0.2637f },
{ -0.2538f, 0.8534f, -0.4553f }, { 0.8953f, 0.3902f, -0.2149f },
{ -0.8295f, 0.4188f, -0.3694f }, { 0.2434f, 0.4297f, -0.8695f },
{ 0.8951f, -0.1347f, -0.4251f }, { -0.8467f, -0.4258f, -0.3191f },
{ 0.2164f, -0.9401f, -0.2635f }, { -0.1589f, -0.1642f, -0.9735f }
};
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
vtkm::filter::Contour mc;
mc.SetIsoValue(0, 200);
mc.SetGenerateNormals(true);
// Test default normals generation: high quality for structured, fast for unstructured.
auto expected = structured ? hq_sg : fast;
mc.SetActiveField("pointvar");
auto result = mc.Execute(dataset);
result.GetField("normals").GetData().CopyTo(normals);
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
"Wrong number of values in normals field");
for (vtkm::Id i = 0; i < numVerts; ++i)
{
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
"Result (",
normals.ReadPortal().Get(i),
") does not match expected value (",
expected[i],
") vert ",
i);
}
// Test the other normals generation method
if (structured)
{
mc.SetComputeFastNormalsForStructured(true);
expected = fast;
}
else
{
mc.SetComputeFastNormalsForUnstructured(false);
expected = hq_ug;
}
result = mc.Execute(dataset);
result.GetField("normals").GetData().CopyTo(normals);
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
"Wrong number of values in normals field");
for (vtkm::Id i = 0; i < numVerts; ++i)
{
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
"Result does not match expected values");
}
}
void TestContourNormals()
{
std::cout << "Testing Contour normals generation" << std::endl;
std::cout << "\tStructured dataset\n";
vtkm::cont::DataSet dataset = MakeNormalsTestDataSet();
TestNormals(dataset, true);
std::cout << "\tUnstructured dataset\n";
vtkm::filter::CleanGrid makeUnstructured;
makeUnstructured.SetCompactPointFields(false);
makeUnstructured.SetMergePoints(false);
makeUnstructured.SetFieldsToPass("pointvar");
auto result = makeUnstructured.Execute(dataset);
TestNormals(result, false);
}
void TestContourFilter()
{
TestContourUniformGrid();
TestContourCustomPolicy();
TestContourNormals();
}
} // anonymous namespace
} // namespace
int UnitTestContourFilter(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_filter::TestContourFilter, argc, argv);
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_filter::TestContourUniformGrid, argc, argv);
}

@ -0,0 +1,218 @@
//============================================================================
// 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/Math.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/filter/Contour.hxx>
namespace vtkm_ut_mc_policy
{
class EuclideanNorm
{
public:
VTKM_EXEC_CONT
EuclideanNorm()
: Reference(0., 0., 0.)
{
}
VTKM_EXEC_CONT
EuclideanNorm(vtkm::Vec3f_32 reference)
: Reference(reference)
{
}
VTKM_EXEC_CONT
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
{
vtkm::Vec3f_32 d(
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
return vtkm::Magnitude(d);
}
private:
vtkm::Vec3f_32 Reference;
};
class CubeGridConnectivity
{
public:
VTKM_EXEC_CONT
CubeGridConnectivity()
: Dimension(1)
, DimSquared(1)
, DimPlus1Squared(4)
{
}
VTKM_EXEC_CONT
CubeGridConnectivity(vtkm::Id dim)
: Dimension(dim)
, DimSquared(dim * dim)
, DimPlus1Squared((dim + 1) * (dim + 1))
{
}
VTKM_EXEC_CONT
vtkm::Id operator()(vtkm::Id vertex) const
{
using HexTag = vtkm::CellShapeTagHexahedron;
using HexTraits = vtkm::CellTraits<HexTag>;
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
vtkm::Id globalId =
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
switch (localId)
{
case 0:
break;
case 1:
globalId += 1;
break;
case 2:
globalId += this->Dimension + 2;
break;
case 3:
globalId += this->Dimension + 1;
break;
case 4:
globalId += this->DimPlus1Squared;
break;
case 5:
globalId += this->DimPlus1Squared + 1;
break;
case 6:
globalId += this->Dimension + this->DimPlus1Squared + 2;
break;
case 7:
globalId += this->Dimension + this->DimPlus1Squared + 1;
break;
}
return globalId;
}
private:
vtkm::Id Dimension;
vtkm::Id DimSquared;
vtkm::Id DimPlus1Squared;
};
class MakeRadiantDataSet
{
public:
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
using DataArrayHandle =
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
using ConnectivityArrayHandle =
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
CubeGridConnectivity>;
using CellSet = vtkm::cont::CellSetSingleType<
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
CubeGridConnectivity>::StorageTag>;
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
};
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
{
public:
using TypeListRadiantCellSetTypes = vtkm::List<MakeRadiantDataSet::CellSet>;
using AllCellSetList = TypeListRadiantCellSetTypes;
};
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
{
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
// axis, with point values equal to the Euclidean distance from the origin.
vtkm::cont::DataSet dataSet;
using HexTag = vtkm::CellShapeTagHexahedron;
using HexTraits = vtkm::CellTraits<HexTag>;
using CoordType = vtkm::Vec3f_32;
const vtkm::IdComponent nCells = dim * dim * dim;
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
CoordType(-.5, -.5, -.5),
CoordType(spacing, spacing, spacing));
DataArrayHandle distanceToOrigin(coordinates);
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
ConnectivityArrayHandle connectivity(
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
CubeGridConnectivity(dim));
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
//Set point scalar
dataSet.AddField(vtkm::cont::Field(
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
dataSet.AddField(
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
CellSet cellSet;
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
dataSet.SetCellSet(cellSet);
return dataSet;
}
void TestContourCustomPolicy()
{
std::cout << "Testing Contour filter with custom field and cellset" << std::endl;
using DataSetGenerator = MakeRadiantDataSet;
DataSetGenerator dataSetGenerator;
const vtkm::IdComponent Dimension = 10;
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
vtkm::filter::Contour mc;
mc.SetGenerateNormals(false);
mc.SetIsoValue(0, 0.45);
mc.SetIsoValue(1, 0.45);
mc.SetIsoValue(2, 0.45);
mc.SetIsoValue(3, 0.45);
//We specify a custom execution policy here, since the "distanceToOrigin" is a
//custom field type
mc.SetActiveField("distanceToOrigin");
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset");
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == (414 * 4), "Should have some coordinates");
}
} // namespace
int UnitTestContourFilterCustomPolicy(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_policy::TestContourCustomPolicy, argc, argv);
}

@ -0,0 +1,156 @@
//============================================================================
// 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/Math.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/CleanGrid.h>
#include <vtkm/filter/Contour.h>
namespace vtkm_ut_mc_normals
{
vtkm::cont::DataSet MakeNormalsTestDataSet()
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::Id3 dimensions(3, 4, 4);
vtkm::cont::DataSet dataSet = dsb.Create(dimensions);
vtkm::cont::DataSetFieldAdd dsf;
const int nVerts = 48;
vtkm::Float32 vars[nVerts] = { 60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f,
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f };
//Set point and cell scalar
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
return dataSet;
}
void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
{
const vtkm::Id numVerts = 16;
//Calculated using PointGradient
const vtkm::Vec3f hq_ug[numVerts] = {
{ 0.1510f, 0.6268f, 0.7644f }, { 0.1333f, -0.3974f, 0.9079f },
{ 0.1626f, 0.7642f, 0.6242f }, { 0.3853f, 0.6643f, 0.6405f },
{ -0.1337f, 0.7136f, 0.6876f }, { 0.7705f, -0.4212f, 0.4784f },
{ -0.7360f, -0.4452f, 0.5099f }, { 0.1234f, -0.8871f, 0.4448f },
{ 0.1626f, 0.7642f, -0.6242f }, { 0.3853f, 0.6643f, -0.6405f },
{ -0.1337f, 0.7136f, -0.6876f }, { 0.1510f, 0.6268f, -0.7644f },
{ 0.7705f, -0.4212f, -0.4784f }, { -0.7360f, -0.4452f, -0.5099f },
{ 0.1234f, -0.8871f, -0.4448f }, { 0.1333f, -0.3974f, -0.9079f }
};
//Calculated using StructuredPointGradient
const vtkm::Vec3f hq_sg[numVerts] = {
{ 0.151008f, 0.626778f, 0.764425f }, { 0.133328f, -0.397444f, 0.907889f },
{ 0.162649f, 0.764163f, 0.624180f }, { 0.385327f, 0.664323f, 0.640467f },
{ -0.133720f, 0.713645f, 0.687626f }, { 0.770536f, -0.421248f, 0.478356f },
{ -0.736036f, -0.445244f, 0.509910f }, { 0.123446f, -0.887088f, 0.444788f },
{ 0.162649f, 0.764163f, -0.624180f }, { 0.385327f, 0.664323f, -0.640467f },
{ -0.133720f, 0.713645f, -0.687626f }, { 0.151008f, 0.626778f, -0.764425f },
{ 0.770536f, -0.421248f, -0.478356f }, { -0.736036f, -0.445244f, -0.509910f },
{ 0.123446f, -0.887088f, -0.444788f }, { 0.133328f, -0.397444f, -0.907889f }
};
//Calculated using normals of the output triangles
const vtkm::Vec3f fast[numVerts] = {
{ -0.1351f, 0.4377f, 0.8889f }, { 0.2863f, -0.1721f, 0.9426f },
{ 0.3629f, 0.8155f, 0.4509f }, { 0.8486f, 0.3560f, 0.3914f },
{ -0.8315f, 0.4727f, 0.2917f }, { 0.9395f, -0.2530f, 0.2311f },
{ -0.9105f, -0.0298f, 0.4124f }, { -0.1078f, -0.9585f, 0.2637f },
{ -0.2538f, 0.8534f, -0.4553f }, { 0.8953f, 0.3902f, -0.2149f },
{ -0.8295f, 0.4188f, -0.3694f }, { 0.2434f, 0.4297f, -0.8695f },
{ 0.8951f, -0.1347f, -0.4251f }, { -0.8467f, -0.4258f, -0.3191f },
{ 0.2164f, -0.9401f, -0.2635f }, { -0.1589f, -0.1642f, -0.9735f }
};
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
vtkm::filter::Contour mc;
mc.SetIsoValue(0, 200);
mc.SetGenerateNormals(true);
// Test default normals generation: high quality for structured, fast for unstructured.
auto expected = structured ? hq_sg : fast;
mc.SetActiveField("pointvar");
auto result = mc.Execute(dataset);
result.GetField("normals").GetData().CopyTo(normals);
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
"Wrong number of values in normals field");
for (vtkm::Id i = 0; i < numVerts; ++i)
{
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
"Result (",
normals.ReadPortal().Get(i),
") does not match expected value (",
expected[i],
") vert ",
i);
}
// Test the other normals generation method
if (structured)
{
mc.SetComputeFastNormalsForStructured(true);
expected = fast;
}
else
{
mc.SetComputeFastNormalsForUnstructured(false);
expected = hq_ug;
}
result = mc.Execute(dataset);
result.GetField("normals").GetData().CopyTo(normals);
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
"Wrong number of values in normals field");
for (vtkm::Id i = 0; i < numVerts; ++i)
{
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
"Result does not match expected values");
}
}
void TestContourNormals()
{
std::cout << "Testing Contour normals generation" << std::endl;
std::cout << "\tStructured dataset\n";
vtkm::cont::DataSet dataset = MakeNormalsTestDataSet();
TestNormals(dataset, true);
std::cout << "\tUnstructured dataset\n";
vtkm::filter::CleanGrid makeUnstructured;
makeUnstructured.SetCompactPointFields(false);
makeUnstructured.SetMergePoints(false);
makeUnstructured.SetFieldsToPass("pointvar");
auto result = makeUnstructured.Execute(dataset);
TestNormals(result, false);
}
} // namespace
int UnitTestContourFilterNormals(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_normals::TestContourNormals, argc, argv);
}

@ -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.
//============================================================================
#include <vtkm/filter/Gradient.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
namespace
{
void TestCellGradientExplicit()
{
std::cout << "Testing Gradient Filter with cell output on Explicit data" << std::endl;
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
vtkm::filter::Gradient gradient;
gradient.SetOutputFieldName("gradient");
gradient.SetActiveField("pointvar");
vtkm::cont::DataSet result = gradient.Execute(dataSet);
VTKM_TEST_ASSERT(result.HasCellField("gradient"), "Result field missing.");
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
result.GetCellField("gradient").GetData().CopyTo(resultArrayHandle);
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
for (int i = 0; i < 2; ++i)
{
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
"Wrong result for CellGradient filter on 3D explicit data");
}
}
void TestPointGradientExplicit()
{
std::cout << "Testing Gradient Filter with point output on Explicit data" << std::endl;
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
vtkm::filter::Gradient gradient;
gradient.SetComputePointGradient(true);
gradient.SetOutputFieldName("gradient");
gradient.SetActiveField("pointvar");
vtkm::cont::DataSet result = gradient.Execute(dataSet);
VTKM_TEST_ASSERT(result.HasPointField("gradient"), "Result field missing.");
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
result.GetPointField("gradient").GetData().CopyTo(resultArrayHandle);
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, 0.0f } };
for (int i = 0; i < 2; ++i)
{
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
"Wrong result for CellGradient filter on 3D explicit data");
}
}
void TestGradient()
{
TestCellGradientExplicit();
TestPointGradientExplicit();
}
}
int UnitTestGradientExplicit(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestGradient, argc, argv);
}

@ -101,30 +101,6 @@ void TestCellGradientUniform3DWithVectorField()
}
}
void TestCellGradientExplicit()
{
std::cout << "Testing Gradient Filter with cell output on Explicit data" << std::endl;
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
vtkm::filter::Gradient gradient;
gradient.SetOutputFieldName("gradient");
gradient.SetActiveField("pointvar");
vtkm::cont::DataSet result = gradient.Execute(dataSet);
VTKM_TEST_ASSERT(result.HasCellField("gradient"), "Result field missing.");
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
result.GetCellField("gradient").GetData().CopyTo(resultArrayHandle);
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
for (int i = 0; i < 2; ++i)
{
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
"Wrong result for CellGradient filter on 3D explicit data");
}
}
void TestPointGradientUniform3DWithVectorField()
{
@ -176,45 +152,17 @@ void TestPointGradientUniform3DWithVectorField()
}
}
void TestPointGradientExplicit()
{
std::cout << "Testing Gradient Filter with point output on Explicit data" << std::endl;
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
vtkm::filter::Gradient gradient;
gradient.SetComputePointGradient(true);
gradient.SetOutputFieldName("gradient");
gradient.SetActiveField("pointvar");
vtkm::cont::DataSet result = gradient.Execute(dataSet);
VTKM_TEST_ASSERT(result.HasPointField("gradient"), "Result field missing.");
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
result.GetPointField("gradient").GetData().CopyTo(resultArrayHandle);
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, 0.0f } };
for (int i = 0; i < 2; ++i)
{
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
"Wrong result for CellGradient filter on 3D explicit data");
}
}
void TestGradient()
{
TestCellGradientUniform3D();
TestCellGradientUniform3DWithVectorField();
TestCellGradientExplicit();
TestPointGradientUniform3DWithVectorField();
TestPointGradientExplicit();
}
}
int UnitTestGradient(int argc, char* argv[])
int UnitTestGradientUniform(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestGradient, argc, argv);
}