2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_DEBUG_H__
|
|
|
|
#define __UTIL_DEBUG_H__
|
|
|
|
|
2016-01-12 11:00:48 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <iostream>
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-01-12 11:00:48 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Global storage for all sort of flags used to fine-tune behavior of particular
|
|
|
|
* areas for the development purposes, without officially exposing settings to
|
|
|
|
* the interface.
|
|
|
|
*/
|
|
|
|
class DebugFlags {
|
|
|
|
public:
|
|
|
|
/* Descriptor of CPU feature-set to be used. */
|
|
|
|
struct CPU {
|
|
|
|
CPU();
|
|
|
|
|
|
|
|
/* Reset flags to their defaults. */
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/* Flags describing which instructions sets are allowed for use. */
|
|
|
|
bool avx2;
|
|
|
|
bool avx;
|
|
|
|
bool sse41;
|
|
|
|
bool sse3;
|
|
|
|
bool sse2;
|
2016-01-19 17:38:41 +00:00
|
|
|
|
|
|
|
/* Whether QBVH usage is allowed or not. */
|
|
|
|
bool qbvh;
|
2016-01-12 11:00:48 +00:00
|
|
|
};
|
|
|
|
|
2016-05-06 20:34:15 +00:00
|
|
|
/* Descriptor of CUDA feature-set to be used. */
|
|
|
|
struct CUDA {
|
|
|
|
CUDA();
|
|
|
|
|
|
|
|
/* Reset flags to their defaults. */
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/* Whether adaptive feature based runtime compile is enabled or not.
|
|
|
|
* Requires the CUDA Toolkit and only works on Linux atm. */
|
|
|
|
bool adaptive_compile;
|
|
|
|
};
|
|
|
|
|
2016-01-12 11:00:48 +00:00
|
|
|
/* Descriptor of OpenCL feature-set to be used. */
|
|
|
|
struct OpenCL {
|
|
|
|
OpenCL();
|
|
|
|
|
|
|
|
/* Reset flags to their defaults. */
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/* Available device types.
|
|
|
|
* Only gives a hint which devices to let user to choose from, does not
|
|
|
|
* try to use any sort of optimal device or so.
|
|
|
|
*/
|
|
|
|
enum DeviceType {
|
|
|
|
/* None of OpenCL devices will be used. */
|
|
|
|
DEVICE_NONE,
|
|
|
|
/* All OpenCL devices will be used. */
|
|
|
|
DEVICE_ALL,
|
|
|
|
/* Default system OpenCL device will be used. */
|
|
|
|
DEVICE_DEFAULT,
|
|
|
|
/* Host processor will be used. */
|
|
|
|
DEVICE_CPU,
|
|
|
|
/* GPU devices will be used. */
|
|
|
|
DEVICE_GPU,
|
|
|
|
/* Dedicated OpenCL accelerator device will be used. */
|
|
|
|
DEVICE_ACCELERATOR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Available kernel types. */
|
|
|
|
enum KernelType {
|
|
|
|
/* Do automated guess which kernel to use, based on the officially
|
|
|
|
* supported GPUs and such.
|
|
|
|
*/
|
|
|
|
KERNEL_DEFAULT,
|
|
|
|
/* Force mega kernel to be used. */
|
|
|
|
KERNEL_MEGA,
|
|
|
|
/* Force split kernel to be used. */
|
|
|
|
KERNEL_SPLIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Requested device type. */
|
|
|
|
DeviceType device_type;
|
|
|
|
|
|
|
|
/* Requested kernel type. */
|
|
|
|
KernelType kernel_type;
|
|
|
|
|
|
|
|
/* Use debug version of the kernel. */
|
|
|
|
bool debug;
|
|
|
|
};
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-01-12 11:00:48 +00:00
|
|
|
/* Get instance of debug flags registry. */
|
|
|
|
static DebugFlags& get()
|
|
|
|
{
|
|
|
|
static DebugFlags instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset flags to their defaults. */
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/* Requested CPU flags. */
|
|
|
|
CPU cpu;
|
|
|
|
|
2016-05-06 20:34:15 +00:00
|
|
|
/* Requested CUDA flags. */
|
|
|
|
CUDA cuda;
|
|
|
|
|
2016-01-12 11:00:48 +00:00
|
|
|
/* Requested OpenCL flags. */
|
|
|
|
OpenCL opencl;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DebugFlags();
|
|
|
|
|
|
|
|
#if (__cplusplus > 199711L)
|
|
|
|
public:
|
2016-05-11 14:50:10 +00:00
|
|
|
explicit DebugFlags(DebugFlags const& /*other*/) = delete;
|
2016-01-12 11:00:48 +00:00
|
|
|
void operator=(DebugFlags const& /*other*/) = delete;
|
|
|
|
#else
|
|
|
|
private:
|
2016-05-11 14:50:10 +00:00
|
|
|
explicit DebugFlags(DebugFlags const& /*other*/);
|
2016-01-12 11:00:48 +00:00
|
|
|
void operator=(DebugFlags const& /*other*/);
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef DebugFlags& DebugFlagsRef;
|
2016-01-23 20:33:53 +00:00
|
|
|
typedef const DebugFlags& DebugFlagsConstRef;
|
2016-01-12 11:00:48 +00:00
|
|
|
|
|
|
|
inline DebugFlags& DebugFlags() {
|
|
|
|
return DebugFlags::get();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream& operator <<(std::ostream &os,
|
2016-01-23 20:33:53 +00:00
|
|
|
DebugFlagsConstRef debug_flags);
|
2016-01-12 11:00:48 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __UTIL_DEBUG_H__ */
|