{"id":13578596,"url":"https://github.com/stetre/mooncl","last_synced_at":"2026-02-11T08:54:24.610Z","repository":{"id":90017927,"uuid":"107637886","full_name":"stetre/mooncl","owner":"stetre","description":"Lua bindings for OpenCL","archived":false,"fork":false,"pushed_at":"2023-05-07T16:17:00.000Z","size":471,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T19:35:13.615Z","etag":null,"topics":["gpgpu","lua-bindings","opencl"],"latest_commit_sha":null,"homepage":null,"language":"C","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/stetre.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":"2017-10-20T06:00:41.000Z","updated_at":"2023-02-10T20:57:06.000Z","dependencies_parsed_at":"2024-03-17T06:59:39.354Z","dependency_job_id":null,"html_url":"https://github.com/stetre/mooncl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stetre/mooncl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmooncl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmooncl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmooncl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmooncl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stetre","download_url":"https://codeload.github.com/stetre/mooncl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmooncl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29330758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["gpgpu","lua-bindings","opencl"],"created_at":"2024-08-01T15:01:32.100Z","updated_at":"2026-02-11T08:54:24.584Z","avatar_url":"https://github.com/stetre.png","language":"C","readme":"## MoonCL: Lua bindings for OpenCL\n\nMoonCL is a Lua binding library for the [Khronos OpenCL\u0026#8482; API](https://www.khronos.org/opencl).\n\nIt runs on GNU/Linux \u003c!-- and on Windows (MSYS2/MinGW) --\u003e and requires \n[Lua](http://www.lua.org/) (\u003e=5.3) and OpenCL (\u003e= 1.2).\n\n\n_Author:_ _[Stefano Trettel](https://www.linkedin.com/in/stetre)_\n\n[![Lua logo](./doc/powered-by-lua.gif)](http://www.lua.org/)\n\n#### License\n\nMIT/X11 license (same as Lua). See [LICENSE](./LICENSE).\n\n#### Documentation\n\nSee the [Reference Manual](https://stetre.github.io/mooncl/doc/index.html).\n\n#### Getting and installing\n\nSetup the build environment as described [here](https://github.com/stetre/moonlibs), then:\n\n```sh\n$ git clone https://github.com/stetre/mooncl\n$ cd mooncl\nmooncl$ make\nmooncl$ sudo make install\n```\n\nTo use MoonCL, you'll also need the [OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ICD-Loader)\nand at least one \n[OpenCL capable device](https://www.khronos.org/conformance/adopters/conformant-products/opencl) with\n[updated drivers](https://www.howtogeek.com/242045/how-to-get-the-latest-nvidia-amd-or-intel-graphics-drivers-on-ubuntu/).\n \nOn Ubuntu, you can install the OpenCL ICD loader with:\n\n```sh\n$ sudo apt install ocl-icd-opencl-dev\n```\n\n#### Example\n\nThe example below performs a simple addition using the first available GPU.\n\nOther examples can be found in the **examples/** directory contained in the release package.\n\n```lua\n-- MoonCL example: hello.lua\ncl = require(\"mooncl\")\n\n-- Select platform and device, create context and command_queue\nplatform = cl.get_platform_ids()[1]\ndevice = cl.get_device_ids(platform, cl.DEVICE_TYPE_GPU)[1]\ncontext = cl.create_context(platform, {device})\nqueue = cl.create_command_queue(context, device)\n\n-- Create program and build it\nprogram = cl.create_program_with_source(context,[[\n   kernel void myadd(uint a, uint b, global uint *result) {\n      *result = a + b;\n   }\n]]) \n\ncl.build_program(program, {device})\n \n-- Create kernel \nkernel = cl.create_kernel(program, \"myadd\")\n\n-- Create a buffer to hold the result\nresult_buffer = cl.create_buffer(context, cl.MEM_WRITE_ONLY, cl.sizeof('uint'))\n         \n-- Set kernel arguments \na, b = 20, 30\ncl.set_kernel_arg(kernel, 0, 'uint', a)\ncl.set_kernel_arg(kernel, 1, 'uint', b)\ncl.set_kernel_arg(kernel, 2, result_buffer)\n\n-- Enqueue kernel for execution\ncl.enqueue_task(queue, kernel)\n\n-- Read and print the result \nmem = cl.malloc(cl.sizeof('uint'))\ncl.enqueue_read_buffer(queue, result_buffer, true, 0, mem:size(), mem:ptr())\nresult = mem:read(0, nil, 'uint')\n   \n-- Print result, and check it\nprint(\"\".. a .. \" + \" .. b .. \" = \" .. result[1])\nassert(result[1] == a + b)\n\n-- Deallocate resources \ncl.release_context(context)\n\n```\n\nThe script can be executed at the shell prompt with the standard Lua interpreter:\n\n```shell\n$ lua hello.lua\n```\n\n#### See also\n\n* [MoonLibs - Graphics and Audio Lua Libraries](https://github.com/stetre/moonlibs).\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstetre%2Fmooncl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstetre%2Fmooncl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstetre%2Fmooncl/lists"}