< Summary

Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 479
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\cublas.hh

#LineLine coverage
 1// Copyright 2025 Digital Holography Foundation
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#pragma once
 16
 17#include <cublas_v2.h>
 18#include <spdlog/spdlog.h>
 19#include <stdexcept>
 20
 21namespace curaii::detail {
 22
 23void log_cublas_failure(spdlog::level::level_enum lvl, cublasStatus_t code, const char *expr,
 24                        const char *file, int line);
 25
 26} // namespace curaii::detail
 27
 28#define CUBLAS_CHECK(expr)                                                                         \
 29  do {                                                                                             \
 30    cublasStatus_t err__ = (expr);                                                                 \
 31    if (err__ != CUBLAS_STATUS_SUCCESS) {                                                          \
 32      ::curaii::detail::log_cublas_failure(spdlog::level::warn, err__, #expr, __FILE__, __LINE__); \
 33      throw ::curaii::CublasError(err__, #expr, __FILE__, __LINE__);                               \
 34    }                                                                                              \
 35  } while (false)
 36
 37#define CUBLAS_CHECK_NT(expr)                                                                      \
 38  do {                                                                                             \
 39    cublasStatus_t err__ = (expr);                                                                 \
 40    if (err__ != CUBLAS_STATUS_SUCCESS) {                                                          \
 41      ::curaii::detail::log_cublas_failure(spdlog::level::critical, err__, #expr, __FILE__,        \
 42                                           __LINE__);                                              \
 43      std::abort();                                                                                \
 44    }                                                                                              \
 45  } while (false)
 46
 47namespace curaii {
 48
 49class CublasError : public std::runtime_error {
 50public:
 51  explicit CublasError(cublasStatus_t code, const char *what, const char *file, int line);
 52
 53  [[nodiscard]] cublasStatus_t code() const noexcept;
 54
 55private:
 56  static std::string make_message(cublasStatus_t code, const char *what, const char *file,
 57                                  int line);
 58
 59  cublasStatus_t code_;
 60};
 61
 62class CublasHandle {
 63public:
 64  CublasHandle();
 65  ~CublasHandle() noexcept;
 66
 67  CublasHandle(const CublasHandle &)            = delete;
 68  CublasHandle &operator=(const CublasHandle &) = delete;
 69
 70  CublasHandle(CublasHandle &&) noexcept;
 71  CublasHandle &operator=(CublasHandle &&) noexcept;
 72
 73  [[nodiscard]] cublasHandle_t get() const noexcept;
 74  [[nodiscard]] cublasHandle_t release() noexcept;
 75  void                         reset(cublasHandle_t handle = nullptr) noexcept;
 76  explicit                     operator bool() const noexcept;
 77
 78private:
 179  cublasHandle_t handle_{nullptr};
 80};
 81
 82} // namespace curaii

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\cuda.hh

#LineLine coverage
 1// Copyright 2025 Digital Holography Foundation
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#pragma once
 16
 17#include <cuda_runtime.h>
 18#include <memory>
 19#include <spdlog/spdlog.h>
 20#include <stdexcept>
 21
 22namespace curaii::detail {
 23
 24void log_cuda_failure(spdlog::level::level_enum lvl, cudaError_t code, const char *expr,
 25                      const char *file, int line);
 26
 27} // namespace curaii::detail
 28
 29#define CUDA_CHECK(expr)                                                                           \
 30  do {                                                                                             \
 31    cudaError_t err__ = (expr);                                                                    \
 32    if (err__ != cudaSuccess) {                                                                    \
 33      ::curaii::detail::log_cuda_failure(spdlog::level::warn, err__, #expr, __FILE__, __LINE__);   \
 34      throw ::curaii::CudaError(err__, #expr, __FILE__, __LINE__);                                 \
 35    }                                                                                              \
 36  } while (false)
 37
 38#define CUDA_CHECK_NT(expr)                                                                        \
 39  do {                                                                                             \
 40    cudaError_t err__ = (expr);                                                                    \
 41    if (err__ != cudaSuccess) {                                                                    \
 42      ::curaii::detail::log_cuda_failure(spdlog::level::critical, err__, #expr, __FILE__,          \
 43                                         __LINE__);                                                \
 44      std::abort();                                                                                \
 45    }                                                                                              \
 46  } while (false)
 47
 48namespace curaii {
 49
 50class CudaError : public std::runtime_error {
 51public:
 52  explicit CudaError(cudaError_t code, const char *what, const char *file, int line);
 53
 54  [[nodiscard]] cudaError_t code() const noexcept;
 55
 56private:
 57  static std::string make_message(cudaError_t code, const char *what, const char *file, int line);
 58
 59  cudaError_t code_;
 60};
 61
 62struct HostDeleter {
 63  void operator()(void *ptr) const noexcept;
 64};
 65
 66struct DeviceDeleter {
 67  void operator()(void *ptr) const noexcept;
 68};
 69
 70template <typename T> using unique_host_ptr = std::unique_ptr<T, HostDeleter>;
 71
 72template <typename T> [[nodiscard]] unique_host_ptr<T> make_unique_host_ptr(size_t count);
 73
 74template <typename T> using unique_device_ptr = std::unique_ptr<T, DeviceDeleter>;
 75
 76template <typename T>
 77[[nodiscard]] unique_device_ptr<T> make_unique_device_ptr(size_t count, cudaStream_t stream = 0);
 78
 79class CudaStream {
 80public:
 81  explicit CudaStream(unsigned flags = cudaStreamDefault, int priority = 0);
 82  ~CudaStream() noexcept;
 83
 84  CudaStream(const CudaStream &)            = delete;
 85  CudaStream &operator=(const CudaStream &) = delete;
 86
 87  CudaStream(CudaStream &&other) noexcept;
 88  CudaStream &operator=(CudaStream &&other) noexcept;
 89
 90  [[nodiscard]] cudaStream_t get() const noexcept;
 91  [[nodiscard]] cudaStream_t release() noexcept;
 92  void                       reset(cudaStream_t s = nullptr) noexcept;
 93  explicit                   operator bool() const noexcept;
 94
 95private:
 196  cudaStream_t stream_{nullptr};
 97};
 98
 99} // namespace curaii
 100
 101#define CURAII_CUDA_HXX_INCLUDED
 102#include "curaii/cuda.hxx"
 103#undef CURAII_CUDA_HXX_INCLUDED

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\cuda.hxx

#LineLine coverage
 1#pragma once
 2
 3#ifndef CURAII_CUDA_HXX_INCLUDED
 4#include "curaii/cuda.hh"
 5#endif
 6
 7namespace curaii {
 8
 19template <typename T> [[nodiscard]] unique_host_ptr<T> make_unique_host_ptr(size_t count) {
 110  T *p = nullptr;
 111  CUDA_CHECK(cudaMallocHost(&p, count * sizeof(T)));
 112  return unique_host_ptr<T>(p);
 113}
 14
 15template <typename T>
 116[[nodiscard]] unique_device_ptr<T> make_unique_device_ptr(size_t count, cudaStream_t stream) {
 117  T *p = nullptr;
 18  // CUDA_CHECK(cudaMallocAsync(&p, count * sizeof(T), stream));
 19  (void)stream; // Currently unused, but will be needed for async allocations
 120  CUDA_CHECK(cudaMalloc(&p, count * sizeof(T)));
 121  return unique_device_ptr<T>(p);
 122}
 23
 24} // namespace curaii

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\cufft.hh

#LineLine coverage
 1// Copyright 2025 Digital Holography Foundation
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#pragma once
 16
 17#include <cufftXt.h>
 18#include <spdlog/spdlog.h>
 19#include <stdexcept>
 20
 21namespace curaii::detail {
 22
 23void log_cufft_failure(spdlog::level::level_enum lvl, cufftResult code, const char *expr,
 24                       const char *file, int line);
 25
 26} // namespace curaii::detail
 27
 28#define CUFFT_CHECK(expr)                                                                          \
 29  do {                                                                                             \
 30    cufftResult err__ = (expr);                                                                    \
 31    if (err__ != CUFFT_SUCCESS) {                                                                  \
 32      ::curaii::detail::log_cufft_failure(spdlog::level::warn, err__, #expr, __FILE__, __LINE__);  \
 33      throw ::curaii::CufftError(err__, #expr, __FILE__, __LINE__);                                \
 34    }                                                                                              \
 35  } while (false)
 36
 37#define CUFFT_CHECK_NT(expr)                                                                       \
 38  do {                                                                                             \
 39    cufftResult err__ = (expr);                                                                    \
 40    if (err__ != CUFFT_SUCCESS) {                                                                  \
 41      ::curaii::detail::log_cufft_failure(spdlog::level::critical, err__, #expr, __FILE__,         \
 42                                          __LINE__);                                               \
 43      std::abort();                                                                                \
 44    }                                                                                              \
 45  } while (false)
 46
 47namespace curaii {
 48
 49class CufftError : public std::runtime_error {
 50public:
 51  explicit CufftError(cufftResult code, const char *what, const char *file, int line);
 52
 53  [[nodiscard]] cufftResult code() const noexcept;
 54
 55private:
 56  static std::string make_message(cufftResult code, const char *what, const char *file, int line);
 57
 58  cufftResult code_;
 59};
 60
 61class CufftHandle {
 62public:
 63  CufftHandle();
 64  ~CufftHandle() noexcept;
 65
 66  CufftHandle(const CufftHandle &)            = delete;
 67  CufftHandle &operator=(const CufftHandle &) = delete;
 68
 69  CufftHandle(CufftHandle &&other) noexcept;
 70  CufftHandle &operator=(CufftHandle &&other) noexcept;
 71
 72  [[nodiscard]] cufftHandle get() const noexcept;
 73  [[nodiscard]] cufftHandle release() noexcept;
 74  void                      reset(cufftHandle handle = 0) noexcept;
 75  explicit                  operator bool() const noexcept;
 76
 77private:
 178  cufftHandle handle_{0};
 79};
 80
 81} // namespace curaii

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\cusolver.hh

#LineLine coverage
 1// Copyright 2025 Digital Holography Foundation
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#pragma once
 16
 17#include <cusolverDn.h>
 18#include <spdlog/spdlog.h>
 19#include <stdexcept>
 20
 21namespace curaii::detail {
 22
 23void log_cusolver_failure(spdlog::level::level_enum lvl, cusolverStatus_t code, const char *expr,
 24                          const char *file, int line);
 25
 26} // namespace curaii::detail
 27
 28#define CUSOLVER_CHECK(expr)                                                                       \
 29  do {                                                                                             \
 30    cusolverStatus_t err__ = (expr);                                                               \
 31    if (err__ != CUSOLVER_STATUS_SUCCESS) {                                                        \
 32      ::curaii::detail::log_cusolver_failure(spdlog::level::warn, err__, #expr, __FILE__,          \
 33                                             __LINE__);                                            \
 34      throw ::curaii::CusolverError(err__, #expr, __FILE__, __LINE__);                             \
 35    }                                                                                              \
 36  } while (false)
 37
 38#define CUSOLVER_CHECK_NT(expr)                                                                    \
 39  do {                                                                                             \
 40    cusolverStatus_t err__ = (expr);                                                               \
 41    if (err__ != CUSOLVER_STATUS_SUCCESS) {                                                        \
 42      ::curaii::detail::log_cusolver_failure(spdlog::level::critical, err__, #expr, __FILE__,      \
 43                                             __LINE__);                                            \
 44      std::abort();                                                                                \
 45    }                                                                                              \
 46  } while (false)
 47
 48namespace curaii {
 49
 50class CusolverError : public std::runtime_error {
 51public:
 52  explicit CusolverError(cusolverStatus_t code, const char *what, const char *file, int line);
 53
 54  [[nodiscard]] cusolverStatus_t code() const noexcept;
 55
 56private:
 57  static std::string make_message(cusolverStatus_t code, const char *what, const char *file,
 58                                  int line);
 59
 60  cusolverStatus_t code_;
 61};
 62
 63class CusolverDnHandle {
 64public:
 65  CusolverDnHandle();
 66  ~CusolverDnHandle() noexcept;
 67
 68  CusolverDnHandle(const CusolverDnHandle &)            = delete;
 69  CusolverDnHandle &operator=(const CusolverDnHandle &) = delete;
 70
 71  CusolverDnHandle(CusolverDnHandle &&other) noexcept;
 72  CusolverDnHandle &operator=(CusolverDnHandle &&other) noexcept;
 73
 74  [[nodiscard]] cusolverDnHandle_t get() const noexcept;
 75  [[nodiscard]] cusolverDnHandle_t release() noexcept;
 76  void                             reset(cusolverDnHandle_t handle = nullptr) noexcept;
 77  explicit                         operator bool() const noexcept;
 78
 79private:
 180  cusolverDnHandle_t handle_{nullptr};
 81};
 82
 83class CusolverDnParams {
 84public:
 85  CusolverDnParams();
 86  ~CusolverDnParams() noexcept;
 87
 88  CusolverDnParams(const CusolverDnParams &)            = delete;
 89  CusolverDnParams &operator=(const CusolverDnParams &) = delete;
 90
 91  CusolverDnParams(CusolverDnParams &&other) noexcept;
 92  CusolverDnParams &operator=(CusolverDnParams &&other) noexcept;
 93
 94  [[nodiscard]] cusolverDnParams_t get() const noexcept;
 95  [[nodiscard]] cusolverDnParams_t release() noexcept;
 96  void                             reset(cusolverDnParams_t params = nullptr) noexcept;
 97  explicit                         operator bool() const noexcept;
 98
 99private:
 1100  cusolverDnParams_t params_{nullptr};
 101};
 102
 103} // namespace curaii

C:\Users\Kremenchuk\actions-runner\_work\Holoflow\Holoflow\src\curaii\include\curaii\nvrtc.hh

#LineLine coverage
 1// Copyright 2025 Digital Holography Foundation
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
 10// distributed under the License is distributed on an "AS IS" BASIS,
 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15#pragma once
 16
 17#include <nvrtc.h>
 18#include <spdlog/spdlog.h>
 19#include <stdexcept>
 20
 21namespace curaii::detail {
 22
 23void log_nvrtc_failure(spdlog::level::level_enum lvl, nvrtcResult code, const char *expr,
 24                       const char *file, int line);
 25
 26} // namespace curaii::detail
 27
 28#define NVRTC_CHECK(expr)                                                                          \
 29  do {                                                                                             \
 30    nvrtcResult err__ = (expr);                                                                    \
 31    if (err__ != NVRTC_SUCCESS) {                                                                  \
 32      ::curaii::detail::log_nvrtc_failure(spdlog::level::warn, err__, #expr, __FILE__, __LINE__);  \
 33      throw ::curaii::NvrtcError(err__, #expr, __FILE__, __LINE__);                                \
 34    }                                                                                              \
 35  } while (false)
 36
 37#define NVRTC_CHECK_NT(expr)                                                                       \
 38  do {                                                                                             \
 39    nvrtcResult err__ = (expr);                                                                    \
 40    if (err__ != NVRTC_SUCCESS) {                                                                  \
 41      ::curaii::detail::log_nvrtc_failure(spdlog::level::critical, err__, #expr, __FILE__,         \
 42                                          __LINE__);                                               \
 43      std::abort();                                                                                \
 44    }                                                                                              \
 45  } while (false)
 46
 47namespace curaii {
 48
 49class NvrtcError : public std::runtime_error {
 50public:
 51  explicit NvrtcError(nvrtcResult code, const char *what, const char *file, int line);
 52
 53  [[nodiscard]] nvrtcResult code() const noexcept;
 54
 55private:
 56  static std::string make_message(nvrtcResult code, const char *what, const char *file, int line);
 57
 58  nvrtcResult code_;
 59};
 60
 61class NvrtcProgram {
 62public:
 63  NvrtcProgram() noexcept = default;
 64  NvrtcProgram(const char *source, const char *name, int numHeaders = 0,
 65               const char *const *headers = nullptr, const char *const *includeNames = nullptr);
 66  ~NvrtcProgram() noexcept;
 67
 68  NvrtcProgram(const NvrtcProgram &)            = delete;
 69  NvrtcProgram &operator=(const NvrtcProgram &) = delete;
 70
 71  NvrtcProgram(NvrtcProgram &&other) noexcept;
 72  NvrtcProgram &operator=(NvrtcProgram &&other) noexcept;
 73
 74  void create(const char *source, const char *name, int numHeaders = 0,
 75              const char *const *headers = nullptr, const char *const *includeNames = nullptr);
 76
 77  [[nodiscard]] nvrtcProgram get() const noexcept;
 78  [[nodiscard]] nvrtcProgram release() noexcept;
 79  void                       reset(nvrtcProgram program = nullptr) noexcept;
 80  explicit                   operator bool() const noexcept;
 81
 82private:
 183  nvrtcProgram program_{nullptr};
 84};
 85
 86} // namespace curaii

Methods/Properties