2
* Copyright 2008-2011 NVIDIA Corporation
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
/*! \file cuda_error.h
23
#include <thrust/detail/config.h>
24
#include <thrust/detail/type_traits.h>
25
#include <thrust/system/error_code.h>
26
#include <driver_types.h>
34
/*! \addtogroup system
38
// To construct an error_code after a CUDA Runtime error:
40
// error_code(::cudaGetLastError(), cuda_category())
42
// XXX N3000 prefers enum class cuda_errc { ... }
48
// from cuda/include/driver_types.h
49
success = cudaSuccess,
50
missing_configuration = cudaErrorMissingConfiguration,
51
memory_allocation = cudaErrorMemoryAllocation,
52
initialization_error = cudaErrorInitializationError,
53
launch_failure = cudaErrorLaunchFailure,
54
prior_launch_failure = cudaErrorPriorLaunchFailure,
55
launch_timeout = cudaErrorLaunchTimeout,
56
launch_out_of_resources = cudaErrorLaunchOutOfResources,
57
invalid_device_function = cudaErrorInvalidDeviceFunction,
58
invalid_configuration = cudaErrorInvalidConfiguration,
59
invalid_device = cudaErrorInvalidDevice,
60
invalid_value = cudaErrorInvalidValue,
61
invalid_pitch_value = cudaErrorInvalidPitchValue,
62
invalid_symbol = cudaErrorInvalidSymbol,
63
map_buffer_object_failed = cudaErrorMapBufferObjectFailed,
64
unmap_buffer_object_failed = cudaErrorUnmapBufferObjectFailed,
65
invalid_host_pointer = cudaErrorInvalidHostPointer,
66
invalid_device_pointer = cudaErrorInvalidDevicePointer,
67
invalid_texture = cudaErrorInvalidTexture,
68
invalid_texture_binding = cudaErrorInvalidTextureBinding,
69
invalid_channel_descriptor = cudaErrorInvalidChannelDescriptor,
70
invalid_memcpy_direction = cudaErrorInvalidMemcpyDirection,
71
address_of_constant_error = cudaErrorAddressOfConstant,
72
texture_fetch_failed = cudaErrorTextureFetchFailed,
73
texture_not_bound = cudaErrorTextureNotBound,
74
synchronization_error = cudaErrorSynchronizationError,
75
invalid_filter_setting = cudaErrorInvalidFilterSetting,
76
invalid_norm_setting = cudaErrorInvalidNormSetting,
77
mixed_device_execution = cudaErrorMixedDeviceExecution,
78
cuda_runtime_unloading = cudaErrorCudartUnloading,
79
unknown = cudaErrorUnknown,
80
not_yet_implemented = cudaErrorNotYetImplemented,
81
memory_value_too_large = cudaErrorMemoryValueTooLarge,
82
invalid_resource_handle = cudaErrorInvalidResourceHandle,
83
not_ready = cudaErrorNotReady,
84
insufficient_driver = cudaErrorInsufficientDriver,
85
set_on_active_process_error = cudaErrorSetOnActiveProcess,
86
no_device = cudaErrorNoDevice,
87
ecc_uncorrectable = cudaErrorECCUncorrectable,
88
startup_failure = cudaErrorStartupFailure,
92
} // end namespace cuda_errc
95
// XXX N3000 prefers is_error_code_enum<cuda_errc>
96
template<> struct is_error_code_enum<cuda_errc::cuda_errc_t> : thrust::detail::true_type {};
99
// XXX replace cuda_errc::cuda_errc_t with cuda_errc upon c++0x
100
/*! \return <tt>error_code(static_cast<int>(e), cuda_category())</tt>
102
inline error_code make_error_code(cuda_errc::cuda_errc_t e);
105
// XXX replace cuda_errc::cuda_errc_t with cuda_error upon c++0x
106
/*! \return <tt>error_condition(static_cast<int>(e), cuda_category())</tt>.
108
inline error_condition make_error_condition(cuda_errc::cuda_errc_t e);
111
/*! \return A reference to an object of a type derived from class \p error_category.
112
* \note The object's \p equivalent virtual functions shall behave as specified
113
* for the class \p error_category. The object's \p name virtual function shall
114
* return a pointer to the string <tt>"cuda"</tt>. The object's
115
* \p default_error_condition virtual function shall behave as follows:
117
* If the argument <tt>ev</tt> corresponds to a CUDA error value, the function
118
* shall return <tt>error_condition(ev,cuda_category())</tt>.
119
* Otherwise, the function shall return <tt>system_category.default_error_condition(ev)</tt>.
121
inline const error_category &cuda_category(void);
129
using system::cuda_category;
131
// XXX replace with using system::cuda_errc upon c++0x
132
namespace cuda_errc = system::cuda_errc;
134
} // end namespace thrust
136
#include <thrust/system/detail/cuda_error.inl>