{"id":18408829,"url":"https://github.com/codeplaysoftware/sycl-crowd-simulation","last_synced_at":"2025-08-30T06:42:33.549Z","repository":{"id":74003380,"uuid":"531032158","full_name":"codeplaysoftware/sycl-crowd-simulation","owner":"codeplaysoftware","description":"A crowd simulation algorithm implemented using C++ and SYCL.","archived":false,"fork":false,"pushed_at":"2025-05-07T09:35:33.000Z","size":566,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-07T10:41:01.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","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.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-31T10:20:05.000Z","updated_at":"2025-05-07T09:35:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa3d100d-4945-413d-b091-5087380b1690","html_url":"https://github.com/codeplaysoftware/sycl-crowd-simulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeplaysoftware/sycl-crowd-simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2Fsycl-crowd-simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2Fsycl-crowd-simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2Fsycl-crowd-simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2Fsycl-crowd-simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeplaysoftware","download_url":"https://codeload.github.com/codeplaysoftware/sycl-crowd-simulation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeplaysoftware%2Fsycl-crowd-simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272815816,"owners_count":24997661,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:44.101Z","updated_at":"2025-08-30T06:42:33.499Z","avatar_url":"https://github.com/codeplaysoftware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYCL-Crowd-Simulation\n\n[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/codeplaysoftware/sycl-crowd-simulation/badge)](https://scorecard.dev/viewer/?uri=github.com/codeplaysoftware/sycl-crowd-simulation)\n\nSYCL GPU-accelerated crowd simulation engine based on Helbing et. al.'s social force model.\n\nDirk Helbing introduced the social force model in a paper in 1995, aimed at modelling the behaviour of crowds using Langevin equations. He proposed a refined model in a 2000 paper, \"Simulating Dynamical Features of Escape Panic\". Helbing posits that human behaviour in large crowds is determined by three component forces: A personal impulse towards one's destination, the cumulative force exerted by neighbouring people, and the repulsive force of any nearby walls. Together, these forces form the basis of a differential equation which can subsequently be integrated in order to calculate the actor's velocity.\n\n## Features\n\n- Performantly simulate tens of thousands of actors in real time\n- Define different crowds with different characteristics and different destinations \n- Define rooms and obstacles\n- Fully configurable environments (see [Input Format](#input-format))\n- Record and graph simulation metrics\n- Target and build for multiple SYCL supported backends\n- Apply a force heatmap across actors\n- The simulation kernels may be used separately from the GUI\n\n## Dependencies\n\n- The [DPC++ compiler](https://intel.github.io/llvm-docs/GetStartedGuide.html) is the required version of clang compiler to compile SYCL code\n- If targeting the DPC++ CUDA backend, the [CUDA runtime](https://intel.github.io/llvm-docs/GetStartedGuide.html#build-dpc-toolchain-with-support-for-nvidia-cuda) is required\n- If targeting the DPC++ OpenCL backend, an [OpenCL runtime](https://intel.github.io/llvm-docs/GetStartedGuide.html#install-low-level-runtime) is require\n- [CMake](https://cmake.org/install/) is used for build configuration\n- Graphics are rendered with [SDL2](https://lazyfoo.net/tutorials/SDL/01_hello_SDL/linux/index.php), installed with apt: `$ apt install libsdl2-dev`\n- Python is needed to run scripts\n- Graphs are plotted using matplotlib, installed via pip: `$ pip install matplotlib`\n- To run simulations in headless mode and record video output, install [xvfb](https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml) and [ffmpeg](https://ffmpeg.org/download.html) using apt\n\n## Building\n\nBuild configuration is carried out using CMake.\n\nThe option `-DSYCL_BACKEND` allows you to select which backend to build for (spir, cuda or hip). By default, it builds for spir.\n\nWhen enabled, the `-DPROFILING_MODE` option builds a headless version which can be run without the SDL dependency.\n\nWhen enabled, the `-DSTATS` option will collect metrics whilst the simulation is running. Results are written to `output/outputStats.txt`. Graphs can be produced from these metrics by running the python script [PlotGraphs.py](scripts/PlotGraphs.py).\n\nBy default, CMake should generate example input files by running [InputFileGenerator.py](scripts/InputFileGenerator.py) when generating the project makefiles. Be sure to enter the path to the DPC++ clang compiler. This would normally reside in `/opt/intel/oneapi/latest/compiler/linux/bin-llvm/`. `latest` is an alias for the version of the oneAPI base toolkit installed.\n\nThe `crowdsim` executable takes an input configuration JSON as a command line argument.\n\n```\n$ git clone https://github.com/codeplaysoftware/sycl-crowd-simulation.git\n$ cd crowd-simulation\n$ mkdir build \u0026\u0026 cd build\n$ cmake -DCMAKE_CXX_COMPILER=path/to/the/oneapi/llvm/build/bin/clang++ -DSYCL_BACKEND=spir -DPROFILING_MODE=off -DSTATS=on ..\n$ cmake --build .\n$ ./crowdsim ../input/evacuateRoom.json\n```\n\n## Input Format\n\nBelow is an annotated example input file which creates a room containing two actors with two different destinations.\n\n```\n{\n  \"config\": {                                     \u003c-- Configure environment\n    \"width\": 9,\n    \"height\": 9,\n    \"scale\": 100,                                 \n    \"delay\": 0,\n    \"bgColor\": [0, 0, 0],                         \n    \"wallColor\": [255, 255, 255],\n    \"heatmapEnabled\": true                        \u003c-- Flag denoting whether \n  },                                                  the heatmap should be \n                                                      applied to actors\n  \"room\": {                                       \n    \"walls\": [\n      [0.5, 0.5, 8.5, 0.5],                       \u003c-- Walls are defined via their\n      [8.5, 0.5, 8.5, 8.5],                           start and end points\n      [8.5, 8.5, 0.5, 8.5],\n      [0.5, 8.5, 0.5, 0.5]\n    ]                                             \n  },\n                                                  \n  \"actors\": [                                     \u003c-- Populate environment with\n    {                                                 actors\n      \"pos\": [3.4, 5.6],\n      \"velocity\": [0.0123, 0.0567],               \n      \"desiredSpeed\": 0.6,\n      \"pathId\": 0,                                \n      \"mass\": 50,\n      \"radius\": 0.05,                             \n      \"atDestination\": false,\n      \"color\": [255, 0, 0],                       \n      \"heatmapEnabled\": true \n    },\n    {\n      \"pos\": [0.7, 7.3],                          \n      \"velocity\": [0.0789, 0.0444],\n      \"desiredSpeed\": 0.6,                        \n      \"pathId\": 1,\n      \"mass\": 45,                                 \n      \"radius\": 0.06,\n      \"atDestination\": false,                     \n      \"color\": [0, 255, 0],\n      \"heatmapEnabled\": true                      \n    }\n  ],                                              \n\n  \"paths\": [                                      \n    {                                             \n      \"id\": 0,                                    \u003c-- Each path has a unique id, \n      \"checkpoints\": [[[7.9, 5.6], [8.1, 5.8]]]       referenced by any actor which\n    },                                                takes that path\n    {\n      \"id\": 1,\n      \"checkpoints\": [[[7.9, 5.6], [8.1, 5.8]],   \u003c-- Paths consist of checkpoints\n                      [[1.5, 2], [1.7, 2.2]]]         Each checkpoint is a rectangular\n    }                                                 region defined as:\n  ]                                                   [[minX, minY], [maxX, maxY]]\n}\n```\n\nLarger input configurations can be generated with python scripts, as demonstrated in [InputFileGenerator.py](scripts/InputFileGenerator.py).\n\nThe social force model itself can be tweaked by altering the constexprs defined in [DifferentialEq.hpp](external/DifferentialEq.hpp). For example, in simulations involving large numbers of actors (10,000+), the values `WALLAi` and `PEOPLEAi` will need to be increased to prevent any clipping issues.\n\n## Benchmarks\n\nRan on NVIDIA Titan RTX with `PROFLILING_MODE` enabled and `STATS` disabled.\n\n|  | **500 iterations\u003cbr\u003e1000 actors** | **500 iterations\u003cbr\u003e10,000 actors** | **500 iterations\u003cbr\u003e50,000 actors** |\n|---|---|---|---|\n| **Average kernel duration** | 0.0000321078s | 0.0000797784s | 0.00040853s |\n| **Total execution time** | 0.180193s | 2.29063s | 20.75141s |\n\n## Citations\n\n- Helbing, D., Farkas, I. \u0026 Vicsek, T. Simulating dynamical features of escape panic. Nature 407, 487–490 (2000). https://doi.org/10.1038/35035023\n- Marsaglia, G. (2003). Xorshift RNGs. Journal of Statistical Software, 8(14), 1–6. https://doi.org/10.18637/jss.v008.i14\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeplaysoftware%2Fsycl-crowd-simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeplaysoftware%2Fsycl-crowd-simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeplaysoftware%2Fsycl-crowd-simulation/lists"}