{"id":17632736,"url":"https://github.com/fynv/curandrtc","last_synced_at":"2025-05-05T22:37:38.358Z","repository":{"id":62565985,"uuid":"196499247","full_name":"fynv/CURandRTC","owner":"fynv","description":"CURandRTC is a GPU random number generation module based on ThrustRTC.","archived":false,"fork":false,"pushed_at":"2021-07-07T12:49:43.000Z","size":85,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T09:08:57.258Z","etag":null,"topics":["cuda","nvrtc","random-number-generators","thrust"],"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/fynv.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}},"created_at":"2019-07-12T03:03:38.000Z","updated_at":"2024-11-11T20:30:31.000Z","dependencies_parsed_at":"2022-11-03T16:15:25.355Z","dependency_job_id":null,"html_url":"https://github.com/fynv/CURandRTC","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/fynv%2FCURandRTC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fynv%2FCURandRTC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fynv%2FCURandRTC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fynv%2FCURandRTC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fynv","download_url":"https://codeload.github.com/fynv/CURandRTC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252588433,"owners_count":21772676,"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","nvrtc","random-number-generators","thrust"],"created_at":"2024-10-23T01:45:26.126Z","updated_at":"2025-05-05T22:37:38.341Z","avatar_url":"https://github.com/fynv.png","language":"C++","readme":"# CURandRTC\n\nThis is the 2nd of the series of GPU libraries based on the \n[\"NVRTC + dynamic-instantiation\" paradigm](https://fynv.github.io/ProgrammingGPUAcrossTheLaunguageBoundaries.html).\n\nThe library provides a simple random number generator using the XORWOW algorithm.\n\nThis project depends on the first of the series, [ThrustRTC](https://github.com/fynv/ThrustRTC).\n\n## Installation\n\n### Install from Source Code\n\nYou will need first get the source code of ThrustRTC and compile.\n\nBuild ThrustRTC C++ library:\n```\n$ git clone https://github.com/fynv/ThrustRTC.git\n$ cd ThrustRTC\n$ mkdir build_cpp\n$ cd build_cpp\n$ cmake ../cpp\n$ make\n$ make install\n$ cd ..\n```\n\nBuild ThrustRTC Python library:\n```\n$ mkdir build_python\n$ cd build_python\n$ cmake ../python\n$ make\n$ make install\n$ cd ..\n```\n\nBuild ThrustRTC Java library:\n```\n$ mkdir build_java\n$ cd build_java\n$ cmake ../java\n$ make\n$ make install\n$ cd ..\n```\n\nBuild ThrustRTC C# library:\n\nPlease use the Visual Studio project in the \"CSharp\" folder to build the C# library.\n\nWhen you finished building the library of the language you need, you can proceed to build this CURandRTC.\n\nFirst clone this repository, then copy the \"install\" directory from \"ThrustRTC\" to \"CURandRTC\".\n\nBuild CURandRTC C++ library:\n```\n$ git clone https://github.com/fynv/CURandRTC.git\n$ cd CURandRTC\n$ cp -r ../ThrustRTC/install .\n$ mkdir build_cpp\n$ cd build_cpp\n$ cmake ../cpp -DBUILD_TESTS=true\n$ make\n$ make install\n$ cd ..\n```\n\nBuild CURandRTC Python library:\n```\n$ mkdir build_python\n$ cd build_python\n$ cmake ../python -DINCLUDE_TESTS=true\n$ make\n$ make install\n$ cd ..\n```\n\nBuild CURandRTC Java library:\n```\n$ mkdir build_java\n$ cd build_java\n$ cmake ../java -DBUILD_TESTS=true\n$ make\n$ make install\n$ cd ..\n```\n\nBuild CURandRTC C# library:\n\nPlease use the Visual Studio project in the \"CSharp\" folder to build the C# library.\n\nYou will get the library headers, binaries and examples in the \"install\" directory.\n\n\n### Install CURandRTC for Python from Pypi\n\nBuilds for Win64/Linux64 + Python 3.7 are available from [Pypi](https://pypi.org/project/CURandRTC/)\nIf your environment matches, you can try:\n\n```\n$ pip3 install CURandRTC\n```\nYou will not get the C++ library, headers as well as all the test programs using this installation method.\n\n\n### GitHub Release\n\nZip packages are available at:\n\n[https://github.com/fynv/CURandRTC/releases](https://github.com/fynv/CURandRTC/releases)\n\nThese libraries should be used together with the ThrustRTC libraries in the correpsonding languages.\n\n\n## Examples of Usage\n\nIn C++:\n\n```cpp\n#include \u003cstdio.h\u003e\n#include \"TRTCContext.h\"\n#include \"DVVector.h\"\n#include \"DVRNG.h\" // random number generator class\n\nint main()\n{\n\tDVRNG\u0026 rng = DVRNG::singlton();\n\n\tTRTC_For ker({ \"rng\", \"vec_rnd\" }, \"idx\",\n\t\t\"    RNGState state;\\n\"\n\t\t\"    rng.state_init(1234, idx, 0, state);\\n\" // initialize a state using the rng object\n\t\t\"    vec_rnd[idx]=(float)state.rand01();\\n\" // generate random number using the rng object\n\t);\n\n\tDVVector d_vec_rnd(\"float\", 1024);\n\tconst DeviceViewable* args[] = { \u0026rng, \u0026d_vec_rnd };\n\tker.launch_n(1024, args);\n\n\t...\n}\n```\n\nIn Python:\n```python\nimport ThrustRTC as trtc\nimport CURandRTC as rndrtc\n\nrng = rndrtc.DVRNG()\n\nker = trtc.For(['rng','vec_rnd'], 'idx',\n\t'''\n    RNGState state;\n    rng.state_init(1234, idx, 0, state);  // initialize a state using the rng object\n   \tvec_rnd[idx]=(float)state.rand01(); // generate random number using the rng object\n\t''')\n\nd_vec_rnd = trtc.device_vector('float', 1024)\nker.launch_n(1024, [rng, d_vec_rnd])\n...\n```\n\nIn C#:\n```cs\nusing System;\nusing ThrustRTCSharp;\nusing CURandRTCSharp;\n\nnamespace test_rand\n{\n    class test_rand\n    {\n        static void Main(string[] args)\n        {\n            DVRNG rng = new DVRNG();\n            For ker = new For(new string[] { \"rng\", \"vec_rnd\" }, \"idx\",\n@\"\n    RNGState state;\n    rng.state_init(1234, idx, 0, state);  // initialize a state using the rng object\n    vec_rnd[idx]=(float)state.rand01(); // generate random number using the rng object \"); \n\n            DVVector d_vec_rnd = new DVVector(\"float\", 1024);\n            DeviceViewable[] kargs = new DeviceViewable[] { rng, d_vec_rnd };\n            ker.launch_n(1024, kargs);\n            ...\n\n        }\n        ...\n    }\n}\n\n```\n\nIn JAVA:\n```java\nimport java.util.*;\nimport JThrustRTC.*;\nimport JCURandRTC.*;\n\npublic class test_rand \n{\n\tpublic static void main(String[] args) \n\t{\n        DVRNG rng = new DVRNG();\n        For ker = new For(new String[] { \"rng\", \"vec_rnd\" }, \"idx\",\n        String.join(\"\",\n\t\t\"    RNGState state;\\n\",\n\t\t\"    rng.state_init(1234, idx, 0, state); // initialize a state using the rng object\\n\",\n\t\t\"    vec_rnd[idx]=(float)state.rand01(); // generate random number using the rng object \\n\"));\n\t\tDVVector d_vec_rnd = new DVVector(\"float\", 1024);\n\t\tDeviceViewable[] kargs = new DeviceViewable[] { rng, d_vec_rnd };\n\t\tker.launch_n(1024, kargs);\n\t\t...\n\t}\n}\n\n```\n\n## License \n\nI've decided to license this project under ['\"Anti 996\" License'](https://github.com/996icu/996.ICU/blob/master/LICENSE)\n\nBasically, you can use the code any way you like unless you are working for a 996 company.\n\n[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffynv%2Fcurandrtc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffynv%2Fcurandrtc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffynv%2Fcurandrtc/lists"}