/build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.h Source File

/build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.h Source File#

API library: /build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.h Source File
rocrand.h
1// Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All rights reserved.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#ifndef ROCRAND_H_
22#define ROCRAND_H_
23
28
29// IWYU pragma: begin_exports
30#include "rocrand/rocrand_discrete_types.h"
31#include "rocrand/rocrand_version.h"
32// IWYU pragma: end_exports
33
34#include "rocrand/rocrandapi.h"
35
36#include <hip/hip_fp16.h>
37#include <hip/hip_runtime.h>
38#include <hip/hip_vector_types.h>
39
42typedef struct rocrand_generator_base_type * rocrand_generator;
44
47typedef __half half;
49
51#define ROCRAND_DEFAULT_MAX_BLOCK_SIZE 256
52
53#if defined(__cplusplus)
54extern "C" {
55#endif /* __cplusplus */
56
76
79
107
110
124
127
132{
133 ROCRAND_DIRECTION_VECTORS_32_JOEKUO6 = 101,
134 ROCRAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 = 102,
135 ROCRAND_DIRECTION_VECTORS_64_JOEKUO6 = 103,
136 ROCRAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 = 104,
137};
138
141
142// Host API function
143
177rocrand_status ROCRANDAPI
178rocrand_create_generator(rocrand_generator * generator, rocrand_rng_type rng_type);
179
200rocrand_status ROCRANDAPI rocrand_create_generator_host(rocrand_generator* generator,
201 rocrand_rng_type rng_type);
202
208rocrand_status ROCRANDAPI rocrand_create_generator_host_blocking(rocrand_generator* generator,
209 rocrand_rng_type rng_type);
210
222rocrand_status ROCRANDAPI
223rocrand_destroy_generator(rocrand_generator generator);
224
245rocrand_status ROCRANDAPI
246rocrand_generate(rocrand_generator generator,
247 unsigned int * output_data, size_t n);
248
270rocrand_status ROCRANDAPI rocrand_generate_long_long(rocrand_generator generator,
271 unsigned long long int* output_data,
272 size_t n);
273
294rocrand_status ROCRANDAPI
295rocrand_generate_char(rocrand_generator generator,
296 unsigned char * output_data, size_t n);
297
318rocrand_status ROCRANDAPI
319rocrand_generate_short(rocrand_generator generator,
320 unsigned short * output_data, size_t n);
321
342rocrand_status ROCRANDAPI
343rocrand_generate_uniform(rocrand_generator generator,
344 float * output_data, size_t n);
345
366rocrand_status ROCRANDAPI
367rocrand_generate_uniform_double(rocrand_generator generator,
368 double * output_data, size_t n);
369
390rocrand_status ROCRANDAPI
391rocrand_generate_uniform_half(rocrand_generator generator,
392 half * output_data, size_t n);
393
413rocrand_status ROCRANDAPI
414rocrand_generate_normal(rocrand_generator generator,
415 float * output_data, size_t n,
416 float mean, float stddev);
417
437rocrand_status ROCRANDAPI
438rocrand_generate_normal_double(rocrand_generator generator,
439 double * output_data, size_t n,
440 double mean, double stddev);
441
461rocrand_status ROCRANDAPI
462rocrand_generate_normal_half(rocrand_generator generator,
463 half * output_data, size_t n,
464 half mean, half stddev);
465
485rocrand_status ROCRANDAPI
486rocrand_generate_log_normal(rocrand_generator generator,
487 float * output_data, size_t n,
488 float mean, float stddev);
489
509rocrand_status ROCRANDAPI
510rocrand_generate_log_normal_double(rocrand_generator generator,
511 double * output_data, size_t n,
512 double mean, double stddev);
513
533rocrand_status ROCRANDAPI
534rocrand_generate_log_normal_half(rocrand_generator generator,
535 half * output_data, size_t n,
536 half mean, half stddev);
537
557rocrand_status ROCRANDAPI
558rocrand_generate_poisson(rocrand_generator generator,
559 unsigned int * output_data, size_t n,
560 double lambda);
561
579rocrand_status ROCRANDAPI
580rocrand_initialize_generator(rocrand_generator generator);
581
595rocrand_status ROCRANDAPI
596rocrand_set_stream(rocrand_generator generator, hipStream_t stream);
597
623rocrand_status ROCRANDAPI
624rocrand_set_seed(rocrand_generator generator, unsigned long long seed);
625
648rocrand_status ROCRANDAPI rocrand_set_seed_uint4(rocrand_generator generator, uint4 seed);
649
670rocrand_status ROCRANDAPI
671rocrand_set_offset(rocrand_generator generator, unsigned long long offset);
672
701rocrand_status ROCRANDAPI rocrand_set_ordering(rocrand_generator generator, rocrand_ordering order);
702
721rocrand_status ROCRANDAPI
723 unsigned int dimensions);
724
737rocrand_status ROCRANDAPI
738rocrand_get_version(int * version);
739
754rocrand_status ROCRANDAPI
756 rocrand_discrete_distribution * discrete_distribution);
757
776rocrand_status ROCRANDAPI
777rocrand_create_discrete_distribution(const double * probabilities,
778 unsigned int size,
779 unsigned int offset,
780 rocrand_discrete_distribution * discrete_distribution);
781
794rocrand_status ROCRANDAPI
795rocrand_destroy_discrete_distribution(rocrand_discrete_distribution discrete_distribution);
796
808rocrand_status ROCRANDAPI rocrand_get_direction_vectors32(const unsigned int** vectors,
810
822rocrand_status ROCRANDAPI rocrand_get_direction_vectors64(const unsigned long long** vectors,
824
833rocrand_status ROCRANDAPI rocrand_get_scramble_constants32(const unsigned int** constants);
834
843rocrand_status ROCRANDAPI rocrand_get_scramble_constants64(const unsigned long long** constants);
844
845#if defined(__cplusplus)
846}
847#endif /* __cplusplus */
848 // end of group rocrandhost
850
851#endif // ROCRAND_H_
rocrand_status ROCRANDAPI rocrand_create_poisson_distribution(double lambda, rocrand_discrete_distribution *discrete_distribution)
Construct the histogram for a Poisson distribution.
rocrand_status ROCRANDAPI rocrand_generate_short(rocrand_generator generator, unsigned short *output_data, size_t n)
Generates uniformly distributed 16-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_normal(rocrand_generator generator, float *output_data, size_t n, float mean, float stddev)
Generates normally distributed float values.
rocrand_status ROCRANDAPI rocrand_set_offset(rocrand_generator generator, unsigned long long offset)
Sets the offset of a random number generator.
rocrand_status ROCRANDAPI rocrand_create_generator_host_blocking(rocrand_generator *generator, rocrand_rng_type rng_type)
Creates a new host random number generator, similar to rocrand_create_generator_host....
rocrand_status ROCRANDAPI rocrand_initialize_generator(rocrand_generator generator)
Initializes the generator's state on GPU or host.
rocrand_status ROCRANDAPI rocrand_get_direction_vectors32(const unsigned int **vectors, rocrand_direction_vector_set set)
Get the vector for 32-bit (scrambled-)sobol generation.
rocrand_status ROCRANDAPI rocrand_create_generator_host(rocrand_generator *generator, rocrand_rng_type rng_type)
Creates a new host random number generator.
rocrand_status ROCRANDAPI rocrand_generate_normal_double(rocrand_generator generator, double *output_data, size_t n, double mean, double stddev)
Generates normally distributed double values.
rocrand_ordering
rocRAND generator ordering
Definition rocrand.h:115
rocrand_status ROCRANDAPI rocrand_generate_char(rocrand_generator generator, unsigned char *output_data, size_t n)
Generates uniformly distributed 8-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_log_normal(rocrand_generator generator, float *output_data, size_t n, float mean, float stddev)
Generates log-normally distributed float values.
rocrand_status
rocRAND function call status type
Definition rocrand.h:61
rocrand_status ROCRANDAPI rocrand_create_generator(rocrand_generator *generator, rocrand_rng_type rng_type)
Creates a new random number generator.
rocrand_rng_type
rocRAND generator type
Definition rocrand.h:84
rocrand_status ROCRANDAPI rocrand_generate_long_long(rocrand_generator generator, unsigned long long int *output_data, size_t n)
Generates uniformly distributed 64-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_uniform_half(rocrand_generator generator, half *output_data, size_t n)
Generates uniformly distributed half-precision floating-point values.
rocrand_status ROCRANDAPI rocrand_set_stream(rocrand_generator generator, hipStream_t stream)
Sets the current stream for kernel launches.
rocrand_status ROCRANDAPI rocrand_generate_normal_half(rocrand_generator generator, half *output_data, size_t n, half mean, half stddev)
Generates normally distributed half values.
rocrand_status ROCRANDAPI rocrand_get_scramble_constants32(const unsigned int **constants)
Get the scramble constants for 32-bit scrambled sobol generation.
rocrand_status ROCRANDAPI rocrand_generate_uniform_double(rocrand_generator generator, double *output_data, size_t n)
Generates uniformly distributed double-precision floating-point values.
rocrand_status ROCRANDAPI rocrand_get_direction_vectors64(const unsigned long long **vectors, rocrand_direction_vector_set set)
Get the vector for 64-bit (scrambled-)sobol generation.
rocrand_status ROCRANDAPI rocrand_generate_uniform(rocrand_generator generator, float *output_data, size_t n)
Generates uniformly distributed float values.
rocrand_status ROCRANDAPI rocrand_create_discrete_distribution(const double *probabilities, unsigned int size, unsigned int offset, rocrand_discrete_distribution *discrete_distribution)
Construct the histogram for a custom discrete distribution.
rocrand_status ROCRANDAPI rocrand_set_ordering(rocrand_generator generator, rocrand_ordering order)
Sets the ordering of a random number generator.
rocrand_status ROCRANDAPI rocrand_generate_poisson(rocrand_generator generator, unsigned int *output_data, size_t n, double lambda)
Generates Poisson-distributed 32-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_set_quasi_random_generator_dimensions(rocrand_generator generator, unsigned int dimensions)
Set the number of dimensions of a quasi-random number generator.
rocrand_status ROCRANDAPI rocrand_get_version(int *version)
Returns the version number of the library.
rocrand_status ROCRANDAPI rocrand_set_seed_uint4(rocrand_generator generator, uint4 seed)
Sets the seeds of a pseudo-random number generator.
rocrand_status ROCRANDAPI rocrand_generate(rocrand_generator generator, unsigned int *output_data, size_t n)
Generates uniformly distributed 32-bit unsigned integers.
rocrand_direction_vector_set
rocRAND vector set
Definition rocrand.h:132
rocrand_status ROCRANDAPI rocrand_destroy_discrete_distribution(rocrand_discrete_distribution discrete_distribution)
Destroy the histogram array for a discrete distribution.
rocrand_status ROCRANDAPI rocrand_generate_log_normal_double(rocrand_generator generator, double *output_data, size_t n, double mean, double stddev)
Generates log-normally distributed double values.
rocrand_status ROCRANDAPI rocrand_set_seed(rocrand_generator generator, unsigned long long seed)
Sets the seed of a pseudo-random number generator.
rocrand_status ROCRANDAPI rocrand_get_scramble_constants64(const unsigned long long **constants)
Get the scramble constants for 64-bit scrambled sobol generation.
rocrand_status ROCRANDAPI rocrand_generate_log_normal_half(rocrand_generator generator, half *output_data, size_t n, half mean, half stddev)
Generates log-normally distributed half values.
rocrand_status ROCRANDAPI rocrand_destroy_generator(rocrand_generator generator)
Destroys random number generator.
@ ROCRAND_ORDERING_PSEUDO_DEFAULT
Default ordering for pseudorandom results.
Definition rocrand.h:117
@ ROCRAND_ORDERING_QUASI_DEFAULT
n-dimensional ordering for quasirandom results
Definition rocrand.h:122
@ ROCRAND_ORDERING_PSEUDO_SEEDED
Fast lower quality pseudorandom results.
Definition rocrand.h:118
@ ROCRAND_ORDERING_PSEUDO_DYNAMIC
Adjust to the device executing the generator. The global memory usage may be higher than with the oth...
Definition rocrand.h:120
@ ROCRAND_ORDERING_PSEUDO_BEST
Best ordering for pseudorandom results.
Definition rocrand.h:116
@ ROCRAND_ORDERING_PSEUDO_LEGACY
Legacy ordering for pseudorandom results.
Definition rocrand.h:119
@ ROCRAND_STATUS_NOT_CREATED
Generator was not created using rocrand_create_generator.
Definition rocrand.h:64
@ ROCRAND_STATUS_LAUNCH_FAILURE
Kernel launch failure.
Definition rocrand.h:73
@ ROCRAND_STATUS_VERSION_MISMATCH
Header file and linked library version do not match.
Definition rocrand.h:63
@ ROCRAND_STATUS_LENGTH_NOT_MULTIPLE
Definition rocrand.h:68
@ ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED
GPU does not have double precision.
Definition rocrand.h:72
@ ROCRAND_STATUS_SUCCESS
No errors.
Definition rocrand.h:62
@ ROCRAND_STATUS_INTERNAL_ERROR
Internal library error.
Definition rocrand.h:74
@ ROCRAND_STATUS_OUT_OF_RANGE
Argument out of range.
Definition rocrand.h:67
@ ROCRAND_STATUS_ALLOCATION_FAILED
Memory allocation failed during execution.
Definition rocrand.h:65
@ ROCRAND_STATUS_TYPE_ERROR
Generator type is wrong.
Definition rocrand.h:66
@ ROCRAND_RNG_PSEUDO_DEFAULT
Default pseudorandom generator.
Definition rocrand.h:85
@ ROCRAND_RNG_QUASI_SOBOL64
Sobol64 quasirandom generator.
Definition rocrand.h:104
@ ROCRAND_RNG_PSEUDO_LFSR113
LFSR113 pseudorandom generator.
Definition rocrand.h:91
@ ROCRAND_RNG_PSEUDO_THREEFRY2_64_20
ThreeFry 64 bit state size 2 pseudorandom generator.
Definition rocrand.h:95
@ ROCRAND_RNG_QUASI_DEFAULT
Default quasirandom generator.
Definition rocrand.h:101
@ ROCRAND_RNG_PSEUDO_XORWOW
XORWOW pseudorandom generator.
Definition rocrand.h:86
@ ROCRAND_RNG_PSEUDO_THREEFRY4_32_20
ThreeFry 32 bit state size 4 pseudorandom generator.
Definition rocrand.h:97
@ ROCRAND_RNG_PSEUDO_MRG31K3P
MRG31k3p pseudorandom generator.
Definition rocrand.h:90
@ ROCRAND_RNG_PSEUDO_MT19937
Mersenne Twister MT19937 pseudorandom generator.
Definition rocrand.h:92
@ ROCRAND_RNG_PSEUDO_PHILOX4_32_10
PHILOX-4x32-10 pseudorandom generator.
Definition rocrand.h:89
@ ROCRAND_RNG_PSEUDO_THREEFRY2_32_20
ThreeFry 32 bit state size 2 pseudorandom generator.
Definition rocrand.h:93
@ ROCRAND_RNG_PSEUDO_THREEFRY4_64_20
ThreeFry 64 bit state size 4 pseudorandom generator.
Definition rocrand.h:99
@ ROCRAND_RNG_PSEUDO_MTGP32
Mersenne Twister MTGP32 pseudorandom generator.
Definition rocrand.h:88
@ ROCRAND_RNG_QUASI_SOBOL32
Sobol32 quasirandom generator.
Definition rocrand.h:102
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32
Scrambled Sobol32 quasirandom generator.
Definition rocrand.h:103
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64
Scrambled Sobol64 quasirandom generator.
Definition rocrand.h:105
@ ROCRAND_RNG_PSEUDO_MRG32K3A
MRG32k3a pseudorandom generator.
Definition rocrand.h:87