
.. _program_listing_file_hiprand_hiprand.h:

Program Listing for File hiprand.h
==================================

|exhale_lsh| :ref:`Return to documentation for file <file_hiprand_hiprand.h>` (``hiprand/hiprand.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 HIPRAND_H_
   #define HIPRAND_H_
   
   #include <hip/hip_runtime.h>
   #include <hip/hip_fp16.h>
   
   #ifndef HIPRANDAPI
   #ifdef WIN32
     #ifdef hiprand_EXPORTS
     /* We are building this library */
       #define HIPRANDAPI __declspec(dllexport)
     #else
       /* We are using this library */
       #define HIPRANDAPI __declspec(dllimport)
     #endif
   #else
     #define HIPRANDAPI
   #endif
   #endif
   
   #include "hiprand/hiprand_version.h"
   #ifdef HIPRAND_DOXYGEN // Only for the documentation
   #define HIPRAND_VERSION
   #endif
   
   #if defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)
   #include "hiprand/hiprand_hcc.h"
   #elif defined(__HIP_PLATFORM_NVCC__)
   #include "hiprand/hiprand_nvcc.h"
   #endif
   
   typedef hiprandGenerator_st * hiprandGenerator_t;
   
   typedef hiprandDiscreteDistribution_st * hiprandDiscreteDistribution_t;
   
   typedef __half half;
   
   #define HIPRAND_DEFAULT_MAX_BLOCK_SIZE 256
   #define HIPRAND_DEFAULT_MIN_WARPS_PER_EU 1
   
   #if defined(__cplusplus)
   extern "C" {
   #endif /* __cplusplus */
   
   typedef enum hiprandStatus {
       HIPRAND_STATUS_SUCCESS = 0, 
       HIPRAND_STATUS_VERSION_MISMATCH = 100, 
       HIPRAND_STATUS_NOT_INITIALIZED = 101, 
       HIPRAND_STATUS_ALLOCATION_FAILED = 102, 
       HIPRAND_STATUS_TYPE_ERROR = 103, 
       HIPRAND_STATUS_OUT_OF_RANGE = 104, 
       HIPRAND_STATUS_LENGTH_NOT_MULTIPLE = 105, 
       HIPRAND_STATUS_DOUBLE_PRECISION_REQUIRED = 106, 
       HIPRAND_STATUS_LAUNCH_FAILURE = 201, 
       HIPRAND_STATUS_PREEXISTING_FAILURE = 202, 
       HIPRAND_STATUS_INITIALIZATION_FAILED = 203, 
       HIPRAND_STATUS_ARCH_MISMATCH = 204, 
       HIPRAND_STATUS_INTERNAL_ERROR = 999, 
       HIPRAND_STATUS_NOT_IMPLEMENTED = 1000 
   } hiprandStatus_t;
   
   typedef enum hiprandRngType {
       HIPRAND_RNG_TEST = 0,
       HIPRAND_RNG_PSEUDO_DEFAULT = 400, 
       HIPRAND_RNG_PSEUDO_XORWOW = 401, 
       HIPRAND_RNG_PSEUDO_MRG32K3A = 402, 
       HIPRAND_RNG_PSEUDO_MTGP32 = 403, 
       HIPRAND_RNG_PSEUDO_MT19937 = 404, 
       HIPRAND_RNG_PSEUDO_PHILOX4_32_10 = 405, 
       HIPRAND_RNG_QUASI_DEFAULT = 500, 
       HIPRAND_RNG_QUASI_SOBOL32 = 501, 
       HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 = 502,  
       HIPRAND_RNG_QUASI_SOBOL64 = 503, 
       HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64 = 504  
   } hiprandRngType_t;
   
   
   // Host API functions
   
   hiprandStatus_t HIPRANDAPI
   hiprandCreateGenerator(hiprandGenerator_t * generator, hiprandRngType_t rng_type);
   
   hiprandStatus_t HIPRANDAPI
   hiprandCreateGeneratorHost(hiprandGenerator_t * generator, hiprandRngType_t rng_type);
   
   hiprandStatus_t HIPRANDAPI
   hiprandDestroyGenerator(hiprandGenerator_t generator);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerate(hiprandGenerator_t generator,
                   unsigned int * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateChar(hiprandGenerator_t generator,
                       unsigned char * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateShort(hiprandGenerator_t generator,
                        unsigned short * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI hiprandGenerateLongLong(hiprandGenerator_t  generator,
                                                      unsigned long long* output_data,
                                                      size_t              n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateUniform(hiprandGenerator_t generator,
                          float * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateUniformDouble(hiprandGenerator_t generator,
                                double * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateUniformHalf(hiprandGenerator_t generator,
                              half * output_data, size_t n);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateNormal(hiprandGenerator_t generator,
                         float * output_data, size_t n,
                         float mean, float stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateNormalDouble(hiprandGenerator_t generator,
                               double * output_data, size_t n,
                               double mean, double stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateNormalHalf(hiprandGenerator_t generator,
                             half * output_data, size_t n,
                             half mean, half stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateLogNormal(hiprandGenerator_t generator,
                            float * output_data, size_t n,
                            float mean, float stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateLogNormalDouble(hiprandGenerator_t generator,
                                  double * output_data, size_t n,
                                  double mean, double stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateLogNormalHalf(hiprandGenerator_t generator,
                                half * output_data, size_t n,
                                half mean, half stddev);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGeneratePoisson(hiprandGenerator_t generator,
                          unsigned int * output_data, size_t n,
                          double lambda);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGenerateSeeds(hiprandGenerator_t generator);
   
   hiprandStatus_t HIPRANDAPI
   hiprandSetStream(hiprandGenerator_t generator, hipStream_t stream);
   
   hiprandStatus_t HIPRANDAPI
   hiprandSetPseudoRandomGeneratorSeed(hiprandGenerator_t generator, unsigned long long seed);
   
   hiprandStatus_t HIPRANDAPI
   hiprandSetGeneratorOffset(hiprandGenerator_t generator, unsigned long long offset);
   
   hiprandStatus_t HIPRANDAPI
   hiprandSetQuasiRandomGeneratorDimensions(hiprandGenerator_t generator, unsigned int dimensions);
   
   hiprandStatus_t HIPRANDAPI
   hiprandGetVersion(int * version);
   
   hiprandStatus_t HIPRANDAPI
   hiprandCreatePoissonDistribution(double lambda, hiprandDiscreteDistribution_t * discrete_distribution);
   
   hiprandStatus_t HIPRANDAPI
   hiprandDestroyDistribution(hiprandDiscreteDistribution_t discrete_distribution);
   
   #if defined(__cplusplus)
   }
   #endif /* __cplusplus */
   
   #endif // HIPRAND_H_
   
