context.hpp
1 /*
2  * Copyright (c) 2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/utilities/export.hpp>
20 
21 #include <cstdint>
22 #include <type_traits>
23 
24 namespace CUDF_EXPORT cudf {
25 
27 enum class init_flags : std::uint32_t {
29  NONE = 0,
31  LOAD_NVCOMP = 1 << 0,
33  INIT_JIT_CACHE = 1 << 1,
36 };
37 
42 constexpr init_flags operator|(init_flags lhs, init_flags rhs) noexcept
43 {
44  using underlying_t = std::underlying_type_t<init_flags>;
45  return static_cast<init_flags>(static_cast<underlying_t>(lhs) | static_cast<underlying_t>(rhs));
46 }
47 
52 constexpr init_flags operator&(init_flags lhs, init_flags rhs) noexcept
53 {
54  using underlying_t = std::underlying_type_t<init_flags>;
55  return static_cast<init_flags>(static_cast<underlying_t>(lhs) & static_cast<underlying_t>(rhs));
56 }
57 
62 constexpr init_flags operator~(init_flags flags) noexcept
63 {
64  using underlying_t = std::underlying_type_t<init_flags>;
65  return static_cast<init_flags>(static_cast<underlying_t>(init_flags::ALL) &
66  ~static_cast<underlying_t>(flags));
67 }
68 
73 constexpr bool has_flag(init_flags flags, init_flags flag) noexcept
74 {
75  return (flags | flag) == flags;
76 }
77 
82 void initialize(init_flags flags = init_flags::INIT_JIT_CACHE);
83 
86 void deinitialize();
87 
88 } // namespace CUDF_EXPORT cudf
constexpr string_character_types operator|(string_character_types lhs, string_character_types rhs)
OR operator for combining string_character_types.
cuDF interfaces
Definition: host_udf.hpp:37
constexpr bool has_flag(init_flags flags, init_flags flag) noexcept
Check if a flag is set.
Definition: context.hpp:73
constexpr init_flags operator~(init_flags flags) noexcept
Bitwise NOT operator for init_flags.
Definition: context.hpp:62
constexpr init_flags operator&(init_flags lhs, init_flags rhs) noexcept
Bitwise AND operator for init_flags.
Definition: context.hpp:52
void deinitialize()
de-initialize the cudf global context
void initialize(init_flags flags=init_flags::INIT_JIT_CACHE)
Initialize the cudf global context.
init_flags
Flags for controlling initialization steps.
Definition: context.hpp:27
@ ALL
All initialization steps (default behavior)
@ INIT_JIT_CACHE
Initialize the JIT program cache during initialization.
@ LOAD_NVCOMP
Load the nvCOMP library during initialization.