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