...
 
Commits (1246)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -12,3 +12,6 @@ __pycache__/
# Exclude some Xcode stuff.
xcuserdata
project.xcworkspace
# Exclude VSCode settings and configuration folder
*.vscode*
......@@ -20,78 +20,89 @@ include(module.cmake)
vtk_module_dep_includes(vtkVTKm)
list(APPEND CMAKE_MODULE_PATH "${VTK_SOURCE_DIR}/ThirdParty/vtkm/vtk-m/CMake")
if(VTKm_ENABLE_TBB)
vtkm_configure_component_TBB()
endif()
if(VTKm_ENABLE_CUDA)
vtkm_configure_component_CUDA()
endif()
set(lib_srcs
vtkmlib/PolyDataConverter.cxx
vtkmlib/UnstructuredGridConverter.cxx
vtkmlib/ArrayConverters.cxx
vtkmlib/CellSetConverters.cxx
vtkmlib/DataSetConverters.cxx
vtkmlib/ImageDataConverter.cxx
vtkmlib/Storage.cxx
)
#needed to properly setup language wrappers
set(headers
vtkmAverageToCells.h
vtkmAverageToPoints.h
vtkmCleanGrid.h
vtkmClip.h
vtkmContour.h
vtkmExternalFaces.h
vtkmExtractVOI.h
vtkmThreshold.h
vtkmLevelOfDetail.h
vtkmAverageToCells.h
vtkmGradient.h
vtkmHistogram.h
vtkmLevelOfDetail.h
vtkmNDHistogram.h
vtkmPointElevation.h
vtkmPolyDataNormals.h
vtkmProbe.h
vtkmThreshold.h
vtkmTriangleMeshPointNormals.h
vtkmWarpScalar.h
vtkmWarpVector.h
)
#implementation of the algorithms for cpu accelerators
set(cpu_accelerator_srcs
vtkmAverageToCells.cxx
vtkmAverageToPoints.cxx
vtkmCellSetExplicit.cxx
vtkmCellSetSingleType.cxx
vtkmCleanGrid.cxx
vtkmClip.cxx
vtkmConnectivityExec.cxx
vtkmContour.cxx
vtkmExternalFaces.cxx
vtkmExtractVOI.cxx
vtkmThreshold.cxx
vtkmLevelOfDetail.cxx
vtkmAverageToCells.cxx
vtkmCellSetExplicit.cxx
vtkmCellSetSingleType.cxx
vtkmConnectivityExec.cxx
vtkmGradient.cxx
vtkmHistogram.cxx
vtkmLevelOfDetail.cxx
vtkmNDHistogram.cxx
vtkmPointElevation.cxx
vtkmPolyDataNormals.cxx
vtkmProbe.cxx
vtkmThreshold.cxx
vtkmTriangleMeshPointNormals.cxx
vtkmWarpScalar.cxx
vtkmWarpVector.cxx
vtkmlib/DataSetConverters.cxx
vtkmlib/Portals.cxx
vtkmlib/ImplicitFunctionConverter.cxx
)
#implementation of the algorithms for gpu accelerators
set(cuda_accelerator_srcs
vtkmAverageToCells.cu
vtkmAverageToPoints.cu
vtkmCellSetExplicit.cu
vtkmCellSetSingleType.cu
vtkmCleanGrid.cu
vtkmClip.cu
vtkmConnectivityExec.cu
vtkmContour.cu
vtkmExternalFaces.cu
vtkmExtractVOI.cu
vtkmThreshold.cu
vtkmLevelOfDetail.cu
vtkmAverageToCells.cu
vtkmCellSetExplicit.cu
vtkmCellSetSingleType.cu
vtkmConnectivityExec.cu
vtkmGradient.cu
vtkmHistogram.cu
vtkmLevelOfDetail.cu
vtkmNDHistogram.cu
vtkmPointElevation.cu
vtkmPolyDataNormals.cu
vtkmProbe.cu
vtkmThreshold.cu
vtkmTriangleMeshPointNormals.cu
vtkmWarpScalar.cu
vtkmWarpVector.cu
vtkmlib/DataSetConverters.cu
vtkmlib/Portals.cu
vtkmlib/ImplicitFunctionConverter.cu
)
......@@ -142,103 +153,47 @@ if(vtkm_pool_size EQUAL 0)
endif()
set_property(GLOBAL APPEND PROPERTY JOB_POOLS vtkm_pool=${vtkm_pool_size})
#we are building with CUDA support
if(VTKm_ENABLE_CUDA)
#need to find cudadevrt
find_library(CUDA_cudadevrt_LIBRARY cudadevrt
PATHS ${CUDA_TOOLKIT_TARGET_DIR}
PATH_SUFFIXES "x64" "lib64" "libx64"
)
if(TARGET vtkm::cuda)
#we are building with CUDA support
cmake_minimum_required(VERSION 3.9...3.12 FATAL_ERROR)
enable_language(CUDA)
########
## cache and clear the CUDA_NVCC_FLAGS so that they aren't passed to
## the linker. FINDCUDA has some problems properly unquoting CUDA_NVCC_FLAGS
## when "generate-code arch..." is used, so we instead patch the options
##
########
set(compile_options)
foreach(f ${CUDA_NVCC_FLAGS})
if(f MATCHES "generate-code ")
string(REPLACE "generate-code " "generate-code=" f "${f}")
endif()
list(APPEND compile_options ${f})
endforeach()
if(BUILD_SHARED_LIBS AND NOT WIN32)
list(APPEND compile_options -Xcompiler=${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden)
list(APPEND compile_options -Xcompiler=-fPIC)
#nvcc doesn't like the macros in VTK and generates hundreds of warnings
#that are false positives
list(APPEND compile_options --disable-warnings)
endif()
set(seperable_state ${CUDA_SEPARABLE_COMPILATION})
set(cache_flag_state ${CUDA_NVCC_FLAGS})
set(CUDA_NVCC_FLAGS "")
set(CUDA_SEPARABLE_COMPILATION ON)
#Some versions of VTK-m overload the CUDA_LIBRARIES to contain private
if(PRIVATE IN_LIST CUDA_LIBRARIES)
set(cache_cuda_libs ${CUDA_LIBRARIES})
set(cache_devrt_libs ${CUDA_cudadevrt_LIBRARY})
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${vtkAcceleratorsVTKm_DEPENDS})
set(CUDA_cudadevrt_LIBRARY PRIVATE ${CUDA_cudadevrt_LIBRARY})
# Workaround cmake issue #7519 which causes the c++11 flag set for VTK-m using
# target_compile_features to not work.
if (CMAKE_VERSION VERSION_LESS 3.11)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED True)
endif()
# CUDA doesn't obey usage requirements so we have to use
# CUDA_INCLUDE_DIRECTORIES, but do get the proper list of
# include dirs I need to query the module system, which
# doesn't exist currently, so we manually call vtk_module_impl
vtk_module_impl()
cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${VTKm_INCLUDE_DIRS}
${vtkAcceleratorsVTKm_DEPENDS_INCLUDE_DIRS})
get_target_property(arch_flags vtkm::cuda VTKm_CUDA_Architecture_Flags)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${arch_flags}")
cuda_add_library(vtkAcceleratorsVTKmCuda STATIC
${cuda_accelerator_srcs}
OPTIONS "${compile_options}"
)
# Temporarily suppress "has address taken but no possible call to it" warnings,
# until we figure out its implications.
# We are disabling all warnings as nvlink has no known way to suppress
# individual warning types.
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xnvlink -w")
set_target_properties(vtkAcceleratorsVTKmCuda
PROPERTIES POSITION_INDEPENDENT_CODE True
JOB_POOL_COMPILE vtkm_pool
)
vtk_module_library(vtkAcceleratorsVTKm
${headers}
${lib_srcs}
${cuda_accelerator_srcs}
)
target_link_libraries(vtkAcceleratorsVTKm
PRIVATE vtkAcceleratorsVTKmCuda ${cache_devrt_libs})
set(CUDA_SEPARABLE_COMPILATION ${seperable_state})
set(CUDA_NVCC_FLAGS_CACHE ${cache_flag_state})
if(cache_cuda_libs)
set(CUDA_LIBRARIES ${cache_cuda_libs})
set(CUDA_cudadevrt_LIBRARY ${CUDA_cudadevrt_LIBRARY})
endif()
set_target_properties(vtkAcceleratorsVTKm PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_compile_options(vtkAcceleratorsVTKm
PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe --diag_suppress=extra_semicolon>)
else()
vtk_module_library(vtkAcceleratorsVTKm
${headers}
${lib_srcs}
${cpu_accelerator_srcs}
)
set_property(TARGET vtkAcceleratorsVTKm PROPERTY JOB_POOL_COMPILE vtkm_pool)
endif()
target_link_libraries(vtkAcceleratorsVTKm PRIVATE vtkm_cont ${VTKm_LIBRARIES})
target_include_directories(vtkAcceleratorsVTKm PRIVATE ${VTKm_INCLUDE_DIRS})
set_property(TARGET vtkAcceleratorsVTKm PROPERTY JOB_POOL_COMPILE vtkm_pool)
target_link_libraries(vtkAcceleratorsVTKm PRIVATE vtkVTKm)
if (MSVC)
# MSVC has limits on obj size that are exceeded by this module so we need
# a flag to ignore those limits
target_compile_options(vtkAcceleratorsVTKm PRIVATE /bigobj)
#C4702 Generates numerous false positives with template code about
# unreachable code
#C4512 Generates numerous warning that implicit assignment operators can't
......@@ -257,6 +212,5 @@ if(NOT VTK_INSTALL_NO_DEVELOPMENT)
DESTINATION ${VTK_INSTALL_INCLUDE_DIR}
COMPONENT Development
FILES_MATCHING PATTERN "*.h*"
)
endif()
......@@ -2,17 +2,23 @@ vtk_add_test_cxx(vtkAcceleratorsVtkmCxxTests tests
TestVTKMCleanGrid.cxx
TestVTKMClip.cxx
TestVTKMClipWithImplicitFunction.cxx
TestVTKMGradient.cxx,NO_VALID
TestVTKMGradientAndVorticity.cxx,NO_VALID
TestVTKMExternalFaces.cxx
TestVTKMExtractVOI.cxx
TestVTKMGradient.cxx,NO_VALID
TestVTKMGradientAndVorticity.cxx,NO_VALID
TestVTKMHistogram.cxx,NO_VALID
TestVTKMLevelOfDetail.cxx
TestVTKMMarchingCubes.cxx
TestVTKMMarchingCubes2.cxx
TestVTKMNDHistogram.cxx,NO_VALID
TestVTKMPointElevation.cxx
TestVTKMProbe.cxx,NO_VALID
TestVTKMPolyDataNormals.cxx
TestVTKMThreshold.cxx
TestVTKMThreshold2.cxx
TestVTKMTriangleMeshPointNormals.cxx
TestVTKMWarpScalar.cxx
TestVTKMWarpVector.cxx
)
vtk_test_cxx_executable(vtkAcceleratorsVtkmCxxTests tests
RENDERING_FACTORY
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: TestVTKMClip.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 "vtkmNDHistogram.h"
#include "vtkActor.h"
#include "vtkArrayData.h"
#include "vtkCamera.h"
#include "vtkCellData.h"
#include "vtkDataSet.h"
#include "vtkDelaunay3D.h"
#include "vtkDoubleArray.h"
#include "vtkImageData.h"
#include "vtkImageToPoints.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkSparseArray.h"
#include "vtkTable.h"
namespace {
static const std::vector<std::string> arrayNames = {"temperature0", "temperature1",
"temperature2", "temperature3"};
static const std::vector<std::vector<size_t>> resultBins =
{{0, 0, 1, 1, 2, 2, 3, 3},
{0, 1, 1, 2, 2, 3, 3, 4},
{0, 1, 2, 2, 3, 4, 4, 5},
{0, 1, 2, 3, 3, 4, 5, 6},};
static const std::vector<size_t> resultFrequency = {2, 1, 1, 1, 1, 1, 1, 2};
static const int nData = 10;
static const std::vector<size_t> bins = {4,5,6,7};
void AddArrayToVTKData(std::string scalarName, vtkDataSetAttributes* pd,
double* data, vtkIdType size)
{
vtkNew<vtkDoubleArray> scalars;
scalars->SetArray(data, size, 1);
scalars->SetName(scalarName.c_str());
pd->AddArray(scalars);
}
void MakeTestDataset(vtkDataSet* dataset)
{
static double T0[nData], T1[nData], T2[nData], T3[nData];
for (int i = 0; i < nData; i++)
{
T0[i] = i * 1.0;
T1[i] = i * 2.0;
T2[i] = i * 3.0;
T3[i] = i * 4.0;
}
vtkPointData* pd = dataset->GetPointData();
AddArrayToVTKData(arrayNames[0], pd, T0, static_cast<vtkIdType>(nData));
AddArrayToVTKData(arrayNames[1], pd, T1, static_cast<vtkIdType>(nData));
AddArrayToVTKData(arrayNames[2], pd, T2, static_cast<vtkIdType>(nData));
AddArrayToVTKData(arrayNames[3], pd, T3, static_cast<vtkIdType>(nData));
}
}
int TestVTKMNDHistogram(int, char*[])
{
vtkNew<vtkPolyData> ds;
MakeTestDataset(ds);
vtkNew<vtkmNDHistogram> filter;
filter->SetInputData(ds);
size_t index = 0;
for (const auto& an: arrayNames)
{
filter->AddFieldAndBin(an, bins[index++]);
}
filter->Update();
vtkArrayData* arrayData = filter->GetOutput();
assert(arrayData != nullptr);
// Valid the data range and bin delta
for (vtkIdType i = 0; i < 4; i++)
{
// Validate the delta and range
auto range = filter->GetDataRange(i);
double delta = filter->GetBinDelta(i);
if (range.first != 0.0 || range.second != (i+1)* 9)
{
std::cout << "array index=" << i << " does not have right range" <<std::endl;
return 1;
}
if (delta != ((range.second - range.first) / bins[i]))
{
std::cout << "array index" << i << " does not have right delta" <<std::endl;
return 1;
}
}
vtkSparseArray<double>* sa = static_cast<vtkSparseArray<double>*>(arrayData->GetArray(0));
vtkArrayCoordinates coordinates;
const vtkIdType dimensions = sa->GetDimensions(); // 4
const vtkIdType non_null_size = sa->GetNonNullSize(); // 8
for(vtkIdType n = 0; n != non_null_size; ++n)
{
sa->GetCoordinatesN(n, coordinates);
for(vtkIdType d = 0; d != dimensions; ++d)
{
assert(coordinates[d] == static_cast<vtkIdType>(resultBins[d][n]));
if (coordinates[d] != static_cast<vtkIdType>(resultBins[d][n]))
{
std::cout << "value does not match at index " << n <<
" dimension " << d <<std::endl;
}
}
assert(resultFrequency[n] == sa->GetValue(coordinates));
}
return 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 2012 Sandia Corporation.
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
//=============================================================================
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkDataSetSurfaceFilter.h"
#include "vtkPlaneSource.h"
#include "vtkmPointElevation.h"
#include "vtkFloatArray.h"
#include "vtkImageData.h"
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPoints.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"