~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/kokkos/core/src/Cuda/Kokkos_Cuda_abort.hpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
//@HEADER
 
3
// ************************************************************************
 
4
// 
 
5
//   Kokkos: Manycore Performance-Portable Multidimensional Arrays
 
6
//              Copyright (2012) Sandia Corporation
 
7
// 
 
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
 
9
// the U.S. Government retains certain rights in this software.
 
10
// 
 
11
// Redistribution and use in source and binary forms, with or without
 
12
// modification, are permitted provided that the following conditions are
 
13
// met:
 
14
//
 
15
// 1. Redistributions of source code must retain the above copyright
 
16
// notice, this list of conditions and the following disclaimer.
 
17
//
 
18
// 2. Redistributions in binary form must reproduce the above copyright
 
19
// notice, this list of conditions and the following disclaimer in the
 
20
// documentation and/or other materials provided with the distribution.
 
21
//
 
22
// 3. Neither the name of the Corporation nor the names of the
 
23
// contributors may be used to endorse or promote products derived from
 
24
// this software without specific prior written permission.
 
25
//
 
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
 
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
 
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
37
//
 
38
// Questions? Contact  H. Carter Edwards (hcedwar@sandia.gov) 
 
39
// 
 
40
// ************************************************************************
 
41
//@HEADER
 
42
*/
 
43
 
 
44
#ifndef KOKKOS_CUDA_ABORT_HPP
 
45
#define KOKKOS_CUDA_ABORT_HPP
 
46
 
 
47
//----------------------------------------------------------------------------
 
48
//----------------------------------------------------------------------------
 
49
 
 
50
#if defined( __CUDACC__ ) && defined( __CUDA_ARCH__ )
 
51
 
 
52
#include <cuda.h>
 
53
 
 
54
#if ! defined( CUDA_VERSION ) || ( CUDA_VERSION < 4010 )
 
55
#error "Cuda version 4.1 or greater required"
 
56
#endif
 
57
 
 
58
#if ( __CUDA_ARCH__ < 200 )
 
59
#error "Cuda device capability 2.0 or greater required"
 
60
#endif
 
61
 
 
62
extern "C" {
 
63
/*  Cuda runtime function, declared in <crt/device_runtime.h>
 
64
 *  Requires capability 2.x or better.
 
65
 */
 
66
extern __device__ void __assertfail(
 
67
  const void  *message,
 
68
  const void  *file,
 
69
  unsigned int line,
 
70
  const void  *function,
 
71
  size_t       charsize);
 
72
}
 
73
 
 
74
namespace Kokkos {
 
75
namespace Impl {
 
76
 
 
77
__device__ inline
 
78
void cuda_abort( const char * const message )
 
79
{
 
80
  const char empty[] = "" ;
 
81
 
 
82
  __assertfail( (const void *) message ,
 
83
                (const void *) empty ,
 
84
                (unsigned int) 0 ,
 
85
                (const void *) empty ,
 
86
                sizeof(char) );
 
87
}
 
88
 
 
89
} // namespace Impl
 
90
} // namespace Kokkos
 
91
 
 
92
#else
 
93
 
 
94
namespace Kokkos {
 
95
namespace Impl {
 
96
KOKKOS_INLINE_FUNCTION
 
97
void cuda_abort( const char * const ) {}
 
98
}
 
99
}
 
100
 
 
101
#endif /* #if defined( __CUDACC__ ) && defined( __CUDA_ARCH__ ) */
 
102
 
 
103
//----------------------------------------------------------------------------
 
104
//----------------------------------------------------------------------------
 
105
 
 
106
#if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_CUDA )
 
107
namespace Kokkos {
 
108
__device__ inline
 
109
void abort( const char * const message ) { Kokkos::Impl::cuda_abort(message); }
 
110
}
 
111
#endif /* defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_CUDA ) */
 
112
 
 
113
//----------------------------------------------------------------------------
 
114
//----------------------------------------------------------------------------
 
115
 
 
116
#endif /* #ifndef KOKKOS_CUDA_ABORT_HPP */
 
117