CMakeLists.txt 2.7 KB
Newer Older
1 2 3 4 5 6 7 8
##============================================================================
##  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.
##
9
##  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 11 12
##  Copyright 2014 UT-Battelle, LLC.
##  Copyright 2014 Los Alamos National Security.
##
13
##  Under the terms of Contract DE-NA0003525 with NTESS,
14 15 16 17 18 19
##  the U.S. Government retains certain rights in this software.
##
##  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
##  Laboratory (LANL), the U.S. Government retains certain rights in
##  this software.
##============================================================================
20
function(add_benchmark name files)
21 22
  set(benchmarks )

23
  add_executable(${name}_SERIAL ${files})
24
  list(APPEND benchmarks ${name}_SERIAL)
25
  target_compile_definitions(${name}_SERIAL PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL")
26 27 28

  if (TARGET vtkm::tbb)
    add_executable(${name}_TBB ${files})
29
    list(APPEND benchmarks ${name}_TBB)
30
    target_compile_definitions(${name}_TBB PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
31
  endif()
32

33
  if (TARGET vtkm::cuda)
34 35 36 37 38 39 40
    get_filename_component(fname "${name}" NAME_WE)
    get_filename_component(fullpath "${name}.cxx" ABSOLUTE)
    file(GENERATE
          OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${fname}.cu
          CONTENT "#include \"${fullpath}\"")

    add_executable(${name}_CUDA ${CMAKE_CURRENT_BINARY_DIR}/${fname}.cu)
41
    list(APPEND benchmarks ${name}_CUDA)
42
    target_compile_definitions(${name}_CUDA PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_CUDA")
43
  endif()
44 45 46 47 48 49 50 51 52

  foreach(benchmark ${benchmarks})
    target_link_libraries(${benchmark} PRIVATE vtkm_cont)
    set_target_properties(${benchmark} PROPERTIES
      RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
      )
  endforeach()


53
endfunction()
54

55 56 57 58 59 60 61 62
set(benchmarks
  BenchmarkArrayTransfer
  BenchmarkCopySpeeds
  BenchmarkDeviceAdapter
  BenchmarkFieldAlgorithms
  BenchmarkTopologyAlgorithms
  )

63 64
foreach (benchmark ${benchmarks})
  add_benchmark(${benchmark} ${benchmark}.cxx)
65
endforeach ()
66 67 68 69 70 71 72 73 74 75 76

if(TARGET vtkm_rendering)
  add_benchmark(BenchmarkRayTracing BenchmarkRayTracing.cxx)
  target_link_libraries(BenchmarkRayTracing_SERIAL PRIVATE vtkm_rendering)
  if(TARGET BenchmarkRayTracing_TBB)
    target_link_libraries(BenchmarkRayTracing_TBB PRIVATE vtkm_rendering)
  endif()
  if(TARGET BenchmarkRayTracing_CUDA)
    target_link_libraries(BenchmarkRayTracing_CUDA PRIVATE vtkm_rendering)
  endif()
endif()