alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Debug.hpp
Go to the documentation of this file.
1/* Copyright 2022 Alexander Matthes, Benjamin Worpitz, Bernhard Manfred Gruber
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
8
9#include <iostream>
10#include <string>
11#include <utility>
12
13//! The no debug level.
14#define ALPAKA_DEBUG_DISABLED 0
15//! The minimal debug level.
16#define ALPAKA_DEBUG_MINIMAL 1
17//! The full debug level.
18#define ALPAKA_DEBUG_FULL 2
19
20#ifndef ALPAKA_DEBUG
21//! Set the minimum log level if it is not defined.
22# define ALPAKA_DEBUG ALPAKA_DEBUG_DISABLED
23#endif
24
26{
27 //! Scope logger.
29 {
30 public:
31 explicit ScopeLogStdOut(std::string sScope) : m_sScope(std::move(sScope))
32 {
33 std::cout << "[+] " << m_sScope << std::endl;
34 }
35
38 auto operator=(ScopeLogStdOut const&) -> ScopeLogStdOut& = delete;
40
42 {
43 std::cout << "[-] " << m_sScope << std::endl;
44 }
45
46 private:
47 std::string const m_sScope;
48 };
49} // namespace alpaka::core::detail
50
51// Define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE.
52#if ALPAKA_DEBUG >= ALPAKA_DEBUG_MINIMAL
53# define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE ::alpaka::core::detail::ScopeLogStdOut const scopeLogStdOut(__func__)
54#else
55# define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE
56#endif
57
58// Define ALPAKA_DEBUG_FULL_LOG_SCOPE.
59#if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
60# define ALPAKA_DEBUG_FULL_LOG_SCOPE ::alpaka::core::detail::ScopeLogStdOut const scopeLogStdOut(__func__)
61#else
62# define ALPAKA_DEBUG_FULL_LOG_SCOPE
63#endif
64
65// Define ALPAKA_DEBUG_BREAK.
66#if ALPAKA_DEBUG >= ALPAKA_DEBUG_MINIMAL
67# if BOOST_COMP_GNUC || BOOST_COMP_CLANG
68# define ALPAKA_DEBUG_BREAK ::__builtin_trap()
69# elif BOOST_COMP_MSVC
70# define ALPAKA_DEBUG_BREAK ::__debugbreak()
71# else
72# define ALPAKA_DEBUG_BREAK
73 // #error debug-break for current compiler not implemented!
74# endif
75#else
76# define ALPAKA_DEBUG_BREAK
77#endif
ScopeLogStdOut(std::string sScope)
Definition Debug.hpp:31
ScopeLogStdOut(ScopeLogStdOut &&)=delete
ScopeLogStdOut(ScopeLogStdOut const &)=delete
auto operator=(ScopeLogStdOut &&) -> ScopeLogStdOut &=delete
auto operator=(ScopeLogStdOut const &) -> ScopeLogStdOut &=delete
Defines implementation details that should not be used directly by the user.
Definition Align.hpp:21
auto clipCast(V const &val) -> T
Definition ClipCast.hpp:16
STL namespace.