File: CMakeLists.txt

package info (click to toggle)
rocblas 5.5.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 565,372 kB
  • sloc: cpp: 198,491; python: 44,792; f90: 25,111; sh: 24,429; asm: 8,954; xml: 222; makefile: 147; ansic: 107; awk: 14
file content (118 lines) | stat: -rw-r--r-- 5,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# ########################################################################
# Copyright (C) 2016-2022 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop-
# ies of the Software, and to permit persons to whom the Software is furnished
# to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
# PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE-
# CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# ########################################################################

set( rocblas_samples_common
      ../common/singletons.cpp
      ../common/utility.cpp
      ../common/rocblas_random.cpp
    )

# C example
add_executable( rocblas-example-c-dgeam example_c_dgeam.c )
target_compile_definitions( rocblas-example-c-dgeam PRIVATE __HIP_PLATFORM_HCC__ )
target_compile_options( rocblas-example-c-dgeam PRIVATE -std=c11 )

# C++ examples
add_executable( rocblas-example-sscal example_sscal.cpp ${rocblas_samples_common} )
add_executable( rocblas-example-scal-template example_scal_template.cpp ${rocblas_samples_common} )
add_executable( rocblas-example-solver example_solver_rocblas.cpp ${rocblas_samples_common} )
add_executable( rocblas-example-hip-complex-her2 example_hip_complex_her2.cpp )
add_executable( rocblas-example-gemv-graph-capture example_gemv_graph_capture.cpp )

if ( BUILD_FORTRAN_CLIENTS )
  # Fortran examples
  add_executable( rocblas-example-fortran-axpy example_fortran_axpy.f90 $<TARGET_OBJECTS:rocblas_fortran>)
  add_executable( rocblas-example-fortran-scal example_fortran_scal.f90 $<TARGET_OBJECTS:rocblas_fortran>)
  add_executable( rocblas-example-fortran-gemv example_fortran_gemv.f90 $<TARGET_OBJECTS:rocblas_fortran>)
  set( sample_list_fortran rocblas-example-fortran-axpy rocblas-example-fortran-scal rocblas-example-fortran-gemv )
endif( )

if( BUILD_WITH_TENSILE )
  add_executable( rocblas-example-user-driven-tuning example_user_driven_tuning.cpp ${rocblas_samples_common} )
  add_executable( rocblas-example-sgemm example_sgemm.cpp ${rocblas_samples_common} )
  add_executable( rocblas-example-sgemm-strided-batched example_sgemm_strided_batched.cpp ${rocblas_samples_common} )
  add_executable( rocblas-example-gemm-ext2 example_gemm_ext2.cpp ${rocblas_samples_common} )
  set( sample_list_tensile rocblas-example-user-driven-tuning rocblas-example-sgemm rocblas-example-sgemm-strided-batched rocblas-example-gemm-ext2 )
else( )
  add_executable( rocblas-example-sgemm example_sgemm.cpp ${rocblas_samples_common} )
  add_executable( rocblas-example-sgemm-strided-batched example_sgemm_strided_batched.cpp ${rocblas_samples_common} )
  set( sample_list_tensile rocblas-example-sgemm rocblas-example-sgemm-strided-batched )
endif( )

set( sample_list_c rocblas-example-c-dgeam )
set( sample_list_base rocblas-example-sscal rocblas-example-scal-template rocblas-example-solver rocblas-example-hip-complex-her2 rocblas-example-gemv-graph-capture)

set( sample_list_all ${sample_list_base} ${sample_list_tensile} ${sample_list_fortran} ${sample_list_c} )
set( sample_list_hip_device ${sample_list_base} ${sample_list_tensile} )

foreach( exe ${sample_list_fortran} )
  target_link_libraries( ${exe} PRIVATE rocblas_fortran_client )
endforeach( )

foreach( exe ${sample_list_all} )
  target_link_libraries( ${exe} PRIVATE roc::rocblas )

  set_target_properties( ${exe} PROPERTIES
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
    RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging"
  )

  if (NOT ${exe} STREQUAL "rocblas-example-c-dgeam")
    target_compile_definitions( ${exe} PRIVATE ROCM_USE_FLOAT16 )
  endif()

  target_include_directories( ${exe}
    PRIVATE
      $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
      $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../library/include>
      )

  target_include_directories( ${exe}
    SYSTEM PRIVATE
      $<BUILD_INTERFACE:${HIP_INCLUDE_DIRS}>
      )

  if( CUDA_FOUND )
    target_include_directories( ${exe}
      PRIVATE
        $<BUILD_INTERFACE:${CUDA_INCLUDE_DIRS}>
      )
    target_compile_definitions( ${exe} PRIVATE __HIP_PLATFORM_NVCC__ )
    target_link_libraries( ${exe} PRIVATE ${CUDA_LIBRARIES} )
  else( )
    # auto set in hip_common.h
    #target_compile_definitions( ${exe} PRIVATE __HIP_PLATFORM_HCC__ )
  endif( )

  if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    target_compile_definitions( ${exe} PRIVATE ROCBLAS_INTERNAL_API )
  endif( )
  rocm_install(TARGETS ${exe} COMPONENT samples)
endforeach( )

foreach( exe ${sample_list_hip_device} )
  if( NOT CUDA_FOUND )
    target_link_libraries( ${exe} PRIVATE hip::device )
  endif()
endforeach( )