2 /* Copyright 2010-2014 NVIDIA Corporation. All rights reserved.
6 * The source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
10 * The Licensed Deliverables contained herein are PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and are being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee. Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
34 * U.S. Government End Users. These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
39 * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
50 #if !defined(CURAND_H_)
54 * \defgroup HOST Host API
59 #include <cuda_runtime.h>
63 #define CURANDAPI __stdcall
69 #if defined(__cplusplus)
71 #endif /* __cplusplus */
73 /* CURAND Host API datatypes */
80 * CURAND function call status types
83 CURAND_STATUS_SUCCESS = 0, ///< No errors
84 CURAND_STATUS_VERSION_MISMATCH = 100, ///< Header file and linked library version do not match
85 CURAND_STATUS_NOT_INITIALIZED = 101, ///< Generator not initialized
86 CURAND_STATUS_ALLOCATION_FAILED = 102, ///< Memory allocation failed
87 CURAND_STATUS_TYPE_ERROR = 103, ///< Generator is wrong type
88 CURAND_STATUS_OUT_OF_RANGE = 104, ///< Argument out of range
89 CURAND_STATUS_LENGTH_NOT_MULTIPLE = 105, ///< Length requested is not a multple of dimension
90 CURAND_STATUS_DOUBLE_PRECISION_REQUIRED = 106, ///< GPU does not have double precision required by MRG32k3a
91 CURAND_STATUS_LAUNCH_FAILURE = 201, ///< Kernel launch failure
92 CURAND_STATUS_PREEXISTING_FAILURE = 202, ///< Preexisting failure on library entry
93 CURAND_STATUS_INITIALIZATION_FAILED = 203, ///< Initialization of CUDA failed
94 CURAND_STATUS_ARCH_MISMATCH = 204, ///< Architecture mismatch, GPU does not support requested feature
95 CURAND_STATUS_INTERNAL_ERROR = 999 ///< Internal library error
99 * CURAND function call status types
101 /** \cond UNHIDE_TYPEDEFS */
102 typedef enum curandStatus curandStatus_t;
106 * CURAND generator types
110 CURAND_RNG_PSEUDO_DEFAULT = 100, ///< Default pseudorandom generator
111 CURAND_RNG_PSEUDO_XORWOW = 101, ///< XORWOW pseudorandom generator
112 CURAND_RNG_PSEUDO_MRG32K3A = 121, ///< MRG32k3a pseudorandom generator
113 CURAND_RNG_PSEUDO_MTGP32 = 141, ///< Mersenne Twister MTGP32 pseudorandom generator
114 CURAND_RNG_PSEUDO_MT19937 = 142, ///< Mersenne Twister MT19937 pseudorandom generator
115 CURAND_RNG_PSEUDO_PHILOX4_32_10 = 161, ///< PHILOX-4x32-10 pseudorandom generator
116 CURAND_RNG_QUASI_DEFAULT = 200, ///< Default quasirandom generator
117 CURAND_RNG_QUASI_SOBOL32 = 201, ///< Sobol32 quasirandom generator
118 CURAND_RNG_QUASI_SCRAMBLED_SOBOL32 = 202, ///< Scrambled Sobol32 quasirandom generator
119 CURAND_RNG_QUASI_SOBOL64 = 203, ///< Sobol64 quasirandom generator
120 CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 = 204 ///< Scrambled Sobol64 quasirandom generator
124 * CURAND generator types
126 /** \cond UNHIDE_TYPEDEFS */
127 typedef enum curandRngType curandRngType_t;
131 * CURAND ordering of results in memory
133 enum curandOrdering {
134 CURAND_ORDERING_PSEUDO_BEST = 100, ///< Best ordering for pseudorandom results
135 CURAND_ORDERING_PSEUDO_DEFAULT = 101, ///< Specific default 4096 thread sequence for pseudorandom results
136 CURAND_ORDERING_PSEUDO_SEEDED = 102, ///< Specific seeding pattern for fast lower quality pseudorandom results
137 CURAND_ORDERING_QUASI_DEFAULT = 201 ///< Specific n-dimensional ordering for quasirandom results
141 * CURAND ordering of results in memory
143 /** \cond UNHIDE_TYPEDEFS */
144 typedef enum curandOrdering curandOrdering_t;
148 * CURAND choice of direction vector set
150 enum curandDirectionVectorSet {
151 CURAND_DIRECTION_VECTORS_32_JOEKUO6 = 101, ///< Specific set of 32-bit direction vectors generated from polynomials recommended by S. Joe and F. Y. Kuo, for up to 20,000 dimensions
152 CURAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 = 102, ///< Specific set of 32-bit direction vectors generated from polynomials recommended by S. Joe and F. Y. Kuo, for up to 20,000 dimensions, and scrambled
153 CURAND_DIRECTION_VECTORS_64_JOEKUO6 = 103, ///< Specific set of 64-bit direction vectors generated from polynomials recommended by S. Joe and F. Y. Kuo, for up to 20,000 dimensions
154 CURAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 = 104 ///< Specific set of 64-bit direction vectors generated from polynomials recommended by S. Joe and F. Y. Kuo, for up to 20,000 dimensions, and scrambled
158 * CURAND choice of direction vector set
160 /** \cond UNHIDE_TYPEDEFS */
161 typedef enum curandDirectionVectorSet curandDirectionVectorSet_t;
165 * CURAND array of 32-bit direction vectors
167 /** \cond UNHIDE_TYPEDEFS */
168 typedef unsigned int curandDirectionVectors32_t[32];
172 * CURAND array of 64-bit direction vectors
174 /** \cond UNHIDE_TYPEDEFS */
175 typedef unsigned long long curandDirectionVectors64_t[64];
179 * CURAND generator (opaque)
181 struct curandGenerator_st;
186 /** \cond UNHIDE_TYPEDEFS */
187 typedef struct curandGenerator_st *curandGenerator_t;
191 * CURAND distribution
193 /** \cond UNHIDE_TYPEDEFS */
194 typedef double curandDistribution_st;
195 typedef curandDistribution_st *curandDistribution_t;
196 typedef struct curandDistributionShift_st *curandDistributionShift_t;
199 * CURAND distribution M2
201 /** \cond UNHIDE_TYPEDEFS */
202 typedef struct curandDistributionM2Shift_st *curandDistributionM2Shift_t;
203 typedef struct curandHistogramM2_st *curandHistogramM2_t;
204 typedef unsigned int curandHistogramM2K_st;
205 typedef curandHistogramM2K_st *curandHistogramM2K_t;
206 typedef curandDistribution_st curandHistogramM2V_st;
207 typedef curandHistogramM2V_st *curandHistogramM2V_t;
209 typedef struct curandDiscreteDistribution_st *curandDiscreteDistribution_t;
215 /** \cond UNHIDE_ENUMS */
217 CURAND_CHOOSE_BEST = 0, // choose best depends on args
223 CURAND_BINARY_SEARCH = 6,
224 CURAND_DISCRETE_GAUSS = 7,
225 CURAND_REJECTION = 8,
226 CURAND_DEVICE_API = 9,
227 CURAND_FAST_REJECTION = 10,
229 CURAND_DEFINITION = 12,
233 typedef enum curandMethod curandMethod_t;
241 * \brief Create new random number generator.
243 * Creates a new random number generator of type \p rng_type
244 * and returns it in \p *generator.
246 * Legal values for \p rng_type are:
247 * - CURAND_RNG_PSEUDO_DEFAULT
248 * - CURAND_RNG_PSEUDO_XORWOW
249 * - CURAND_RNG_PSEUDO_MRG32K3A
250 * - CURAND_RNG_PSEUDO_MTGP32
251 * - CURAND_RNG_PSEUDO_MT19937
252 * - CURAND_RNG_PSEUDO_PHILOX4_32_10
253 * - CURAND_RNG_QUASI_DEFAULT
254 * - CURAND_RNG_QUASI_SOBOL32
255 * - CURAND_RNG_QUASI_SCRAMBLED_SOBOL32
256 * - CURAND_RNG_QUASI_SOBOL64
257 * - CURAND_RNG_QUASI_SCRAMBLED_SOBOL64
259 * When \p rng_type is CURAND_RNG_PSEUDO_DEFAULT, the type chosen
260 * is CURAND_RNG_PSEUDO_XORWOW. \n
261 * When \p rng_type is CURAND_RNG_QUASI_DEFAULT,
262 * the type chosen is CURAND_RNG_QUASI_SOBOL32.
264 * The default values for \p rng_type = CURAND_RNG_PSEUDO_XORWOW are:
267 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
269 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MRG32K3A are:
272 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
274 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MTGP32 are:
277 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
279 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MT19937 are:
282 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
284 * * The default values for \p rng_type = CURAND_RNG_PSEUDO_PHILOX4_32_10 are:
287 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
289 * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL32 are:
290 * - \p dimensions = 1
292 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
294 * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL64 are:
295 * - \p dimensions = 1
297 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
299 * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBBLED_SOBOL32 are:
300 * - \p dimensions = 1
302 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
304 * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 are:
305 * - \p dimensions = 1
307 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
309 * \param generator - Pointer to generator
310 * \param rng_type - Type of generator to create
313 * - CURAND_STATUS_ALLOCATION_FAILED, if memory could not be allocated \n
314 * - CURAND_STATUS_INITIALIZATION_FAILED if there was a problem setting up the GPU \n
315 * - CURAND_STATUS_VERSION_MISMATCH if the header file version does not match the
316 * dynamically linked library version \n
317 * - CURAND_STATUS_TYPE_ERROR if the value for \p rng_type is invalid \n
318 * - CURAND_STATUS_SUCCESS if generator was created successfully \n
321 curandStatus_t CURANDAPI
322 curandCreateGenerator(curandGenerator_t *generator, curandRngType_t rng_type);
325 * \brief Create new host CPU random number generator.
327 * Creates a new host CPU random number generator of type \p rng_type
328 * and returns it in \p *generator.
330 * Legal values for \p rng_type are:
331 * - CURAND_RNG_PSEUDO_DEFAULT
332 * - CURAND_RNG_PSEUDO_XORWOW
333 * - CURAND_RNG_PSEUDO_MRG32K3A
334 * - CURAND_RNG_PSEUDO_MTGP32
335 * - CURAND_RNG_PSEUDO_MT19937
336 * - CURAND_RNG_PSEUDO_PHILOX4_32_10
337 * - CURAND_RNG_QUASI_DEFAULT
338 * - CURAND_RNG_QUASI_SOBOL32
340 * When \p rng_type is CURAND_RNG_PSEUDO_DEFAULT, the type chosen
341 * is CURAND_RNG_PSEUDO_XORWOW. \n
342 * When \p rng_type is CURAND_RNG_QUASI_DEFAULT,
343 * the type chosen is CURAND_RNG_QUASI_SOBOL32.
345 * The default values for \p rng_type = CURAND_RNG_PSEUDO_XORWOW are:
348 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
350 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MRG32K3A are:
353 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
355 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MTGP32 are:
358 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
360 * The default values for \p rng_type = CURAND_RNG_PSEUDO_MT19937 are:
363 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
365 * * The default values for \p rng_type = CURAND_RNG_PSEUDO_PHILOX4_32_10 are:
368 * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
370 * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL32 are:
371 * - \p dimensions = 1
373 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
375 * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL64 are:
376 * - \p dimensions = 1
378 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
380 * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL32 are:
381 * - \p dimensions = 1
383 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
385 * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 are:
386 * - \p dimensions = 1
388 * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
390 * \param generator - Pointer to generator
391 * \param rng_type - Type of generator to create
394 * - CURAND_STATUS_ALLOCATION_FAILED if memory could not be allocated \n
395 * - CURAND_STATUS_INITIALIZATION_FAILED if there was a problem setting up the GPU \n
396 * - CURAND_STATUS_VERSION_MISMATCH if the header file version does not match the
397 * dynamically linked library version \n
398 * - CURAND_STATUS_TYPE_ERROR if the value for \p rng_type is invalid \n
399 * - CURAND_STATUS_SUCCESS if generator was created successfully \n
401 curandStatus_t CURANDAPI
402 curandCreateGeneratorHost(curandGenerator_t *generator, curandRngType_t rng_type);
405 * \brief Destroy an existing generator.
407 * Destroy an existing generator and free all memory associated with its state.
409 * \param generator - Generator to destroy
412 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
413 * - CURAND_STATUS_SUCCESS if generator was destroyed successfully \n
415 curandStatus_t CURANDAPI
416 curandDestroyGenerator(curandGenerator_t generator);
419 * \brief Return the version number of the library.
421 * Return in \p *version the version number of the dynamically linked CURAND
422 * library. The format is the same as CUDART_VERSION from the CUDA Runtime.
423 * The only supported configuration is CURAND version equal to CUDA Runtime
426 * \param version - CURAND library version
429 * - CURAND_STATUS_SUCCESS if the version number was successfully returned \n
431 curandStatus_t CURANDAPI
432 curandGetVersion(int *version);
435 * \brief Set the current stream for CURAND kernel launches.
437 * Set the current stream for CURAND kernel launches. All library functions
438 * will use this stream until set again.
440 * \param generator - Generator to modify
441 * \param stream - Stream to use or ::NULL for null stream
444 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
445 * - CURAND_STATUS_SUCCESS if stream was set successfully \n
447 curandStatus_t CURANDAPI
448 curandSetStream(curandGenerator_t generator, cudaStream_t stream);
451 * \brief Set the seed value of the pseudo-random number generator.
453 * Set the seed value of the pseudorandom number generator.
454 * All values of seed are valid. Different seeds will produce different sequences.
455 * Different seeds will often not be statistically correlated with each other,
456 * but some pairs of seed values may generate sequences which are statistically correlated.
458 * \param generator - Generator to modify
459 * \param seed - Seed value
462 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
463 * - CURAND_STATUS_TYPE_ERROR if the generator is not a pseudorandom number generator \n
464 * - CURAND_STATUS_SUCCESS if generator seed was set successfully \n
466 curandStatus_t CURANDAPI
467 curandSetPseudoRandomGeneratorSeed(curandGenerator_t generator, unsigned long long seed);
470 * \brief Set the absolute offset of the pseudo or quasirandom number generator.
472 * Set the absolute offset of the pseudo or quasirandom number generator.
474 * All values of offset are valid. The offset position is absolute, not
475 * relative to the current position in the sequence.
477 * \param generator - Generator to modify
478 * \param offset - Absolute offset position
481 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
482 * - CURAND_STATUS_SUCCESS if generator offset was set successfully \n
484 curandStatus_t CURANDAPI
485 curandSetGeneratorOffset(curandGenerator_t generator, unsigned long long offset);
488 * \brief Set the ordering of results of the pseudo or quasirandom number generator.
490 * Set the ordering of results of the pseudo or quasirandom number generator.
492 * Legal values of \p order for pseudorandom generators are:
493 * - CURAND_ORDERING_PSEUDO_DEFAULT
494 * - CURAND_ORDERING_PSEUDO_BEST
495 * - CURAND_ORDERING_PSEUDO_SEEDED
497 * Legal values of \p order for quasirandom generators are:
498 * - CURAND_ORDERING_QUASI_DEFAULT
500 * \param generator - Generator to modify
501 * \param order - Ordering of results
504 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
505 * - CURAND_STATUS_OUT_OF_RANGE if the ordering is not valid \n
506 * - CURAND_STATUS_SUCCESS if generator ordering was set successfully \n
508 curandStatus_t CURANDAPI
509 curandSetGeneratorOrdering(curandGenerator_t generator, curandOrdering_t order);
512 * \brief Set the number of dimensions.
514 * Set the number of dimensions to be generated by the quasirandom number
517 * Legal values for \p num_dimensions are 1 to 20000.
519 * \param generator - Generator to modify
520 * \param num_dimensions - Number of dimensions
523 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
524 * - CURAND_STATUS_OUT_OF_RANGE if num_dimensions is not valid \n
525 * - CURAND_STATUS_TYPE_ERROR if the generator is not a quasirandom number generator \n
526 * - CURAND_STATUS_SUCCESS if generator ordering was set successfully \n
528 curandStatus_t CURANDAPI
529 curandSetQuasiRandomGeneratorDimensions(curandGenerator_t generator, unsigned int num_dimensions);
532 * \brief Generate 32-bit pseudo or quasirandom numbers.
534 * Use \p generator to generate \p num 32-bit results into the device memory at
535 * \p outputPtr. The device memory must have been previously allocated and be
536 * large enough to hold all the results. Launches are done with the stream
537 * set using ::curandSetStream(), or the null stream if no stream has been set.
539 * Results are 32-bit values with every bit random.
541 * \param generator - Generator to use
542 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
543 * Pointer to host memory to store CPU-generated results
544 * \param num - Number of random 32-bit values to generate
547 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
548 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
549 * a previous kernel launch \n
550 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
551 * not a multiple of the quasirandom dimension \n
552 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
553 * - CURAND_STATUS_TYPE_ERROR if the generator is a 64 bit quasirandom generator.
554 * (use ::curandGenerateLongLong() with 64 bit quasirandom generators)
555 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
557 curandStatus_t CURANDAPI
558 curandGenerate(curandGenerator_t generator, unsigned int *outputPtr, size_t num);
561 * \brief Generate 64-bit quasirandom numbers.
563 * Use \p generator to generate \p num 64-bit results into the device memory at
564 * \p outputPtr. The device memory must have been previously allocated and be
565 * large enough to hold all the results. Launches are done with the stream
566 * set using ::curandSetStream(), or the null stream if no stream has been set.
568 * Results are 64-bit values with every bit random.
570 * \param generator - Generator to use
571 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
572 * Pointer to host memory to store CPU-generated results
573 * \param num - Number of random 64-bit values to generate
576 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
577 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
578 * a previous kernel launch \n
579 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
580 * not a multiple of the quasirandom dimension \n
581 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
582 * - CURAND_STATUS_TYPE_ERROR if the generator is not a 64 bit quasirandom generator\n
583 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
585 curandStatus_t CURANDAPI
586 curandGenerateLongLong(curandGenerator_t generator, unsigned long long *outputPtr, size_t num);
589 * \brief Generate uniformly distributed floats.
591 * Use \p generator to generate \p num float results into the device memory at
592 * \p outputPtr. The device memory must have been previously allocated and be
593 * large enough to hold all the results. Launches are done with the stream
594 * set using ::curandSetStream(), or the null stream if no stream has been set.
596 * Results are 32-bit floating point values between \p 0.0f and \p 1.0f,
597 * excluding \p 0.0f and including \p 1.0f.
599 * \param generator - Generator to use
600 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
601 * Pointer to host memory to store CPU-generated results
602 * \param num - Number of floats to generate
605 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
606 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
607 * a previous kernel launch \n
608 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
609 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
610 * not a multiple of the quasirandom dimension \n
611 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
613 curandStatus_t CURANDAPI
614 curandGenerateUniform(curandGenerator_t generator, float *outputPtr, size_t num);
617 * \brief Generate uniformly distributed doubles.
619 * Use \p generator to generate \p num double results into the device memory at
620 * \p outputPtr. The device memory must have been previously allocated and be
621 * large enough to hold all the results. Launches are done with the stream
622 * set using ::curandSetStream(), or the null stream if no stream has been set.
624 * Results are 64-bit double precision floating point values between
625 * \p 0.0 and \p 1.0, excluding \p 0.0 and including \p 1.0.
627 * \param generator - Generator to use
628 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
629 * Pointer to host memory to store CPU-generated results
630 * \param num - Number of doubles to generate
633 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
634 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
635 * a previous kernel launch \n
636 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
637 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
638 * not a multiple of the quasirandom dimension \n
639 * - CURAND_STATUS_DOUBLE_PRECISION_REQUIRED if the GPU does not support double precision \n
640 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
642 curandStatus_t CURANDAPI
643 curandGenerateUniformDouble(curandGenerator_t generator, double *outputPtr, size_t num);
646 * \brief Generate normally distributed doubles.
648 * Use \p generator to generate \p n float results into the device memory at
649 * \p outputPtr. The device memory must have been previously allocated and be
650 * large enough to hold all the results. Launches are done with the stream
651 * set using ::curandSetStream(), or the null stream if no stream has been set.
653 * Results are 32-bit floating point values with mean \p mean and standard
654 * deviation \p stddev.
656 * Normally distributed results are generated from pseudorandom generators
657 * with a Box-Muller transform, and so require \p n to be even.
658 * Quasirandom generators use an inverse cumulative distribution
659 * function to preserve dimensionality.
661 * There may be slight numerical differences between results generated
662 * on the GPU with generators created with ::curandCreateGenerator()
663 * and results calculated on the CPU with generators created with
664 * ::curandCreateGeneratorHost(). These differences arise because of
665 * differences in results for transcendental functions. In addition,
666 * future versions of CURAND may use newer versions of the CUDA math
667 * library, so different versions of CURAND may give slightly different
670 * \param generator - Generator to use
671 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
672 * Pointer to host memory to store CPU-generated results
673 * \param n - Number of floats to generate
674 * \param mean - Mean of normal distribution
675 * \param stddev - Standard deviation of normal distribution
678 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
679 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
680 * a previous kernel launch \n
681 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
682 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
683 * not a multiple of the quasirandom dimension, or is not a multiple
684 * of two for pseudorandom generators \n
685 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
687 curandStatus_t CURANDAPI
688 curandGenerateNormal(curandGenerator_t generator, float *outputPtr,
689 size_t n, float mean, float stddev);
692 * \brief Generate normally distributed doubles.
694 * Use \p generator to generate \p n double results into the device memory at
695 * \p outputPtr. The device memory must have been previously allocated and be
696 * large enough to hold all the results. Launches are done with the stream
697 * set using ::curandSetStream(), or the null stream if no stream has been set.
699 * Results are 64-bit floating point values with mean \p mean and standard
700 * deviation \p stddev.
702 * Normally distributed results are generated from pseudorandom generators
703 * with a Box-Muller transform, and so require \p n to be even.
704 * Quasirandom generators use an inverse cumulative distribution
705 * function to preserve dimensionality.
707 * There may be slight numerical differences between results generated
708 * on the GPU with generators created with ::curandCreateGenerator()
709 * and results calculated on the CPU with generators created with
710 * ::curandCreateGeneratorHost(). These differences arise because of
711 * differences in results for transcendental functions. In addition,
712 * future versions of CURAND may use newer versions of the CUDA math
713 * library, so different versions of CURAND may give slightly different
716 * \param generator - Generator to use
717 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
718 * Pointer to host memory to store CPU-generated results
719 * \param n - Number of doubles to generate
720 * \param mean - Mean of normal distribution
721 * \param stddev - Standard deviation of normal distribution
724 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
725 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
726 * a previous kernel launch \n
727 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
728 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
729 * not a multiple of the quasirandom dimension, or is not a multiple
730 * of two for pseudorandom generators \n
731 * - CURAND_STATUS_DOUBLE_PRECISION_REQUIRED if the GPU does not support double precision \n
732 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
734 curandStatus_t CURANDAPI
735 curandGenerateNormalDouble(curandGenerator_t generator, double *outputPtr,
736 size_t n, double mean, double stddev);
739 * \brief Generate log-normally distributed floats.
741 * Use \p generator to generate \p n float results into the device memory at
742 * \p outputPtr. The device memory must have been previously allocated and be
743 * large enough to hold all the results. Launches are done with the stream
744 * set using ::curandSetStream(), or the null stream if no stream has been set.
746 * Results are 32-bit floating point values with log-normal distribution based on
747 * an associated normal distribution with mean \p mean and standard deviation \p stddev.
749 * Normally distributed results are generated from pseudorandom generators
750 * with a Box-Muller transform, and so require \p n to be even.
751 * Quasirandom generators use an inverse cumulative distribution
752 * function to preserve dimensionality.
753 * The normally distributed results are transformed into log-normal distribution.
755 * There may be slight numerical differences between results generated
756 * on the GPU with generators created with ::curandCreateGenerator()
757 * and results calculated on the CPU with generators created with
758 * ::curandCreateGeneratorHost(). These differences arise because of
759 * differences in results for transcendental functions. In addition,
760 * future versions of CURAND may use newer versions of the CUDA math
761 * library, so different versions of CURAND may give slightly different
764 * \param generator - Generator to use
765 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
766 * Pointer to host memory to store CPU-generated results
767 * \param n - Number of floats to generate
768 * \param mean - Mean of associated normal distribution
769 * \param stddev - Standard deviation of associated normal distribution
772 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
773 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
774 * a previous kernel launch \n
775 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
776 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
777 * not a multiple of the quasirandom dimension, or is not a multiple
778 * of two for pseudorandom generators \n
779 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
781 curandStatus_t CURANDAPI
782 curandGenerateLogNormal(curandGenerator_t generator, float *outputPtr,
783 size_t n, float mean, float stddev);
786 * \brief Generate log-normally distributed doubles.
788 * Use \p generator to generate \p n double results into the device memory at
789 * \p outputPtr. The device memory must have been previously allocated and be
790 * large enough to hold all the results. Launches are done with the stream
791 * set using ::curandSetStream(), or the null stream if no stream has been set.
793 * Results are 64-bit floating point values with log-normal distribution based on
794 * an associated normal distribution with mean \p mean and standard deviation \p stddev.
796 * Normally distributed results are generated from pseudorandom generators
797 * with a Box-Muller transform, and so require \p n to be even.
798 * Quasirandom generators use an inverse cumulative distribution
799 * function to preserve dimensionality.
800 * The normally distributed results are transformed into log-normal distribution.
802 * There may be slight numerical differences between results generated
803 * on the GPU with generators created with ::curandCreateGenerator()
804 * and results calculated on the CPU with generators created with
805 * ::curandCreateGeneratorHost(). These differences arise because of
806 * differences in results for transcendental functions. In addition,
807 * future versions of CURAND may use newer versions of the CUDA math
808 * library, so different versions of CURAND may give slightly different
811 * \param generator - Generator to use
812 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
813 * Pointer to host memory to store CPU-generated results
814 * \param n - Number of doubles to generate
815 * \param mean - Mean of normal distribution
816 * \param stddev - Standard deviation of normal distribution
819 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
820 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
821 * a previous kernel launch \n
822 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
823 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
824 * not a multiple of the quasirandom dimension, or is not a multiple
825 * of two for pseudorandom generators \n
826 * - CURAND_STATUS_DOUBLE_PRECISION_REQUIRED if the GPU does not support double precision \n
827 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
829 curandStatus_t CURANDAPI
830 curandGenerateLogNormalDouble(curandGenerator_t generator, double *outputPtr,
831 size_t n, double mean, double stddev);
834 * \brief Construct the histogram array for a Poisson distribution.
836 * Construct the histogram array for the Poisson distribution with lambda \p lambda.
837 * For lambda greater than 2000, an approximation with a normal distribution is used.
839 * \param lambda - lambda for the Poisson distribution
842 * \param discrete_distribution - pointer to the histogram in device memory
845 * - CURAND_STATUS_ALLOCATION_FAILED if memory could not be allocated \n
846 * - CURAND_STATUS_DOUBLE_PRECISION_REQUIRED if the GPU does not support double precision \n
847 * - CURAND_STATUS_INITIALIZATION_FAILED if there was a problem setting up the GPU \n
848 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
849 * a previous kernel launch \n
850 * - CURAND_STATUS_OUT_OF_RANGE if lambda is non-positive or greater than 400,000 \n
851 * - CURAND_STATUS_SUCCESS if the histogram were generated successfully \n
854 curandStatus_t CURANDAPI
855 curandCreatePoissonDistribution(double lambda, curandDiscreteDistribution_t *discrete_distribution);
860 * \brief Destroy the histogram array for a discrete distribution (e.g. Poisson).
862 * Destroy the histogram array for a discrete distribution created by curandCreatePoissonDistribution.
864 * \param discrete_distribution - pointer to device memory where the histogram is stored
867 * - CURAND_STATUS_NOT_INITIALIZED if the histogram was never created \n
868 * - CURAND_STATUS_SUCCESS if the histogram was destroyed successfully \n
870 curandStatus_t CURANDAPI
871 curandDestroyDistribution(curandDiscreteDistribution_t discrete_distribution);
875 * \brief Generate Poisson-distributed unsigned ints.
877 * Use \p generator to generate \p n unsigned int results into device memory at
878 * \p outputPtr. The device memory must have been previously allocated and must be
879 * large enough to hold all the results. Launches are done with the stream
880 * set using ::curandSetStream(), or the null stream if no stream has been set.
882 * Results are 32-bit unsigned int point values with Poisson distribution, with lambda \p lambda.
884 * \param generator - Generator to use
885 * \param outputPtr - Pointer to device memory to store CUDA-generated results, or
886 * Pointer to host memory to store CPU-generated results
887 * \param n - Number of unsigned ints to generate
888 * \param lambda - lambda for the Poisson distribution
891 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
892 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
893 * a previous kernel launch \n
894 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
895 * - CURAND_STATUS_LENGTH_NOT_MULTIPLE if the number of output samples is
896 * not a multiple of the quasirandom dimension\n
897 * - CURAND_STATUS_DOUBLE_PRECISION_REQUIRED if the GPU or sm does not support double precision \n
898 * - CURAND_STATUS_OUT_OF_RANGE if lambda is non-positive or greater than 400,000 \n
899 * - CURAND_STATUS_SUCCESS if the results were generated successfully \n
902 curandStatus_t CURANDAPI
903 curandGeneratePoisson(curandGenerator_t generator, unsigned int *outputPtr,
904 size_t n, double lambda);
905 // just for internal usage
906 curandStatus_t CURANDAPI
907 curandGeneratePoissonMethod(curandGenerator_t generator, unsigned int *outputPtr,
908 size_t n, double lambda, curandMethod_t method);
912 * \brief Setup starting states.
914 * Generate the starting state of the generator. This function is
915 * automatically called by generation functions such as
916 * ::curandGenerate() and ::curandGenerateUniform().
917 * It can be called manually for performance testing reasons to separate
918 * timings for starting state generation and random number generation.
920 * \param generator - Generator to update
923 * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
924 * - CURAND_STATUS_PREEXISTING_FAILURE if there was an existing error from
925 * a previous kernel launch \n
926 * - CURAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason \n
927 * - CURAND_STATUS_SUCCESS if the seeds were generated successfully \n
929 curandStatus_t CURANDAPI
930 curandGenerateSeeds(curandGenerator_t generator);
933 * \brief Get direction vectors for 32-bit quasirandom number generation.
935 * Get a pointer to an array of direction vectors that can be used
936 * for quasirandom number generation. The resulting pointer will
937 * reference an array of direction vectors in host memory.
939 * The array contains vectors for many dimensions. Each dimension
940 * has 32 vectors. Each individual vector is an unsigned int.
942 * Legal values for \p set are:
943 * - CURAND_DIRECTION_VECTORS_32_JOEKUO6 (20,000 dimensions)
944 * - CURAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 (20,000 dimensions)
946 * \param vectors - Address of pointer in which to return direction vectors
947 * \param set - Which set of direction vectors to use
950 * - CURAND_STATUS_OUT_OF_RANGE if the choice of set is invalid \n
951 * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
953 curandStatus_t CURANDAPI
954 curandGetDirectionVectors32(curandDirectionVectors32_t *vectors[], curandDirectionVectorSet_t set);
957 * \brief Get scramble constants for 32-bit scrambled Sobol' .
959 * Get a pointer to an array of scramble constants that can be used
960 * for quasirandom number generation. The resulting pointer will
961 * reference an array of unsinged ints in host memory.
963 * The array contains constants for many dimensions. Each dimension
964 * has a single unsigned int constant.
966 * \param constants - Address of pointer in which to return scramble constants
969 * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
971 curandStatus_t CURANDAPI
972 curandGetScrambleConstants32(unsigned int * * constants);
975 * \brief Get direction vectors for 64-bit quasirandom number generation.
977 * Get a pointer to an array of direction vectors that can be used
978 * for quasirandom number generation. The resulting pointer will
979 * reference an array of direction vectors in host memory.
981 * The array contains vectors for many dimensions. Each dimension
982 * has 64 vectors. Each individual vector is an unsigned long long.
984 * Legal values for \p set are:
985 * - CURAND_DIRECTION_VECTORS_64_JOEKUO6 (20,000 dimensions)
986 * - CURAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 (20,000 dimensions)
988 * \param vectors - Address of pointer in which to return direction vectors
989 * \param set - Which set of direction vectors to use
992 * - CURAND_STATUS_OUT_OF_RANGE if the choice of set is invalid \n
993 * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
995 curandStatus_t CURANDAPI
996 curandGetDirectionVectors64(curandDirectionVectors64_t *vectors[], curandDirectionVectorSet_t set);
999 * \brief Get scramble constants for 64-bit scrambled Sobol' .
1001 * Get a pointer to an array of scramble constants that can be used
1002 * for quasirandom number generation. The resulting pointer will
1003 * reference an array of unsinged long longs in host memory.
1005 * The array contains constants for many dimensions. Each dimension
1006 * has a single unsigned long long constant.
1008 * \param constants - Address of pointer in which to return scramble constants
1011 * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
1013 curandStatus_t CURANDAPI
1014 curandGetScrambleConstants64(unsigned long long * * constants);
1018 #if defined(__cplusplus)
1020 #endif /* __cplusplus */
1023 #endif /* !defined(CURAND_H_) */