Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
cuda_debugging.h
Go to the documentation of this file.
1
2// NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the
3// software in any medium, provided that you keep intact this entire notice. You may improve, modify and create
4// derivative works of the software or any portion of the software, and you may copy and distribute such modifications
5// or works. Modified works should carry a notice stating that you changed the software and should note the date and
6// nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the
7// source of the software. NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND,
8// EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
9// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
10// WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE
11// CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS
12// THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. You
13// are solely responsible for determining the appropriateness of using and distributing the software and you assume
14// all risks associated with its use, including but not limited to the risks and costs of program errors, compliance
15// with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of
16// operation. This software is not intended to be used in any situation where a failure could cause risk of injury or
17// damage to property. The software developed by NIST employees is not subject to copyright protection within the
18// United States.
19
20#ifndef HEDGEHOG_CUDADEBUGGING_H
21#define HEDGEHOG_CUDADEBUGGING_H
22
23#ifdef HH_USE_CUDA
24
25#include <iostream>
26#include <cublas.h>
27#include <cuda_runtime.h>
28
29#ifndef checkCudaErrors
35inline void __checkCudaErrors(cudaError_t err, const char *file, const int line) {
36 if (cudaSuccess != err) {
37 std::cerr
38 << "checkCudaErrors() Cuda error = "
39 << err
40 << " \"" << cudaGetErrorString(err) << "\" from "
41 << file << ":" << line << std::endl;
42 exit(43);
43 }
44}
45
51inline void __checkCudaErrors(cublasStatus_t status, const char *file, const int line) {
52 if (CUBLAS_STATUS_SUCCESS != status) {
53 std::cerr
54 << "checkCudaErrors() Status Error = "
55 << status << " from "
56 << file << ":" << line << std::endl;
57 exit(44);
58 }
59}
60
61#ifdef HH_ENABLE_CHECK_CUDA
62#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
63#else //HH_ENABLE_CHECK_CUDA
64#define checkCudaErrors(err) err
65#endif //HH_ENABLE_CHECK_CUDA
66
67#endif //checkCudaErrors
68
69#endif //HH_USE_CUDA
70
71#endif //HEDGEHOG_CUDADEBUGGING_H
void __checkCudaErrors(cudaError_t err, const char *file, const int line)
Inline helper function for all of the SDK helper functions, to catch and show CUDA Error,...