VTK-m  2.0
ExportMacros.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_internal__ExportMacros_h
11 #define vtk_m_internal__ExportMacros_h
12 
13 #include <vtkm/internal/Configure.h>
14 
19 #ifdef VTKM_HIP
20 
21 #include "hip/hip_runtime.h"
22 #define VTKM_EXEC __device__ __host__
23 #define VTKM_EXEC_CONT __device__ __host__
24 #define VTKM_SUPPRESS_EXEC_WARNINGS
25 
26 #elif defined(VTKM_CUDA)
27 
28 #define VTKM_EXEC __device__ __host__
29 #define VTKM_EXEC_CONT __device__ __host__
30 
31 #ifdef VTKM_MSVC
32 
33 #if __CUDAVER__ >= 75000
34 #define VTKM_SUPPRESS_EXEC_WARNINGS __pragma(nv_exec_check_disable)
35 #else
36 #define VTKM_SUPPRESS_EXEC_WARNINGS __pragma(hd_warning_disable)
37 #endif
38 
39 #else
40 
41 #if __CUDAVER__ >= 75000
42 #define VTKM_SUPPRESS_EXEC_WARNINGS _Pragma("nv_exec_check_disable")
43 #else
44 #define VTKM_SUPPRESS_EXEC_WARNINGS _Pragma("hd_warning_disable")
45 #endif
46 
47 #endif
48 
49 #else // !VTKM_CUDA
50 
51 #define VTKM_EXEC
52 #define VTKM_EXEC_CONT
53 #define VTKM_SUPPRESS_EXEC_WARNINGS
54 
55 #endif // !VTKM_CUDA
56 
57 #define VTKM_CONT
58 
59 // Background:
60 // VTK-m libraries are built with the hidden symbol visibility by default.
61 // This means that all template classes that are defined in VTK-m headers are
62 // defined with hidden visibility when we are building VTK-m. But when those
63 // headers are included by a third-party which has differing visibility controls
64 // causing link time warnings ( external vs private ).
65 //
66 // Issue:
67 // Dynamic cast is not just based on the name of the class, but also the
68 // combined visibility of the class on OSX. When building the hash_code of
69 // an object the symbol visibility controls of the type are taken into
70 // consideration ( including symbol vis of template parameters ).
71 // Therefore if a class has a component with private/hidden vis than it
72 // can't be passed across library boundaries.
73 //
74 // Example is PolymorphicArrayHandleContainer<T,S> whose visibility affected
75 // by the visibility of both T and S.
76 //
77 // Solution:
78 // The solution is fairly simple, but annoying. You need to mark every single
79 // header only class that is tempgit lated on non value types to be marked as
80 // always exported ( or never pass fvisibility=hidden ).
81 //
82 // TL;DR:
83 // This markup is used when we want to make sure:
84 // - The class can be compiled into multiple libraries and at runtime will
85 // resolve to a single type instance
86 // - Be a type ( or component of a types signature ) that can be passed between
87 // dynamic libraries and requires RTTI support ( dynamic_cast ).
88 #if defined(VTKM_MSVC) || defined(VTKM_CUDA)
89 #define VTKM_ALWAYS_EXPORT
90 #define VTKM_NEVER_EXPORT
91 #else
92 #define VTKM_ALWAYS_EXPORT __attribute__((visibility("default")))
93 #define VTKM_NEVER_EXPORT __attribute__((visibility("hidden")))
94 #endif
95 
96 // cuda 7.5 doesn't support static const or static constexpr variables
97 // that exist inside methods or classes, so in those cases we have to use
98 // just constexpr
99 #if defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR < 8)
100 #define VTKM_STATIC_CONSTEXPR_ARRAY constexpr
101 // cuda 8-9 doesn't support static constexpr pointers/fixed size arrays
102 // that exist inside methods or classes, so in those cases we gracefully
103 // fall back to static const
104 #elif defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR < 10)
105 #define VTKM_STATIC_CONSTEXPR_ARRAY static const
106 #else
107 #define VTKM_STATIC_CONSTEXPR_ARRAY static constexpr
108 #endif
109 
110 // Clang will warn about weak vtables (-Wweak-vtables) on exception classes,
111 // but there's no good way to eliminate them in this case because MSVC (See
112 // http://stackoverflow.com/questions/24511376). These macros will silence the
113 // warning for classes defined within them.
114 #ifdef VTKM_CLANG
115 #define VTKM_SILENCE_WEAK_VTABLE_WARNING_START \
116  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wweak-vtables\"")
117 #define VTKM_SILENCE_WEAK_VTABLE_WARNING_END _Pragma("clang diagnostic pop")
118 #else // VTKM_CLANG
119 #define VTKM_SILENCE_WEAK_VTABLE_WARNING_START
120 #define VTKM_SILENCE_WEAK_VTABLE_WARNING_END
121 #endif // VTKM_CLANG
122 
128 #define vtkmNotUsed(parameter_name)
129 
130 #endif //vtk_m_internal__ExportMacros_h