Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/jcl/src/openj9.cuda/share/classes/com/ibm/cuda/CudaGrid.java
12927 views
1
/*[INCLUDE-IF Sidecar18-SE]*/
2
/*******************************************************************************
3
* Copyright (c) 2013, 2018 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
22
*******************************************************************************/
23
package com.ibm.cuda;
24
25
/**
26
* The {@code CudaGrid} class represents a kernel launch configuration.
27
*/
28
public final class CudaGrid {
29
30
/**
31
* The size of the thread block in the x dimension.
32
*/
33
public final int blockDimX;
34
35
/**
36
* The size of the thread block in the y dimension.
37
*/
38
public final int blockDimY;
39
40
/**
41
* The size of the thread block in the z dimension.
42
*/
43
public final int blockDimZ;
44
45
/**
46
* The size of the grid in the x dimension.
47
*/
48
public final int gridDimX;
49
50
/**
51
* The size of the grid in the y dimension.
52
*/
53
public final int gridDimY;
54
55
/**
56
* The size of the grid in the z dimension.
57
*/
58
public final int gridDimZ;
59
60
/**
61
* The number of bytes of shared memory to allocate to each thread block.
62
*/
63
public final int sharedMemBytes;
64
65
/**
66
* The stream on which the kernel should be queued
67
* (or null for the default stream).
68
*/
69
public final CudaStream stream;
70
71
/**
72
* Creates a grid with the specified dimensions, with no shared memory
73
* on the default stream.
74
*
75
* @param gridDim
76
* the dimensions of the grid
77
* @param blockDim
78
* the dimensions of the thread block
79
*/
80
public CudaGrid(Dim3 gridDim, Dim3 blockDim) {
81
this(gridDim, blockDim, 0, null);
82
}
83
84
/**
85
* Creates a grid with the specified dimensions with no shared memory
86
* on the specified stream.
87
*
88
* @param gridDim
89
* the dimensions of the grid
90
* @param blockDim
91
* the dimensions of the thread block
92
* @param stream
93
* the stream on which the kernel should be queued
94
* (or null for the default stream)
95
*/
96
public CudaGrid(Dim3 gridDim, Dim3 blockDim, CudaStream stream) {
97
this(gridDim, blockDim, 0, stream);
98
}
99
100
/**
101
* Creates a grid with the specified dimensions and shared memory size
102
* on the default stream.
103
*
104
* @param gridDim
105
* the dimensions of the grid
106
* @param blockDim
107
* the dimensions of the thread block
108
* @param sharedMemBytes
109
* the number of bytes of shared memory to allocate to each thread block
110
*/
111
public CudaGrid(Dim3 gridDim, Dim3 blockDim, int sharedMemBytes) {
112
this(gridDim, blockDim, sharedMemBytes, null);
113
}
114
115
/**
116
* Creates a grid with the specified dimensions and shared memory size
117
* on the specified stream.
118
*
119
* @param gridDim
120
* the dimensions of the grid
121
* @param blockDim
122
* the dimensions of the thread block
123
* @param sharedMemBytes
124
* the number of bytes of shared memory to allocate to each thread block
125
* @param stream
126
* the stream on which the kernel should be queued
127
* (or null for the default stream)
128
*/
129
public CudaGrid(Dim3 gridDim, Dim3 blockDim, int sharedMemBytes,
130
CudaStream stream) {
131
super();
132
this.blockDimX = blockDim.x;
133
this.blockDimY = blockDim.y;
134
this.blockDimZ = blockDim.z;
135
this.gridDimX = gridDim.x;
136
this.gridDimY = gridDim.y;
137
this.gridDimZ = gridDim.z;
138
this.sharedMemBytes = sharedMemBytes;
139
this.stream = stream;
140
}
141
142
/**
143
* Creates a grid with the specified x dimensions with no shared memory
144
* on the default stream. The y and z dimensions are set to 1.
145
*
146
* @param gridDim
147
* the x dimension of the grid
148
* @param blockDim
149
* the x dimension of the thread block
150
*/
151
public CudaGrid(int gridDim, int blockDim) {
152
this(gridDim, blockDim, 0, null);
153
}
154
155
/**
156
* Creates a grid with the specified x dimensions with no shared memory
157
* on the specified stream. The y and z dimensions are set to 1.
158
*
159
* @param gridDim
160
* the x dimension of the grid
161
* @param blockDim
162
* the x dimension of the thread block
163
* @param stream
164
* the stream on which the kernel should be queued
165
* (or null for the default stream)
166
*/
167
public CudaGrid(int gridDim, int blockDim, CudaStream stream) {
168
this(gridDim, blockDim, 0, stream);
169
}
170
171
/**
172
* Creates a grid with the specified x dimensions and shared memory size
173
* on the default stream. The y and z dimensions are set to 1.
174
*
175
* @param gridDim
176
* the x dimension of the grid
177
* @param blockDim
178
* the x dimension of the thread block
179
* @param sharedMemBytes
180
* the number of bytes of shared memory to allocate to each thread block
181
*/
182
public CudaGrid(int gridDim, int blockDim, int sharedMemBytes) {
183
this(gridDim, blockDim, sharedMemBytes, null);
184
}
185
186
/**
187
* Creates a grid with the specified x dimensions and shared memory size
188
* on the specified stream. The y and z dimensions are set to 1.
189
*
190
* @param gridDim
191
* the x dimension of the grid
192
* @param blockDim
193
* the x dimension of the thread block
194
* @param sharedMemBytes
195
* the number of bytes of shared memory to allocate to each thread block
196
* @param stream
197
* the stream on which the kernel should be queued
198
* (or null for the default stream)
199
*/
200
public CudaGrid(int gridDim, int blockDim, int sharedMemBytes,
201
CudaStream stream) {
202
super();
203
this.blockDimX = blockDim;
204
this.blockDimY = 1;
205
this.blockDimZ = 1;
206
this.gridDimX = gridDim;
207
this.gridDimY = 1;
208
this.gridDimZ = 1;
209
this.sharedMemBytes = sharedMemBytes;
210
this.stream = stream;
211
}
212
}
213
214