
.. _program_listing_file_library_include_rocrand_rocrand.h:

Program Listing for File rocrand.h
==================================

|exhale_lsh| :ref:`Return to documentation for file <file_library_include_rocrand_rocrand.h>` (``library/include/rocrand/rocrand.h``)

.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS

.. code-block:: cpp

   // Copyright (c) 2017-2022 Advanced Micro Devices, Inc. All rights reserved.
   //
   // Permission is hereby granted, free of charge, to any person obtaining a copy
   // of this software and associated documentation files (the "Software"), to deal
   // in the Software without restriction, including without limitation the rights
   // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   // copies of the Software, and to permit persons to whom the Software is
   // furnished to do so, subject to the following conditions:
   //
   // The above copyright notice and this permission notice shall be included in
   // all copies or substantial portions of the Software.
   //
   // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
   // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   // THE SOFTWARE.
   
   #ifndef ROCRAND_H_
   #define ROCRAND_H_
   
   #include "rocrand/rocrand_discrete_types.h"
   #include "rocrand/rocrand_hip_cpu.h"
   
   #include <hip/hip_fp16.h>
   #include <hip/hip_runtime.h>
   #include <hip/hip_vector_types.h>
   
   #include "rocrand/rocrandapi.h"
   
   #include "rocrand/rocrand_version.h"
   
   typedef struct rocrand_generator_base_type * rocrand_generator;
   
   typedef __half half;
   
   #define ROCRAND_DEFAULT_MAX_BLOCK_SIZE 256
   
   #if defined(__cplusplus)
   extern "C" {
   #endif /* __cplusplus */
   
   typedef enum rocrand_status {
       ROCRAND_STATUS_SUCCESS = 0, 
       ROCRAND_STATUS_VERSION_MISMATCH = 100, 
       ROCRAND_STATUS_NOT_CREATED = 101, 
       ROCRAND_STATUS_ALLOCATION_FAILED = 102, 
       ROCRAND_STATUS_TYPE_ERROR = 103, 
       ROCRAND_STATUS_OUT_OF_RANGE = 104, 
       ROCRAND_STATUS_LENGTH_NOT_MULTIPLE = 105, 
       ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED = 106, 
       ROCRAND_STATUS_LAUNCH_FAILURE = 107, 
       ROCRAND_STATUS_INTERNAL_ERROR = 108 
   } rocrand_status;
   
   typedef enum rocrand_rng_type
   {
       ROCRAND_RNG_PSEUDO_DEFAULT       = 400, 
       ROCRAND_RNG_PSEUDO_XORWOW        = 401, 
       ROCRAND_RNG_PSEUDO_MRG32K3A      = 402, 
       ROCRAND_RNG_PSEUDO_MTGP32        = 403, 
       ROCRAND_RNG_PSEUDO_PHILOX4_32_10 = 404, 
       ROCRAND_RNG_PSEUDO_MRG31K3P      = 405, 
       ROCRAND_RNG_PSEUDO_LFSR113       = 406, 
       ROCRAND_RNG_PSEUDO_MT19937       = 407, 
       ROCRAND_RNG_PSEUDO_THREEFRY2_32_20
       = 408, 
       ROCRAND_RNG_PSEUDO_THREEFRY2_64_20
       = 409, 
       ROCRAND_RNG_PSEUDO_THREEFRY4_32_20
       = 410, 
       ROCRAND_RNG_PSEUDO_THREEFRY4_64_20
       = 411, 
       ROCRAND_RNG_QUASI_DEFAULT           = 500, 
       ROCRAND_RNG_QUASI_SOBOL32           = 501, 
       ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32 = 502, 
       ROCRAND_RNG_QUASI_SOBOL64           = 504, 
       ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64 = 505 
   
   } rocrand_rng_type;
   
   typedef enum rocrand_ordering
   {
       ROCRAND_ORDERING_PSEUDO_BEST    = 100, 
       ROCRAND_ORDERING_PSEUDO_DEFAULT = 101, 
       ROCRAND_ORDERING_PSEUDO_SEEDED  = 102, 
       ROCRAND_ORDERING_PSEUDO_LEGACY  = 103, 
       ROCRAND_ORDERING_PSEUDO_DYNAMIC = 104, 
       ROCRAND_ORDERING_QUASI_DEFAULT  = 201 
   } rocrand_ordering;
   
   // Host API function
   
   rocrand_status ROCRANDAPI
   rocrand_create_generator(rocrand_generator * generator, rocrand_rng_type rng_type);
   
   rocrand_status ROCRANDAPI
   rocrand_destroy_generator(rocrand_generator generator);
   
   rocrand_status ROCRANDAPI
   rocrand_generate(rocrand_generator generator,
                    unsigned int * output_data, size_t n);
   
   rocrand_status ROCRANDAPI rocrand_generate_long_long(rocrand_generator       generator,
                                                        unsigned long long int* output_data,
                                                        size_t                  n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_char(rocrand_generator generator,
                         unsigned char * output_data, size_t n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_short(rocrand_generator generator,
                          unsigned short * output_data, size_t n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_uniform(rocrand_generator generator,
                            float * output_data, size_t n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_uniform_double(rocrand_generator generator,
                                   double * output_data, size_t n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_uniform_half(rocrand_generator generator,
                                 half * output_data, size_t n);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_normal(rocrand_generator generator,
                           float * output_data, size_t n,
                           float mean, float stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_normal_double(rocrand_generator generator,
                                  double * output_data, size_t n,
                                  double mean, double stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_normal_half(rocrand_generator generator,
                                half * output_data, size_t n,
                                half mean, half stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_log_normal(rocrand_generator generator,
                               float * output_data, size_t n,
                               float mean, float stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_log_normal_double(rocrand_generator generator,
                                      double * output_data, size_t n,
                                      double mean, double stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_log_normal_half(rocrand_generator generator,
                                    half * output_data, size_t n,
                                    half mean, half stddev);
   
   rocrand_status ROCRANDAPI
   rocrand_generate_poisson(rocrand_generator generator,
                            unsigned int * output_data, size_t n,
                            double lambda);
   
   rocrand_status ROCRANDAPI
   rocrand_initialize_generator(rocrand_generator generator);
   
   rocrand_status ROCRANDAPI
   rocrand_set_stream(rocrand_generator generator, hipStream_t stream);
   
   rocrand_status ROCRANDAPI
   rocrand_set_seed(rocrand_generator generator, unsigned long long seed);
   
   rocrand_status ROCRANDAPI rocrand_set_seed_uint4(rocrand_generator generator, uint4 seed);
   
   rocrand_status ROCRANDAPI
   rocrand_set_offset(rocrand_generator generator, unsigned long long offset);
   
   rocrand_status ROCRANDAPI rocrand_set_ordering(rocrand_generator generator, rocrand_ordering order);
   
   rocrand_status ROCRANDAPI
   rocrand_set_quasi_random_generator_dimensions(rocrand_generator generator,
                                                 unsigned int dimensions);
   
   rocrand_status ROCRANDAPI
   rocrand_get_version(int * version);
   
   rocrand_status ROCRANDAPI
   rocrand_create_poisson_distribution(double lambda,
                                       rocrand_discrete_distribution * discrete_distribution);
   
   rocrand_status ROCRANDAPI
   rocrand_create_discrete_distribution(const double * probabilities,
                                        unsigned int size,
                                        unsigned int offset,
                                        rocrand_discrete_distribution * discrete_distribution);
   
   rocrand_status ROCRANDAPI
   rocrand_destroy_discrete_distribution(rocrand_discrete_distribution discrete_distribution);
   
   #if defined(__cplusplus)
   }
   #endif /* __cplusplus */
   
    // end of group rocrandhost
   #endif // ROCRAND_H_
