{"id":18408821,"url":"https://github.com/codeplaysoftware/sycl-samples","last_synced_at":"2025-04-07T09:33:23.094Z","repository":{"id":206257881,"uuid":"676656786","full_name":"codeplaysoftware/SYCL-samples","owner":"codeplaysoftware","description":"A collection of samples written using the SYCL standard for C++.","archived":false,"fork":false,"pushed_at":"2024-03-26T10:37:00.000Z","size":118,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-03-27T13:26:49.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeplaysoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-09T17:45:21.000Z","updated_at":"2024-04-04T15:55:06.636Z","dependencies_parsed_at":null,"dependency_job_id":"dab3821a-8829-4cb7-ba50-33454fd52332","html_url":"https://github.com/codeplaysoftware/SYCL-samples","commit_stats":null,"previous_names":["codeplaysoftware/sycl-samples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2FSYCL-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2FSYCL-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2FSYCL-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2FSYCL-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeplaysoftware","download_url":"https://codeload.github.com/codeplaysoftware/SYCL-samples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223275909,"owners_count":17118250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T03:21:40.529Z","updated_at":"2024-11-06T03:21:41.293Z","avatar_url":"https://github.com/codeplaysoftware.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYCL-samples\n\n[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/codeplaysoftware/SYCL-samples/badge)](https://scorecard.dev/viewer/?uri=github.com/codeplaysoftware/SYCL-samples)\n\nA collection of samples and graphical demos written using\n[SYCL](https://www.khronos.org/sycl/).\n\n## Graphical Demos\n### Game of Life\nThis demo simulates Conway's Game of Life with a dynamically resizable grid.\nTo draw new cells, hold the mouse button and drag the mouse slowly over the\ngrid. Press SPACE to pause/resume the simulation. To resize the grid, use the\nmouse wheel. Doing this or resizing the window will reset the simulation.\n\n### Mandelbrot\nThis demo dynamically renders and displays a visualization of the Mandelbrot\nset on the complex plane. Use the mouse wheel to zoom in or out and drag the\nmouse while holding the mouse button to move around the plane.\n\n### NBody\nThis demo demonstrates the use of numerical integration methods to simulate\nsystems of interacting bodies, where every body exerts a force on every other\nbody. A graphical interface is provided to set the force type, the integration\nmethod, and the initial distribution of bodies. The simulation can be\ninitialized from there. The simulation can be viewed from different positions\nby dragging the mouse and using the mouse wheel to control the camera.\n\n### Fluid Simulation\nThis demo visualizes fluid behavior in a closed container. Each cell in the\ncellular automata represents a fluid particle existing in a velocity field.\nDrag the mouse around the screen to create fluid particles with velocities in\ndirection of the mouse travel. The fluid fades slowly over time so as not to fill\nthe container.\n\n## Non-graphical Demos\n### MPI with SYCL\nMPI, the Message Passing Interface, is a standard API for communicating data\nvia messages between distributed processes that is commonly used in HPC to\nbuild applications that can scale to multi-node computer clusters.\nThe three minimal code examples demonstrate how some GPUs can support\nGPU-Aware MPI together with SYCL. This enables fast device to device memory\ntransfers and collective operations without going via the host.\nMore generally the USM code samples are also portable across any SYCL backend\n(including CPU devices) that support the MPI standard. For this reason we\nuse the more general term \"device-aware\" MPI.\n\nThe first example uses the SYCL Unified Shared Memory (USM) memory model \n(`send_recv_usm`). The second uses the Buffer (`send_recv_buff`) model. Each\nexample uses the programming pattern Send-Receive.\n\nThe third slightly more complex code example `scatter_reduce_gather` demonstrates\na common HPC programming idiom using Scatter, Reduce and Gather. A data array is \nscattered by two processes associated with different MPI ranks using Scatter. The \ninitial data is updated within each MPI rank. Next the updated data is used to \ncalculate a local quantity that is then reduced to a partial result in each rank \nusing the SYCL 2020 reduction interface. Finally, the partial results from each \nrank are reduced to a final scalar value, `res`, using Reduce. Finally, the \ninitial data is updated using Gather.\n\nThese three examples form part of the Codeplay oneAPI for [NVIDIA GPUs](https://developer.codeplay.com/products/oneapi/nvidia/latest/guides/MPI-guide)\nand [AMD GPUs](https://developer.codeplay.com/products/oneapi/amd/latest/guides/MPI-guide)\nplugin documentation.\nThese two links point to the device-aware MPI guide for the CUDA/HIP backends\nrespectively.\n\nBuilding the MPI examples requires that the correct\nMPI headers and library be present on the system, and that you have set your\nCMAKE_CXX_COMPILER correctly (If you are using an MPI wrapper such as `mpicxx`).\nThis demo will be automatically skipped when MPI is not installed/detected.\nSometimes CMake fails to find the correct MPI library. A message saying this\nwill appear in the CMake configuration output. If this occurs then you\nshould adjust the CMakeLists.txt manually depending on the location of your\nMPI installation. E.g.\n\n```bash\n--- a/src/MPI_with_SYCL/CMakeLists.txt\n+++ b/src/MPI_with_SYCL/CMakeLists.txt\n@@ -5,7 +5,7 @@ else()\n     message(STATUS \"Found MPI, configuring the MPI_with_SYCL demo\")\n     foreach(TARGET send_recv_usm send_recv_buff scatter_reduce_gather)\n         add_executable(${TARGET} ${TARGET}.cpp)\n-        target_compile_options(${TARGET} PUBLIC ${SYCL_FLAGS} ${MPI_INCLUDE_DIRS})\n-        target_link_options(${TARGET} PUBLIC ${SYCL_FLAGS} ${MPI_LIBRARIES})\n+        target_compile_options(${TARGET} PUBLIC ${SYCL_FLAGS} ${MPI_INCLUDE_DIRS} -I/opt/cray/pe/mpich/8.1.25/ofi/cray/10.0/include/)\n+        target_link_options(${TARGET} PUBLIC ${SYCL_FLAGS} ${MPI_LIBRARIES} -L/opt/cray/pe/mpich/8.1.25/ofi/cray/10.0/lib)\n     endforeach()\n endif()\n```\n\nAdditionally, in order to run the examples, the MPI implementation needs\nto be device-aware. The CMake configuration attempts to build and execute the\nsimplest example to evaluate whether the found MPI library supports any of the\nenabled backends. This demo will be automatically skipped if this check does not\npass and a corresponding message will appear in the CMake configuration output.\nThe result of this check can be overwritten with the `-DMPI_DEVICE_AWARE=ON/OFF`\noption.\n\n### Parallel Inclusive Scan\nImplementation of a parallel inclusive scan with a given associative binary \noperation in SYCL.\n\n### Matrix Multiply OpenMP Comparison\nA block tiled matrix multiplication example which compares an OpenMP blocked \nmatrix multiplication implementation with a SYCL blocked matrix multiplication \nexample. The purpose is not to compare performance, but to show the \nsimilarities and differences between them. See block_host for the OpenMP \nimplementation.\n\n## Dependencies\nThe graphical demos use\n[Magnum](https://doc.magnum.graphics/magnum/getting-started.html#getting-started-setup-install)\n(and its dependency\n[Corrade](https://doc.magnum.graphics/corrade/building-corrade.html#building-corrade-packages))\nfor the graphics and UI abstraction with the\n[SDL2](https://wiki.libsdl.org/SDL2/Installation) implementation. Magnum and\nCorrade are built as part of this project through git submodules. Make sure to\ninclude them in the checkout via\n`git clone --recurse-submodules \u003cthis repo's URL\u003e`. SDL2 needs to be supplied by\nthe user and can be installed with common package managers on most systems, or\nbuilt from source. If you install SDL2 from source in a non-default location,\npass it into the CMake configuration with `-DSDL2_ROOT=\u003cpath\u003e`. It is possible\nto build the project without the graphical demos using `-DENABLE_GRAPHICS=OFF`\nif SDL2 cannot be provided - see the Building section below.\n\nAlthough the code should compile with any SYCL implementation, the CMake\nconfiguration assumes the DPC++ compiler driver CLI for compilation flags setup.\nBoth the\n[Intel DPC++ release](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html)\nand the [open source version](https://github.com/intel/llvm) are compatible.\n\n## Building\nThe project uses a standard CMake build configuration system. Ensure the SYCL \ncompiler is used by the configuration either by setting the\nenvironment variable `CXX=\u003ccompiler\u003e` or passing the configuration flag\n`-DCMAKE_CXX_COMPILER=\u003ccompiler\u003e` where `\u003ccompiler\u003e` is your SYCL compiler's\nexecutable (for example Intel `icpx` or LLVM `clang++`).\n\nTo check out the repository and build the examples, use simply:\n```\ngit clone --recurse-submodules \u003cthis repo's URL\u003e\ncd SYCL-samples\nmkdir build \u0026\u0026 cd build\ncmake .. -DCMAKE_CXX_COMPILER=\u003ccompiler\u003e\ncmake --build .\n```\nThe CMake configuration automatically detects the available SYCL backends and\nenables the SPIR/CUDA/HIP targets for the device code, including the\ncorresponding architecture flags. If desired, these auto-configured options may\nbe overridden with `-D\u003cOPTION\u003e=\u003cVALUE\u003e` with the following options:\n\n| `\u003cOPTION\u003e` | `\u003cVALUE\u003e` |\n| ---------- | ---------- |\n| `ENABLE_SPIR` | `ON` or `OFF` |\n| `ENABLE_CUDA` | `ON` or `OFF` |\n| `ENABLE_HIP` | `ON` or `OFF` |\n| `CUDA_COMPUTE_CAPABILITY` | Integer, e.g. `70` meaning capability 7.0 (arch `sm_70`) |\n| `HIP_GFX_ARCH` | String, e.g. `gfx1030` |\n\n### Building without graphics\nIt is possible to build only the non-graphical demos by adding the option\n`-DENABLE_GRAPHICS=OFF` to the CMake configuration command. In this case\nbuilding of the Magnum library will be skipped and the SDL2 library is not\nrequired as dependency. The option `--recurse-submodules` can also be skipped\nduring the checkout when building only the non-graphical demos.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeplaysoftware%2Fsycl-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeplaysoftware%2Fsycl-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeplaysoftware%2Fsycl-samples/lists"}