{"id":16572752,"url":"https://github.com/lemire/simdxorshift","last_synced_at":"2025-03-16T20:31:30.186Z","repository":{"id":66054943,"uuid":"55607349","full_name":"lemire/SIMDxorshift","owner":"lemire","description":"Fast random number generators: Vectorized (SIMD) version of xorshift128+","archived":false,"fork":false,"pushed_at":"2020-07-22T16:31:10.000Z","size":35,"stargazers_count":113,"open_issues_count":1,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-16T05:31:46.037Z","etag":null,"topics":["prng","simd","simd-instructions","xorshift"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemire.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,"publiccode":null,"codemeta":null}},"created_at":"2016-04-06T13:15:41.000Z","updated_at":"2025-03-09T17:00:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"6517811d-9ffa-443d-85ff-0723044225c6","html_url":"https://github.com/lemire/SIMDxorshift","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSIMDxorshift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSIMDxorshift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSIMDxorshift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2FSIMDxorshift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemire","download_url":"https://codeload.github.com/lemire/SIMDxorshift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243928358,"owners_count":20370278,"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":["prng","simd","simd-instructions","xorshift"],"created_at":"2024-10-11T21:28:29.995Z","updated_at":"2025-03-16T20:31:30.178Z","avatar_url":"https://github.com/lemire.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SIMDxorshift\n\n\n Xorshift are a family of pseudo-random number generators (RNG) invented by\n Marsaglia.\n\n https://en.wikipedia.org/wiki/Xorshift\n\n\nWe present   a vectorized version of xorshift128+, a popular random-number generator\npart of this family. It is written in C. The implementation uses Intel's SIMD\ninstructions and is based on Vigna's original (pure C) implementation.\n\nAs a random number generator, xorshift128+ is not very strong. [It fails statistical\ntests such as BigCrush](https://lemire.me/blog/2017/09/08/the-xorshift128-random-number-generator-fails-bigcrush/). It should never be\nused alone in applications where the quality of the random numbers matters a great\ndeal. However, when you just want fast and \"good enough\" random numbers, it should\ndo well.\n\nSince speed is the primary benefit of xorshift128+, then it is tempting to accelerate\nit further using vector instructions.\n\n[This library is used by the Yandex ClickHouse high-performance data engine](https://github.com/ClickHouse/ClickHouse).\n\n## Prerequisite\n\nYou should have a recent Intel processor (Haswell or better). If you bought your\nPC before everyone on Earth had a smartphone, it is probably too old a PC. Please\nupgrade.\n\nYour compiler supports C99, right? C99 stands for 1999. That was almost 20 years ago.\n\n## Code sample\n\n```C\n#include \"simdxorshift128plus.h\"\n\n// create a new key\navx_xorshift128plus_key_t mykey;\navx_xorshift128plus_init(324,4444,\u0026mykey); // values 324, 4444 are arbitrary, must be non-zero\n\n// generate 32 random bytes, do this as many times as you want\n__m256i randomstuff =  avx_xorshift128plus(\u0026mykey);\n```\n\n## Usage \n\n```bash\n$ make\n$ ./fillarray\nGenerating 5000 32-bit random numbers\nTime reported in number of cycles per array element.\nWe store values to an array of size = 19 kB.\n\nWe just generate the random numbers:\npopulateRandom_xorshift128plus(prec, size):  3.63 cycles per operation\npopulateRandom_avx_xorshift128plus(prec, size):  2.21 cycles per operation\npopulateRandom_avx_xorshift128plus_two(prec, size):  1.88 cycles per operation\npopulateRandom_avx512_xorshift128plus_two(prec, size):  1.47 cycles per operation\n\n```\n\n(Tests on a Skylake-X processor.)\n\n\n## Shallow analysis\n\nSIMD random-number generation is something like twice as fast as plain C random number\ngeneration. However on algorithms such as random shuffling, the benefits of faster random number generation\nare lesser because other bottlenecks arise. \n\nFor the most part however, the application of SIMD instructions for random number generation is \"free\"\nif the CPU supports it.\n\n## Related work\n\n* [Vectorized version of the PCG random number generator](https://github.com/lemire/simdpcg)\n\n## Reference\n\nVigna's xorshift128+ implementation http://xorshift.di.unimi.it/xorshift128plus.c\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fsimdxorshift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemire%2Fsimdxorshift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fsimdxorshift/lists"}