-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jupyter notebooks for many python samples (#96)
* initial jupyter notebooks for enumopencl and mandelbrot * updated a bunch of samples and added a bunch of descriptive text * update copyright dates, switch to SPDX license identifiers
- Loading branch information
Showing
17 changed files
with
1,102 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ external/OpenCL-Headers/ | |
external/OpenCL-ICD-Loader/ | ||
install/ | ||
*~ | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d0b4a6b7-3ba6-4cc0-8b3c-ba4638247b3d", | ||
"metadata": {}, | ||
"source": [ | ||
"# enumopencl\n", | ||
"\n", | ||
"### Copyright Information" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "163deb93-0c32-40c7-aaf0-a427b453ccc3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Copyright (c) 2024 Ben Ashbaugh\n", | ||
"#\n", | ||
"# SPDX-License-Identifier: MIT" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "79250647-6a73-42d0-aee8-051aae55a2a8", | ||
"metadata": {}, | ||
"source": [ | ||
"## Sample Purpose\n", | ||
"\n", | ||
"This is a very simple sample that demonstrates how to enumerate the OpenCL platforms that are installed on a machine, and the OpenCL devices that these platforms expose.\n", | ||
"\n", | ||
"This is a good first sample to run to verify that OpenCL is correctly installed on your machine, and that your environment is correctly setup.\n", | ||
"\n", | ||
"## Sample\n", | ||
"\n", | ||
"The first thing we will do is to import pyopencl so we have access to OpenCL from Python." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6c728115-6d8e-4e4c-a4f8-55a6580864f7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pyopencl as cl" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b343a628-3e47-4704-8e69-049200236316", | ||
"metadata": {}, | ||
"source": [ | ||
"Assuming that this worked correctly, we can now query the installed OpenCL platforms. An OpenCL platform is an OpenCL implementation for a specific device or collection of devices. There may be an OpenCL platform from a specific device vendor, a specific class of devices from that vendor, or even a specific device. For example, if you have a CPU from one vendor and a GPU from another vendor, you may need to install two OpenCL platforms to enumerate both devices.\n", | ||
"\n", | ||
"If no platforms are found then either no OpenCL platforms are installed or there is a problem with your installation.\n", | ||
"\n", | ||
"For each of the platforms that we find we will print information about the platform and information about each of the devices that the platform supports." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "23b4e3c9-0d34-43af-95fb-2a207d6942fc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for p, platform in enumerate(cl.get_platforms()):\n", | ||
" print(\"Platform[{}]:\".format(p))\n", | ||
" print(\" Name: \" + platform.get_info(cl.platform_info.NAME))\n", | ||
" print(\" Vendor: \" + platform.get_info(cl.platform_info.VENDOR))\n", | ||
" print(\" Driver Version: \" + platform.get_info(cl.platform_info.VERSION))\n", | ||
" for d, device in enumerate(platform.get_devices()):\n", | ||
" print(\"Device[{}]:\".format(d))\n", | ||
" print(\" Type: \" + cl.device_type.to_string(device.get_info(cl.device_info.TYPE)))\n", | ||
" print(\" Name: \" + device.get_info(cl.device_info.NAME))\n", | ||
" print(\" Vendor: \" + device.get_info(cl.device_info.VENDOR))\n", | ||
" print(\" Device Version: \" + device.get_info(cl.device_info.VERSION))\n", | ||
" print(\" Driver Version: \" + device.get_info(cl.device_info.DRIVER_VERSION))\n", | ||
" print()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d447785a-0580-423a-b56e-63bb424fe608", | ||
"metadata": {}, | ||
"source": [ | ||
"If you see at least one platform and device listed above, great, your installation is working!" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.