Kokkos Core Kernels Package  Version of the Day
Kokkos_Qthread.hpp
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Kokkos v. 2.0
6 // Copyright (2014) 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_QTHREAD_HPP
45 #define KOKKOS_QTHREAD_HPP
46 
47 #include <cstddef>
48 #include <iosfwd>
49 #include <Kokkos_Core.hpp>
50 #include <Kokkos_Layout.hpp>
51 #include <Kokkos_MemoryTraits.hpp>
52 #include <Kokkos_HostSpace.hpp>
53 #include <Kokkos_ExecPolicy.hpp>
54 #include <impl/Kokkos_Tags.hpp>
55 
56 /*--------------------------------------------------------------------------*/
57 
58 namespace Kokkos {
59 namespace Impl {
60 class QthreadExec ;
61 } // namespace Impl
62 } // namespace Kokkos
63 
64 /*--------------------------------------------------------------------------*/
65 
66 namespace Kokkos {
67 
69 class Qthread {
70 public:
72 
73 
79 
81  typedef memory_space::size_type size_type ;
82 
84 
86  /*------------------------------------------------------------------------*/
87 
89  static Qthread & instance( int = 0 );
90 
100  bool sleep();
101 
107  static bool wake();
108 
116  static void fence();
117 
118  /*------------------------------------------------------------------------*/
119 
120  static int in_parallel();
121 
122  static int is_initialized();
123 
125  static int concurrency();
126 
127  static void initialize( int thread_count );
128  static void finalize();
129 
131  static void print_configuration( std::ostream & , const bool detail = false );
132 
133  int shepherd_size() const ;
134  int shepherd_worker_size() const ;
135 };
136 
137 /*--------------------------------------------------------------------------*/
138 
139 } // namespace Kokkos
140 
141 /*--------------------------------------------------------------------------*/
142 /*--------------------------------------------------------------------------*/
143 
144 namespace Kokkos {
145 namespace Impl {
146 
147 template<>
148 struct VerifyExecutionCanAccessMemorySpace
151  >
152 {
153  enum { value = true };
154  inline static void verify( void ) { }
155  inline static void verify( const void * ) { }
156 };
157 
158 } // namespace Impl
159 } // namespace Kokkos
160 
161 /*--------------------------------------------------------------------------*/
162 /*--------------------------------------------------------------------------*/
163 
164 #include <Kokkos_Parallel.hpp>
165 #include <Qthread/Kokkos_QthreadExec.hpp>
166 #include <Qthread/Kokkos_Qthread_Parallel.hpp>
167 
168 #endif /* #define KOKKOS_QTHREAD_HPP */
169 
170 //----------------------------------------------------------------------------
171 //----------------------------------------------------------------------------
172 
Scratch memory space associated with an execution space.
Qthread execution_space
Tag this class as an execution space.
Execution space supported by Qthread.
Memory space for main process and CPU execution spaces.
Memory management for host memory.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
Declaration of various MemoryLayout options.
Declaration of parallel operators.
void finalize()
Finalize the spaces that were initialized via Kokkos::initialize.
Kokkos::Device< execution_space, memory_space > device_type
This execution space preferred device_type.