Skip to content

Commit

Permalink
Add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vxst committed Aug 21, 2023
1 parent 67e0f8f commit 2a1f0ba
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ int main(){
}
```

Or you can use the callable object as a drop in replacement for rand function:

```c++
#include <iostream>
#include "qrand.h"

int main(){
qrand randq;
for(int i = 0; i < 10; i++){
std::cout << randq() << " " << randq() % 100 << std::endl;
}
}
```

There is no global state, so it's thread safe as long as it's thread local:

```c++
void some_thread_function(){
static thread_local qrand randq;
// call randq
}
```

Or in OpenMP

```c++
extern qrand randq;
#pragma omp threadprivate(randq)
qrand randq;
```

To use the qrand library, simply include the header file `qrand.h`. The
qrand uses VAES or AES-NI instructions to accelerate the random number
generation. So it need to be compiled with either `-maes` or `-mvaes` option.
Expand Down

0 comments on commit 2a1f0ba

Please sign in to comment.