{"id":51985762,"url":"https://github.com/node-3d/opencl","last_synced_at":"2026-07-30T19:01:29.978Z","repository":{"id":42917841,"uuid":"242407144","full_name":"node-3d/opencl","owner":"node-3d","description":"OpenCL for Node.js","archived":false,"fork":false,"pushed_at":"2026-07-25T18:55:53.000Z","size":37927,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-07-25T20:17:31.161Z","etag":null,"topics":["api","cl","compute","crossplatform","gpgpu","gpu","node-3d","node-addon","nodejs","opencl"],"latest_commit_sha":null,"homepage":"https://github.com/node-3d/node-3d","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-3d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-02-22T20:28:24.000Z","updated_at":"2026-07-25T18:55:58.000Z","dependencies_parsed_at":"2022-08-28T05:31:22.446Z","dependency_job_id":null,"html_url":"https://github.com/node-3d/opencl","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/node-3d/opencl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fopencl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fopencl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fopencl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fopencl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-3d","download_url":"https://codeload.github.com/node-3d/opencl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-3d%2Fopencl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36088336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-30T02:00:05.956Z","response_time":106,"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":["api","cl","compute","crossplatform","gpgpu","gpu","node-3d","node-addon","nodejs","opencl"],"created_at":"2026-07-30T19:01:28.948Z","updated_at":"2026-07-30T19:01:29.935Z","avatar_url":"https://github.com/node-3d.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCL for Node.js\n\nThis is a part of [Node3D](https://github.com/node-3d) project.\n\n[![NPM](https://badge.fury.io/js/@node-3d%2Fopencl.svg)](https://badge.fury.io/js/@node-3d%2Fopencl)\n[![Lint](https://github.com/node-3d/opencl/actions/workflows/lint.yml/badge.svg)](https://github.com/node-3d/opencl/actions/workflows/lint.yml)\n[![Test](https://github.com/node-3d/opencl/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/opencl/actions/workflows/test.yml)\n[![Cpplint](https://github.com/node-3d/opencl/actions/workflows/cpplint.yml/badge.svg)](https://github.com/node-3d/opencl/actions/workflows/cpplint.yml)\n\n```bash\nnpm install @node-3d/opencl\n```\n\n\n\n**Node.js** addon with **OpenCL 1.2** bindings. This is not WebCL.\n\nPrebuilt addon binaries: Windows x64/ARM64, Linux x64/ARM64, macOS x64/ARM64.\nAn OpenCL runtime/ICD is still required on Windows and Linux.\n\n## Platform Notes\n\nOpenCL behavior depends on the installed platform runtime. This package is a thin\nbinding layer and generally forwards calls and status codes directly to the native\nOpenCL implementation, so validation details can differ between vendors.\n\nWindows ARM64 uses Microsoft's OpenCLOn12 compatibility layer in CI. That layer exposes\nOpenCL through Direct3D 12, which is currently the practical way to run OpenCL on\nGitHub-hosted Windows ARM64 runners. It can differ from vendor OpenCL runtimes for\ninvalid-input edge cases, especially around program build failures and kernel argument\nvalidation. Valid kernel build, argument setup, queue, buffer, and execution paths are\nstill tested there.\n\nThe API directly reflects the low-level **OpenCL** interface. There are minor changes\nsimilar to how WebGL is different from OpenGL.\n* All `cl*` methods are available as `cl.*` starting lowercase,\n\te.g: `clCreateKernel -\u003e cl.createKernel`.\n* All `CL_*` constants are available as `cl.*`, e.g.: `CL_TRUE -\u003e cl.TRUE`.\n* The CL resource pointers are wrapped in JS objects, such as `TClPlatform`, `TClContext`, `TClEvent`.\n* For `cl.enqueue*()` methods, you can pass `hasEvent = true`, in that case a `TClEvent` is returned.\n* The CL status is not returned, instead a JS exception is thrown in case of a CL error.\n\nMost of the method arguments comply to the original C-style spec, some parameters are omitted\ndue to JS specifics. For example, passing an array, you don't need to specify its length.\n\n## API\n\nThe package is intended to be imported as a namespace:\n\n```ts\nimport * as cl from '@node-3d/opencl';\n```\n\nThe namespace contains:\n\n* OpenCL constants, with `CL_` prefixes removed.\n* Platform/device/context helpers such as `getPlatformIDs`, `getDeviceIDs`,\n  `createContext`, and `createContextFromType`.\n* Queue, program, kernel, sampler, memory, image, and event functions mirroring OpenCL 1.2.\n* GL interop helpers such as `createFromGLBuffer`, `createFromGLTexture`,\n  `enqueueAcquireGLObjects`, and `enqueueReleaseGLObjects`.\n* `quickStart(isLoggingDevices?)`, which chooses the first available platform/device and\n  creates a context for examples and small tools.\n\nResources are native handles wrapped in JS objects. Release resources explicitly with the\nmatching `release*` function when ownership ends.\n\n\n## Examples\n\n1. Import the module:\n\t```ts\n\timport * as cl from '@node-3d/opencl';\n\t```\n2. Fetch the CL control objects:\n\t```ts\n\tconst { context, device } = cl.quickStart();\n\tconst queue = cl.createCommandQueue(context, device);\n\t```\n3. Prepare the data input/output buffers:\n\t```ts\n\tconst BUFFER_SIZE = 10;\n\tconst BYTE_SIZE = BUFFER_SIZE * Uint32Array.BYTES_PER_ELEMENT;\n\t\n\tconst arrayA = new Uint32Array(BUFFER_SIZE);\n\tconst arrayB = new Uint32Array(BUFFER_SIZE);\n\tconst arrayC = new Uint32Array(BUFFER_SIZE);\n\t\n\tfor (let i = 0; i \u003c BUFFER_SIZE; i++) {\n\t\tarrayA[i] = i;\n\t\tarrayB[i] = i * 2;\n\t}\n\t\n\t// Create buffer for arrayA and arrayB and copy host contents\n\tconst bufferA = cl.createBuffer(context, cl.MEM_READ_ONLY, BYTE_SIZE);\n\tconst bufferB = cl.createBuffer(context, cl.MEM_READ_ONLY, BYTE_SIZE);\n\t\n\t// Create buffer for arrayC to read results\n\tconst bufferC = cl.createBuffer(context, cl.MEM_WRITE_ONLY, BYTE_SIZE);\n\t```\n4. Create a valid CL program, e.g. from source:\n\t```ts\n\tconst program = cl.createProgramWithSource(context, `\n\t\t__kernel\n\t\tvoid vadd(__global int *a, __global int *b, __global int *c, uint num) {\n\t\t\tsize_t i = get_global_id(0);\n\t\t\tif (i \u003c num) {\n\t\t\t\tc[i] = a[i] + b[i];\n\t\t\t}\n\t\t}\n\t`);\n\tcl.buildProgram(program);\n\t```\n5. Fetch and set up a kernel from within the program:\n\t```ts\n\t// Create a kernel object\n\tconst kernel = cl.createKernel(program, 'vadd');\n\t\n\t// Set kernel args\n\tcl.setKernelArg(kernel, 0, 'uint*', bufferA);\n\tcl.setKernelArg(kernel, 1, 'uint*', bufferB);\n\tcl.setKernelArg(kernel, 2, 'uint*', bufferC);\n\tcl.setKernelArg(kernel, 3, 'uint', BUFFER_SIZE);\n\t```\n6. Launch the kernel and then read the results:\n\t```ts\n\t// Do the work\n\tcl.enqueueWriteBuffer(queue, bufferA, true, 0, BYTE_SIZE, arrayA);\n\tcl.enqueueWriteBuffer(queue, bufferB, true, 0, BYTE_SIZE, arrayB);\n\tcl.enqueueNDRangeKernel(queue, kernel, 1, null, [BUFFER_SIZE]);\n\tcl.enqueueReadBuffer(queue, bufferC, true, 0, BYTE_SIZE, arrayC);\n\t```\n7. See if it worked:\n\t```ts\n\tconsole.log(`A = [${arrayA.join(', ')}]`);\n\tconsole.log(`B = [${arrayB.join(', ')}]`);\n\tconsole.log(`C = [${arrayC.join(', ')}]`);\n\t```\n8. Release the CL objects:\n\t```ts\n\tcl.releaseCommandQueue(queue);\n\tcl.releaseKernel(kernel);\n\tcl.releaseProgram(program);\n\tcl.releaseMemObject(bufferA);\n\tcl.releaseMemObject(bufferB);\n\tcl.releaseMemObject(bufferC);\n\t```\n\n\nSee `examples` for more details. The full code of the above example is available\n[here](examples/simple.ts).\n\n## Binary Origin\n\nRelease archives are built by this repository's public GitHub Actions workflows.\n\nAttestations: https://github.com/node-3d/opencl/attestations\n\nTo verify a downloaded archive:\n\n```bash\ngh release download \u003ctag\u003e -R node-3d/opencl -p \u003cplatform\u003e.gz\ngh attestation verify \u003cplatform\u003e.gz -R node-3d/opencl\n```\n\n\u003e This addon is ABI-compatible across Node.js versions. **There is no compilation** during `npm install`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fopencl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-3d%2Fopencl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-3d%2Fopencl/lists"}