30 #pragma warning(disable:4530) // C++ exception handler used, but unwind semantics are not enabled.
60 #if FW_CUDA && !defined(__CUDA_ARCH__)
61 # define __CUDA_ARCH__ 100 // e.g. 120 = compute capability 1.2
64 #if (FW_DEBUG || defined(FW_ENABLE_ASSERT)) && !FW_CUDA
65 # define FW_ASSERT(X) ((X) ? ((void)0) : FW::fail("Assertion failed!\n%s:%d\n%s", __FILE__, __LINE__, #X))
67 # define FW_ASSERT(X) ((void)0)
71 # define FW_CUDA_FUNC __device__ __inline__
72 # define FW_CUDA_CONST __constant__
74 # define FW_CUDA_FUNC inline
75 # define FW_CUDA_CONST static const
78 #define FW_UNREF(X) ((void)(X))
79 #define FW_ARRAY_SIZE(X) ((int)(sizeof(X) / sizeof((X)[0])))
83 typedef unsigned char U8;
84 typedef unsigned short U16;
85 typedef unsigned int U32;
86 typedef signed char S8;
87 typedef signed short S16;
88 typedef signed int S32;
94 typedef unsigned long long U64;
95 typedef signed long long S64;
97 typedef unsigned __int64
U64;
98 typedef signed __int64
S64;
111 #define FW_U32_MAX (0xFFFFFFFFu)
112 #define FW_S32_MIN (~0x7FFFFFFF)
113 #define FW_S32_MAX (0x7FFFFFFF)
114 #define FW_U64_MAX ((U64)(S64)-1)
115 #define FW_S64_MIN ((S64)-1 << 63)
116 #define FW_S64_MAX (~((S64)-1 << 63))
117 #define FW_F32_MIN (1.175494351e-38f)
118 #define FW_F32_MAX (3.402823466e+38f)
119 #define FW_F64_MIN (2.2250738585072014e-308)
120 #define FW_F64_MAX (1.7976931348623158e+308)
121 #define FW_PI (3.14159265358979323846f)
122 #define FW_INV_PI (0.31830988618379067154f)
123 #define FW_INV_2PI (0.15915494309189533577f)
137 void printf (
const char* fmt, ...);
138 String
sprintf (
const char* fmt, ...);
142 void setError (
const char* fmt, ...);
148 void fail (
const char* fmt, ...);
185 #define FW_SPECIALIZE_MINMAX(TEMPLATE, T, MIN, MAX) \
186 TEMPLATE FW_CUDA_FUNC T min(T a, T b) { return MIN; } \
187 TEMPLATE FW_CUDA_FUNC T max(T a, T b) { return MAX; } \
188 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c) { return min(min(a, b), c); } \
189 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c) { return max(max(a, b), c); } \
190 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c, T d) { return min(min(min(a, b), c), d); } \
191 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c, T d) { return max(max(max(a, b), c), d); } \
192 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c, T d, T e) { return min(min(min(min(a, b), c), d), e); } \
193 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c, T d, T e) { return max(max(max(max(a, b), c), d), e); } \
194 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c, T d, T e, T f) { return min(min(min(min(min(a, b), c), d), e), f); } \
195 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c, T d, T e, T f) { return max(max(max(max(max(a, b), c), d), e), f); } \
196 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c, T d, T e, T f, T g) { return min(min(min(min(min(min(a, b), c), d), e), f), g); } \
197 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c, T d, T e, T f, T g) { return max(max(max(max(max(max(a, b), c), d), e), f), g); } \
198 TEMPLATE FW_CUDA_FUNC T min(T a, T b, T c, T d, T e, T f, T g, T h) { return min(min(min(min(min(min(min(a, b), c), d), e), f), g), h); } \
199 TEMPLATE FW_CUDA_FUNC T max(T a, T b, T c, T d, T e, T f, T g, T h) { return max(max(max(max(max(max(max(a, b), c), d), e), f), g), h); } \
200 TEMPLATE FW_CUDA_FUNC T clamp(T v, T lo, T hi) { return min(max(v, lo), hi); }
208 FW_SPECIALIZE_MINMAX(,
U64, ::
min(a, b), ::
max(a, b))
209 FW_SPECIALIZE_MINMAX(,
S64, ::
min(a, b), ::
max(a, b))
210 FW_SPECIALIZE_MINMAX(,
F32, ::fminf(a, b), ::fmaxf(a, b))
211 FW_SPECIALIZE_MINMAX(,
F64, ::fmin(a, b), ::fmax(a, b))
218 # define globalThreadIdx (threadIdx.x + blockDim.x * (threadIdx.y + blockDim.y * (blockIdx.x + gridDim.x * blockIdx.y)))
225 #ifndef FW_DO_NOT_OVERRIDE_NEW_DELETE
234 #endif // FW_DO_NOT_OVERRIDE_NEW_DELETE
void * malloc(size_t size)
void setError(const char *fmt,...)
void failWin32Error(const char *funcName)
bool getDiscardEvents(void)
bool restoreError(const String &old)
size_t getMemoryUsed(void)
const String & getError(void)
bool setDiscardEvents(bool discard)
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
void pushMemOwner(const char *id)
void * realloc(void *ptr, size_t size)
void pushLogFile(const String &name, bool append=true)
int incNestingLevel(int delta)
String sprintf(const char *fmt,...)
void printf(const char *fmt,...)
FW_SPECIALIZE_MINMAX(template< class T >, T &,(a< b)?a:b,(a > b)?a:b) FW_SPECIALIZE_MINMAX(template< class T >
FW_CUDA_FUNC void swap(T &a, T &b)
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx void
void fail(const char *fmt,...)
void profileEnd(bool printResults=true)
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
void profilePush(const char *id)