Skip to content

Commit e643c8e

Browse files
authored
Merge pull request #3 from gjbex/development
Fix environments
2 parents 4aa585e + 499111b commit e643c8e

11 files changed

+306
-1272
lines changed

source-code/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ Sample code for performing computations on a GPU.
66
## What is it?
77

88
1. `pycuda`: directory illustrating pyCUDA.
9-
1. `scikit_cuda`: code illustrating linear algebra on a GPU device. This is an
10-
older library and has been at least partially superceded by CuPy.
119
1. `numba`: code illustrating using numba for GPU computing.
1210
1. `cupy`: Jupyter notebook illustrating some aspects of the `cupy` package.

source-code/cupy/cupy.ipynb

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 15,
13+
"execution_count": 1,
1414
"id": "c5430b2b-a033-4d85-a76a-eb9c958eb66d",
1515
"metadata": {},
1616
"outputs": [],
@@ -67,8 +67,8 @@
6767
"name": "stdout",
6868
"output_type": "stream",
6969
"text": [
70-
"CPU times: user 975 ms, sys: 1.03 s, total: 2.01 s\n",
71-
"Wall time: 127 ms\n"
70+
"CPU times: user 1.93 s, sys: 211 ms, total: 2.14 s\n",
71+
"Wall time: 136 ms\n"
7272
]
7373
}
7474
],
@@ -87,8 +87,8 @@
8787
"name": "stdout",
8888
"output_type": "stream",
8989
"text": [
90-
"CPU times: user 427 ms, sys: 2.04 s, total: 2.47 s\n",
91-
"Wall time: 1.26 s\n"
90+
"CPU times: user 1.55 s, sys: 293 ms, total: 1.84 s\n",
91+
"Wall time: 1.79 s\n"
9292
]
9393
}
9494
],
@@ -116,8 +116,8 @@
116116
"name": "stdout",
117117
"output_type": "stream",
118118
"text": [
119-
"CPU times: user 964 ms, sys: 2.58 s, total: 3.55 s\n",
120-
"Wall time: 3.67 s\n"
119+
"CPU times: user 113 ms, sys: 79.7 ms, total: 193 ms\n",
120+
"Wall time: 195 ms\n"
121121
]
122122
}
123123
],
@@ -136,8 +136,8 @@
136136
"name": "stdout",
137137
"output_type": "stream",
138138
"text": [
139-
"CPU times: user 2.44 ms, sys: 37 µs, total: 2.48 ms\n",
140-
"Wall time: 2.05 ms\n"
139+
"CPU times: user 3.14 ms, sys: 400 μs, total: 3.54 ms\n",
140+
"Wall time: 2.58 ms\n"
141141
]
142142
}
143143
],
@@ -164,8 +164,8 @@
164164
"name": "stdout",
165165
"output_type": "stream",
166166
"text": [
167-
"CPU times: user 360 ms, sys: 15 ms, total: 375 ms\n",
168-
"Wall time: 378 ms\n"
167+
"CPU times: user 197 ms, sys: 29.6 ms, total: 227 ms\n",
168+
"Wall time: 227 ms\n"
169169
]
170170
}
171171
],
@@ -185,8 +185,8 @@
185185
"name": "stdout",
186186
"output_type": "stream",
187187
"text": [
188-
"CPU times: user 432 µs, sys: 1.49 ms, total: 1.92 ms\n",
189-
"Wall time: 1.08 ms\n"
188+
"CPU times: user 2.03 ms, sys: 259 μs, total: 2.29 ms\n",
189+
"Wall time: 1.72 ms\n"
190190
]
191191
}
192192
],
@@ -203,6 +203,14 @@
203203
"## Matrix power"
204204
]
205205
},
206+
{
207+
"cell_type": "markdown",
208+
"id": "8f38d6ea-b522-4eb6-930b-0f577c3a4277",
209+
"metadata": {},
210+
"source": [
211+
"Since there seems to be an issue with `%%timeit` in combination with `cp.linalg.matrix_power` `%%time` is used in this section."
212+
]
213+
},
206214
{
207215
"cell_type": "code",
208216
"execution_count": 10,
@@ -223,17 +231,19 @@
223231
"name": "stdout",
224232
"output_type": "stream",
225233
"text": [
226-
"30.3 ms ± 5.26 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
234+
"CPU times: user 1.5 s, sys: 424 ms, total: 1.93 s\n",
235+
"Wall time: 130 ms\n"
227236
]
228237
}
229238
],
230239
"source": [
231-
"%timeit np.linalg.matrix_power(D, 10)"
240+
"%%time\n",
241+
"p = np.linalg.matrix_power(D, 10);"
232242
]
233243
},
234244
{
235245
"cell_type": "code",
236-
"execution_count": 21,
246+
"execution_count": 12,
237247
"id": "2cca5817-c795-4240-8a56-6361aade49cf",
238248
"metadata": {},
239249
"outputs": [],
@@ -251,12 +261,14 @@
251261
"name": "stdout",
252262
"output_type": "stream",
253263
"text": [
254-
"43.7 ms ± 2.55 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n"
264+
"CPU times: user 143 ms, sys: 10.6 ms, total: 153 ms\n",
265+
"Wall time: 7.04 ms\n"
255266
]
256267
}
257268
],
258269
"source": [
259-
"%timeit cp.linalg.matrix_power(D_dev, 10)"
270+
"%%time\n",
271+
"p_dev = cp.linalg.matrix_power(D_dev, 10);"
260272
]
261273
},
262274
{
@@ -269,15 +281,15 @@
269281
},
270282
{
271283
"cell_type": "code",
272-
"execution_count": 16,
284+
"execution_count": 14,
273285
"id": "dbae0849-7d44-4d8e-8a2a-104d08e63016",
274286
"metadata": {},
275287
"outputs": [
276288
{
277289
"name": "stdout",
278290
"output_type": "stream",
279291
"text": [
280-
"261 ms ± 81.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
292+
"497 ms ± 89.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
281293
]
282294
}
283295
],
@@ -288,15 +300,15 @@
288300
},
289301
{
290302
"cell_type": "code",
291-
"execution_count": 22,
303+
"execution_count": 15,
292304
"id": "33e09563-e5a0-47ca-b860-7b0581d7a11d",
293305
"metadata": {},
294306
"outputs": [
295307
{
296308
"name": "stdout",
297309
"output_type": "stream",
298310
"text": [
299-
"728 ms ± 16.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
311+
"554 ms ± 18.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
300312
]
301313
}
302314
],
@@ -307,15 +319,15 @@
307319
},
308320
{
309321
"cell_type": "code",
310-
"execution_count": 17,
322+
"execution_count": 16,
311323
"id": "2552a033-b7b0-423f-a162-ad559d696821",
312324
"metadata": {},
313325
"outputs": [
314326
{
315327
"name": "stdout",
316328
"output_type": "stream",
317329
"text": [
318-
"49.8 ms ± 4.96 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
330+
"132 ms ± 22.4 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
319331
]
320332
}
321333
],
@@ -326,15 +338,16 @@
326338
},
327339
{
328340
"cell_type": "code",
329-
"execution_count": 23,
341+
"execution_count": 17,
330342
"id": "b74986ef-b699-40db-ae50-c759b5c5a9f7",
331343
"metadata": {},
332344
"outputs": [
333345
{
334346
"name": "stdout",
335347
"output_type": "stream",
336348
"text": [
337-
"34 ms ± 36.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
349+
"The slowest run took 16.34 times longer than the fastest. This could mean that an intermediate result is being cached.\n",
350+
"14.5 ms ± 16 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
338351
]
339352
}
340353
],
@@ -360,7 +373,7 @@
360373
"name": "python",
361374
"nbconvert_exporter": "python",
362375
"pygments_lexer": "ipython3",
363-
"version": "3.11.6"
376+
"version": "3.12.8"
364377
}
365378
},
366379
"nbformat": 4,

