{"id":13806212,"url":"https://github.com/libmir/dcompute","last_synced_at":"2025-08-20T18:33:01.251Z","repository":{"id":9842146,"uuid":"63517055","full_name":"libmir/dcompute","owner":"libmir","description":"DCompute: Native execution of D on GPUs and other Accelerators","archived":false,"fork":false,"pushed_at":"2022-12-23T18:34:18.000Z","size":162,"stargazers_count":138,"open_issues_count":17,"forks_count":27,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-12-10T02:20:34.877Z","etag":null,"topics":["cuda","d","fpga","gpgpu","gpu","ldc","opencl"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libmir.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":null,"support":null}},"created_at":"2016-07-17T05:54:55.000Z","updated_at":"2024-10-02T09:06:45.000Z","dependencies_parsed_at":"2023-01-13T15:35:39.975Z","dependency_job_id":null,"html_url":"https://github.com/libmir/dcompute","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libmir%2Fdcompute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libmir%2Fdcompute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libmir%2Fdcompute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libmir%2Fdcompute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libmir","download_url":"https://codeload.github.com/libmir/dcompute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230445926,"owners_count":18227060,"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":["cuda","d","fpga","gpgpu","gpu","ldc","opencl"],"created_at":"2024-08-04T01:01:08.932Z","updated_at":"2024-12-19T14:07:21.252Z","avatar_url":"https://github.com/libmir.png","language":"D","funding_links":[],"categories":["Parallel computing"],"sub_categories":["XML"],"readme":"# dcompute\n\n[![Latest version](https://img.shields.io/dub/v/dcompute.svg)](http://code.dlang.org/packages/dcompute)\n[![Latest version](https://img.shields.io/github/tag/libmir/dcompute.svg?maxAge=3600)](http://code.dlang.org/packages/dcompute)\n[![License](https://img.shields.io/dub/l/dcompute.svg)](http://code.dlang.org/packages/dcompute)\n[![Gitter](https://img.shields.io/gitter/room/libmir/public.svg)](https://gitter.im/libmir/public)\n\n## About\n\nThis project is a set of libraries designed to work with [LDC][1] to \nenable native execution of D on GPUs (and other more exotic targets of OpenCL such as FPGAs DSPs, hereafter just 'GPUs') on the OpenCL and CUDA runtimes. As DCompute depends on developments in LDC for the code generation, a relatively recent LDC is required, use [1.8.0](https://github.com/ldc-developers/ldc/releases/tag/v1.8.0) or newer.\n\nThere are four main parts: \n* [std](https://github.com/libmir/dcompute/tree/master/source/dcompute/std): A library containing standard functionality for targetting GPUs and abstractions over the intrinsics of OpenCL and CUDA.\n* [driver](https://github.com/libmir/dcompute/tree/master/source/dcompute/driver): For handling all the compute API interactions and provide a friendly, easy-to-use, consistent interface. Of course you can always get down to a lower level of interaction if you need to. You can also use this to execute non-D kernels (e.g. OpenCL or CUDA).\n* [kernels](https://github.com/libmir/dcompute/tree/master/source/dcompute/kernels): A set of standard kernels and primitives to cover a large number of use cases and serve as documentation on how (and how not) to use this library.\n* [tests](https://github.com/libmir/dcompute/tree/master/source/dcompute/tests): A framework for testing kernels. The suite is runnable with `dub test` (see `dub.json` for the configuration used).\n\n## Examples\n\nKernel:\n```\n@kernel void saxpy(GlobalPointer!(float) res,\n                   float alpha,\n                   GlobalPointer!(float) x,\n                   GlobalPointer!(float) y, \n                   size_t N)\n{\n    auto i = GlobalIndex.x;\n    if (i \u003e= N) return;\n    res[i] = alpha*x[i] + y[i];\n}\n```\n\nInvoke with (CUDA):\n```\nq.enqueue!(saxpy)\n    ([N,1,1],[1,1,1]) // Grid \u0026 block \u0026 optional shared memory\n    (b_res,alpha,b_x,b_y, N); // kernel arguments\n```\nequivalent to the CUDA code\n```\nsaxpy\u003c\u003c\u003c1,N,0,q\u003e\u003e\u003e(b_res,alpha,b_x,b_y, N);\n```\n\nFor more examples and the full code see `source/dcompute/tests`.\n## Build Instructions\n\nTo build DCompute you will need:\n* [ldc][1] as the D dcompiler.\n* a SPIRV capable LLVM (available [here](https://github.com/thewilsonator/llvm/tree/compute) to build ldc to to support SPIRV (required for OpenCL)).\n* or LDC built with any LLVM 3.9.1 or greater that has the NVPTX backend enabled, to support CUDA.\n* [dub](https://github.com/dlang/dub)\nand then just run `$dub build` or add `\"dcompute\": \"~\u003e0.1.0\"` to your `dub.json` or `dependency \"dcompute\" version=\"~\u003e0.1.0\"` to your `dub.sdl`.\n\nIf you get an error like `Error: unrecognized switch '-mdcompute-targets=cuda-210`, make sure you are using LDC and not DMD: passing `--compiler=/path/to/ldc2` to dub will force it to use `/path/to/ldc2` as the D compiler.\n\nA dmd compatible d compiler,[dmd](https://github.com/dlang/dmd), ldmd or gdmd (available as part of [ldc][1] and [gdc](https://github.com/D-Programming-GDC/GDC) respectively), and cmake for building ldc is also required if you need to build ldc yourself.\n \n## Getting Started\n\nPlease see the [documentation](https://github.com/libmir/dcompute/blob/master/docs/README.md).\n\n## TODO\n\nGenerate OpenCL builtins from [here](https://github.com/KhronosGroup/SPIR-Tools/wiki/SPIR-2.0-built-in-functions)\n\n[1]: https://github.com/ldc-developers/ldc\n\n\n### Our sponsors\n\n[\u003cimg src=\"https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/symmetry.png\" height=\"80\" /\u003e](http://symmetryinvestments.com/) \t\u0026nbsp; \t\u0026nbsp;\t\u0026nbsp;\t\u0026nbsp;\n[\u003cimg src=\"https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/kaleidic.jpeg\" height=\"80\" /\u003e](https://github.com/kaleidicassociates)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibmir%2Fdcompute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibmir%2Fdcompute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibmir%2Fdcompute/lists"}