platform.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2018 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Eduard Valeyev
19  * Department of Chemistry, Virginia Tech
20  * Mar 18, 2018
21  *
22  */
23 
24 #ifndef TILEDARRAY_CUDA_PLATFORM_H__INCLUDED
25 #define TILEDARRAY_CUDA_PLATFORM_H__INCLUDED
26 
27 namespace TiledArray {
28 
30 enum class MemorySpace {
31  // MemorySpace is represented as a bitfield to compute unions and
32  // intersections easier
33  Null = 0b00,
34  CPU = 0b01,
35  CUDA = 0b10,
36  CUDA_UM = CPU | CUDA // union of CPU and CUDA spaces
37 };
38 
39 // customization point: in_memory_space<S>(O) -> bool
40 // it can be used to query if object O is in space S
41 
43 constexpr MemorySpace operator&(MemorySpace space1, MemorySpace space2) {
44  return static_cast<MemorySpace>(static_cast<int>(space1) &
45  static_cast<int>(space2));
46 }
48 constexpr MemorySpace operator|(MemorySpace space1, MemorySpace space2) {
49  return static_cast<MemorySpace>(static_cast<int>(space1) |
50  static_cast<int>(space2));
51 }
53 constexpr bool overlap(MemorySpace space1, MemorySpace space2) {
54  return (space1 & space2) != MemorySpace::Null;
55 }
56 
58 enum class ExecutionSpace { CPU, CUDA };
59 
60 // customization point: to_execution_space<S>(O) -> void
61 // "moves" O to execution space S
62 
63 } // namespace TiledArray
64 
65 #endif // TILEDARRAY_CUDA_PLATFORM_H__INCLUDED
ExecutionSpace
enumerates the execution spaces
Definition: platform.h:58
constexpr bool overlap(MemorySpace space1, MemorySpace space2)
Definition: platform.h:53
constexpr MemorySpace operator&(MemorySpace space1, MemorySpace space2)
Definition: platform.h:43
constexpr MemorySpace operator|(MemorySpace space1, MemorySpace space2)
Definition: platform.h:48
MemorySpace
enumerates the memory spaces
Definition: platform.h:30