source-code/pycuda/curand.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
{
5656
"cell_type": "code",
57-
"execution_count": 48,
57+
"execution_count": 2,
5858
"id": "122a78d1-9d07-4484-8f30-a01ed58a9715",
5959
"metadata": {},
6060
"outputs": [],
@@ -96,7 +96,7 @@
9696
},
9797
{
9898
"cell_type": "code",
99-
"execution_count": 44,
99+
"execution_count": 3,
100100
"id": "71134a08-5195-4205-ae1c-51c7298704e7",
101101
"metadata": {},
102102
"outputs": [],
@@ -118,7 +118,7 @@
118118
},
119119
{
120120
"cell_type": "code",
121-
"execution_count": 45,
121+
"execution_count": 4,
122122
"id": "a872e28c-9256-4d50-b46c-f8381131eda1",
123123
"metadata": {},
124124
"outputs": [],
@@ -128,7 +128,7 @@
128128
},
129129
{
130130
"cell_type": "code",
131-
"execution_count": 46,
131+
"execution_count": 5,
132132
"id": "53ddbb43-0f22-427e-83a6-c6d0264e958e",
133133
"metadata": {},
134134
"outputs": [],
@@ -146,7 +146,7 @@
146146
},
147147
{
148148
"cell_type": "code",
149-
"execution_count": 47,
149+
"execution_count": 6,
150150
"id": "f86f0258-64c8-44a0-b8b3-5a6f5d24e362",
151151
"metadata": {},
152152
"outputs": [
@@ -191,7 +191,7 @@
191191
"name": "python",
192192
"nbconvert_exporter": "python",
193193
"pygments_lexer": "ipython3",
194-
"version": "3.9.7"
194+
"version": "3.12.8"
195195
}
196196
},
197197
"nbformat": 4,

0 commit comments

Comments
 (0)