~ubuntu-branches/ubuntu/trusty/libthrust/trusty

« back to all changes in this revision

Viewing changes to system/cuda_error.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Beckmann
  • Date: 2011-05-28 09:32:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110528093248-np3euv5sj7fw3nyv
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright 2008-2011 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
 
 
18
/*! \file cuda_error.h
 
19
 */
 
20
 
 
21
#pragma once
 
22
 
 
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>
 
27
 
 
28
namespace thrust
 
29
{
 
30
 
 
31
namespace system
 
32
{
 
33
 
 
34
/*! \addtogroup system
 
35
 *  \{
 
36
 */
 
37
 
 
38
// To construct an error_code after a CUDA Runtime error:
 
39
//
 
40
//   error_code(::cudaGetLastError(), cuda_category())
 
41
 
 
42
// XXX N3000 prefers enum class cuda_errc { ... }
 
43
namespace cuda_errc
 
44
{
 
45
 
 
46
enum cuda_errc_t
 
47
{
 
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,
 
89
}; // end cuda_errc_t
 
90
 
 
91
 
 
92
} // end namespace cuda_errc
 
93
 
 
94
 
 
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 {};
 
97
 
 
98
 
 
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>
 
101
 */
 
102
inline error_code make_error_code(cuda_errc::cuda_errc_t e);
 
103
 
 
104
 
 
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>.
 
107
 */
 
108
inline error_condition make_error_condition(cuda_errc::cuda_errc_t e);
 
109
 
 
110
 
 
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:
 
116
 *
 
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>.
 
120
 */
 
121
inline const error_category &cuda_category(void);
 
122
 
 
123
/*! \} // end system
 
124
 */
 
125
 
 
126
 
 
127
} // end system
 
128
 
 
129
using system::cuda_category;
 
130
 
 
131
// XXX replace with using system::cuda_errc upon c++0x
 
132
namespace cuda_errc = system::cuda_errc;
 
133
 
 
134
} // end namespace thrust
 
135
 
 
136
#include <thrust/system/detail/cuda_error.inl>
 
137