OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / curand.h
1
2  /* Copyright 2010-2014 NVIDIA Corporation.  All rights reserved.
3   *
4   * NOTICE TO LICENSEE:
5   *
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.
9   *
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.
18   *
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.
33   *
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.
43   *
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
47   * Users Notice.
48   */
49
50 #if !defined(CURAND_H_)
51 #define CURAND_H_
52
53 /**
54  * \defgroup HOST Host API
55  *
56  * @{
57  */
58
59 #include <cuda_runtime.h>
60
61 #ifndef CURANDAPI
62 #ifdef _WIN32
63 #define CURANDAPI __stdcall
64 #else
65 #define CURANDAPI 
66 #endif
67 #endif
68
69 #if defined(__cplusplus)
70 extern "C" {
71 #endif /* __cplusplus */
72
73 /* CURAND Host API datatypes */
74
75 /**  
76  * @{
77  */
78
79 /**
80  * CURAND function call status types 
81  */
82 enum curandStatus {
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
96 };
97
98 /*
99  * CURAND function call status types
100 */
101 /** \cond UNHIDE_TYPEDEFS */
102 typedef enum curandStatus curandStatus_t;
103 /** \endcond */
104
105 /**
106  * CURAND generator types
107  */
108 enum curandRngType {
109     CURAND_RNG_TEST = 0,
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
121 };
122
123 /*
124  * CURAND generator types
125  */
126 /** \cond UNHIDE_TYPEDEFS */
127 typedef enum curandRngType curandRngType_t;
128 /** \endcond */
129
130 /**
131  * CURAND ordering of results in memory
132  */
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
138 };
139
140 /*
141  * CURAND ordering of results in memory
142  */
143 /** \cond UNHIDE_TYPEDEFS */
144 typedef enum curandOrdering curandOrdering_t;
145 /** \endcond */
146
147 /**
148  * CURAND choice of direction vector set
149  */
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
155 };
156
157 /*
158  * CURAND choice of direction vector set
159  */
160 /** \cond UNHIDE_TYPEDEFS */
161 typedef enum curandDirectionVectorSet curandDirectionVectorSet_t;
162 /** \endcond */
163
164 /**
165  * CURAND array of 32-bit direction vectors
166  */
167 /** \cond UNHIDE_TYPEDEFS */
168 typedef unsigned int curandDirectionVectors32_t[32];
169 /** \endcond */
170
171  /**
172  * CURAND array of 64-bit direction vectors
173  */
174 /** \cond UNHIDE_TYPEDEFS */
175 typedef unsigned long long curandDirectionVectors64_t[64];
176 /** \endcond **/
177  
178 /**
179  * CURAND generator (opaque)
180  */
181 struct curandGenerator_st;
182
183 /**
184  * CURAND generator
185  */
186 /** \cond UNHIDE_TYPEDEFS */
187 typedef struct curandGenerator_st *curandGenerator_t;
188 /** \endcond */
189
190 /**
191  * CURAND distribution
192  */
193 /** \cond UNHIDE_TYPEDEFS */
194 typedef double curandDistribution_st;
195 typedef curandDistribution_st *curandDistribution_t;
196 typedef struct curandDistributionShift_st *curandDistributionShift_t;
197 /** \endcond */
198 /**
199  * CURAND distribution M2
200  */
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;
208
209 typedef struct curandDiscreteDistribution_st *curandDiscreteDistribution_t;
210 /** \endcond */
211
212 /*
213  * CURAND METHOD
214  */
215 /** \cond UNHIDE_ENUMS */
216 enum curandMethod {
217     CURAND_CHOOSE_BEST = 0, // choose best depends on args
218     CURAND_ITR = 1,
219     CURAND_KNUTH = 2,
220     CURAND_HITR = 3,
221     CURAND_M1 = 4,
222     CURAND_M2 = 5,
223     CURAND_BINARY_SEARCH = 6,
224     CURAND_DISCRETE_GAUSS = 7,
225     CURAND_REJECTION = 8,
226     CURAND_DEVICE_API = 9,
227     CURAND_FAST_REJECTION = 10,
228     CURAND_3RD = 11,
229     CURAND_DEFINITION = 12,
230     CURAND_POISSON = 13
231 };
232
233 typedef enum curandMethod curandMethod_t;
234 /** \endcond */
235
236 /**
237  * @}
238  */
239
240 /**
241  * \brief Create new random number generator.
242  *
243  * Creates a new random number generator of type \p rng_type
244  * and returns it in \p *generator.
245  *
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
258  * 
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.
263  * 
264  * The default values for \p rng_type = CURAND_RNG_PSEUDO_XORWOW are:
265  * - \p seed = 0
266  * - \p offset = 0
267  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
268  *
269  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MRG32K3A are:
270  * - \p seed = 0
271  * - \p offset = 0
272  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
273  *
274  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MTGP32 are:
275  * - \p seed = 0
276  * - \p offset = 0
277  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
278  *
279  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MT19937 are:
280  * - \p seed = 0
281  * - \p offset = 0
282  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
283  *
284  * * The default values for \p rng_type = CURAND_RNG_PSEUDO_PHILOX4_32_10 are:
285  * - \p seed = 0
286  * - \p offset = 0
287  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
288  *
289  * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL32 are:
290  * - \p dimensions = 1
291  * - \p offset = 0
292  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
293  *
294  * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL64 are:
295  * - \p dimensions = 1
296  * - \p offset = 0
297  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
298  *
299  * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBBLED_SOBOL32 are:
300  * - \p dimensions = 1
301  * - \p offset = 0
302  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
303  *
304  * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 are:
305  * - \p dimensions = 1
306  * - \p offset = 0
307  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
308  *
309  * \param generator - Pointer to generator
310  * \param rng_type - Type of generator to create
311  *
312  * \return 
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
319  * 
320  */
321 curandStatus_t CURANDAPI 
322 curandCreateGenerator(curandGenerator_t *generator, curandRngType_t rng_type);
323
324 /**
325  * \brief Create new host CPU random number generator.
326  *
327  * Creates a new host CPU random number generator of type \p rng_type
328  * and returns it in \p *generator.
329  *
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
339  * 
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.
344  * 
345  * The default values for \p rng_type = CURAND_RNG_PSEUDO_XORWOW are:
346  * - \p seed = 0
347  * - \p offset = 0
348  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
349  *
350  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MRG32K3A are:
351  * - \p seed = 0
352  * - \p offset = 0
353  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
354  *
355  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MTGP32 are:
356  * - \p seed = 0
357  * - \p offset = 0
358  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
359  *
360  * The default values for \p rng_type = CURAND_RNG_PSEUDO_MT19937 are:
361  * - \p seed = 0
362  * - \p offset = 0
363  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
364  *
365  * * The default values for \p rng_type = CURAND_RNG_PSEUDO_PHILOX4_32_10 are:
366  * - \p seed = 0
367  * - \p offset = 0
368  * - \p ordering = CURAND_ORDERING_PSEUDO_DEFAULT
369  *
370  * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL32 are:
371  * - \p dimensions = 1
372  * - \p offset = 0
373  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
374  *
375  * The default values for \p rng_type = CURAND_RNG_QUASI_SOBOL64 are:
376  * - \p dimensions = 1
377  * - \p offset = 0
378  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
379  *
380  * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL32 are:
381  * - \p dimensions = 1
382  * - \p offset = 0
383  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
384  *
385  * The default values for \p rng_type = CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 are:
386  * - \p dimensions = 1
387  * - \p offset = 0
388  * - \p ordering = CURAND_ORDERING_QUASI_DEFAULT
389  *
390  * \param generator - Pointer to generator
391  * \param rng_type - Type of generator to create
392  *
393  * \return
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
400  */
401 curandStatus_t CURANDAPI 
402 curandCreateGeneratorHost(curandGenerator_t *generator, curandRngType_t rng_type);
403
404 /**
405  * \brief Destroy an existing generator.
406  *
407  * Destroy an existing generator and free all memory associated with its state.
408  *
409  * \param generator - Generator to destroy
410  *
411  * \return
412  * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
413  * - CURAND_STATUS_SUCCESS if generator was destroyed successfully \n
414  */
415 curandStatus_t CURANDAPI 
416 curandDestroyGenerator(curandGenerator_t generator);
417
418 /**
419  * \brief Return the version number of the library.
420  *
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
424  * version.
425  *
426  * \param version - CURAND library version
427  *
428  * \return
429  * - CURAND_STATUS_SUCCESS if the version number was successfully returned \n
430  */
431 curandStatus_t CURANDAPI
432 curandGetVersion(int *version);
433
434 /**
435  * \brief Set the current stream for CURAND kernel launches.
436  *
437  * Set the current stream for CURAND kernel launches.  All library functions
438  * will use this stream until set again.
439  *
440  * \param generator - Generator to modify
441  * \param stream - Stream to use or ::NULL for null stream
442  *
443  * \return
444  * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
445  * - CURAND_STATUS_SUCCESS if stream was set successfully \n
446  */
447 curandStatus_t CURANDAPI
448 curandSetStream(curandGenerator_t generator, cudaStream_t stream);
449
450 /**
451  * \brief Set the seed value of the pseudo-random number generator.  
452  * 
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.
457  *
458  * \param generator - Generator to modify
459  * \param seed - Seed value
460  * 
461  * \return
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
465  */
466 curandStatus_t CURANDAPI 
467 curandSetPseudoRandomGeneratorSeed(curandGenerator_t generator, unsigned long long seed);
468
469 /**
470  * \brief Set the absolute offset of the pseudo or quasirandom number generator.
471  *
472  * Set the absolute offset of the pseudo or quasirandom number generator.
473  *
474  * All values of offset are valid.  The offset position is absolute, not 
475  * relative to the current position in the sequence.
476  *
477  * \param generator - Generator to modify
478  * \param offset - Absolute offset position
479  *
480  * \return
481  * - CURAND_STATUS_NOT_INITIALIZED if the generator was never created \n
482  * - CURAND_STATUS_SUCCESS if generator offset was set successfully \n
483  */
484 curandStatus_t CURANDAPI 
485 curandSetGeneratorOffset(curandGenerator_t generator, unsigned long long offset);
486
487 /**
488  * \brief Set the ordering of results of the pseudo or quasirandom number generator.
489  *
490  * Set the ordering of results of the pseudo or quasirandom number generator.
491  *
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
496  *
497  * Legal values of \p order for quasirandom generators are:
498  * - CURAND_ORDERING_QUASI_DEFAULT
499  *
500  * \param generator - Generator to modify
501  * \param order - Ordering of results
502  *
503  * \return
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
507  */
508 curandStatus_t CURANDAPI 
509 curandSetGeneratorOrdering(curandGenerator_t generator, curandOrdering_t order);
510
511 /**
512  * \brief Set the number of dimensions.
513  *
514  * Set the number of dimensions to be generated by the quasirandom number
515  * generator.
516  * 
517  * Legal values for \p num_dimensions are 1 to 20000.
518  * 
519  * \param generator - Generator to modify
520  * \param num_dimensions - Number of dimensions
521  *
522  * \return
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
527  */
528 curandStatus_t CURANDAPI
529 curandSetQuasiRandomGeneratorDimensions(curandGenerator_t generator, unsigned int num_dimensions);
530
531 /**
532  * \brief Generate 32-bit pseudo or quasirandom numbers.
533  *
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.
538  *
539  * Results are 32-bit values with every bit random.
540  *
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
545  *
546  * \return
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
556  */
557 curandStatus_t CURANDAPI 
558 curandGenerate(curandGenerator_t generator, unsigned int *outputPtr, size_t num);
559
560 /**
561  * \brief Generate 64-bit quasirandom numbers.
562  *
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.
567  *
568  * Results are 64-bit values with every bit random.
569  *
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
574  *
575  * \return
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
584  */
585 curandStatus_t CURANDAPI 
586 curandGenerateLongLong(curandGenerator_t generator, unsigned long long *outputPtr, size_t num);
587
588 /**
589  * \brief Generate uniformly distributed floats.
590  *
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.
595  *
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.
598  *
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
603  *
604  * \return
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
612  */
613 curandStatus_t CURANDAPI 
614 curandGenerateUniform(curandGenerator_t generator, float *outputPtr, size_t num);
615
616 /**
617  * \brief Generate uniformly distributed doubles.
618  *
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.
623  *
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.
626  *
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
631  *
632  * \return
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
641  */
642 curandStatus_t CURANDAPI 
643 curandGenerateUniformDouble(curandGenerator_t generator, double *outputPtr, size_t num);
644
645 /**
646  * \brief Generate normally distributed doubles.
647  *
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.
652  *
653  * Results are 32-bit floating point values with mean \p mean and standard
654  * deviation \p stddev.
655  *
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.
660  *
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
668  * numerical values.
669  *
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
676  *
677  * \return
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
686  */
687 curandStatus_t CURANDAPI 
688 curandGenerateNormal(curandGenerator_t generator, float *outputPtr, 
689                      size_t n, float mean, float stddev);
690
691 /**
692  * \brief Generate normally distributed doubles.
693  *
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.
698  *
699  * Results are 64-bit floating point values with mean \p mean and standard
700  * deviation \p stddev.
701  *
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.
706  *
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
714  * numerical values.
715  *
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
722  *
723  * \return
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
733  */
734 curandStatus_t CURANDAPI 
735 curandGenerateNormalDouble(curandGenerator_t generator, double *outputPtr, 
736                      size_t n, double mean, double stddev);
737
738 /**
739  * \brief Generate log-normally distributed floats.
740  *
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.
745  *
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.
748  *
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.
754  *
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
762  * numerical values.
763  *
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
770  *
771  * \return
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
780  */
781 curandStatus_t CURANDAPI 
782 curandGenerateLogNormal(curandGenerator_t generator, float *outputPtr, 
783                      size_t n, float mean, float stddev);
784
785 /**
786  * \brief Generate log-normally distributed doubles.
787  *
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.
792  *
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.
795  *
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.
801  *
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
809  * numerical values.
810  *
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
817  *
818  * \return
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
828  */
829 curandStatus_t CURANDAPI 
830 curandGenerateLogNormalDouble(curandGenerator_t generator, double *outputPtr, 
831                      size_t n, double mean, double stddev);
832
833 /**
834  * \brief Construct the histogram array for a Poisson distribution.
835  *
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.
838  *
839  * \param lambda - lambda for the Poisson distribution
840  *
841  *
842  * \param discrete_distribution - pointer to the histogram in device memory
843  *
844  * \return
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
852  */
853
854 curandStatus_t CURANDAPI
855 curandCreatePoissonDistribution(double lambda, curandDiscreteDistribution_t *discrete_distribution);
856
857
858
859 /**
860  * \brief Destroy the histogram array for a discrete distribution (e.g. Poisson).
861  *
862  * Destroy the histogram array for a discrete distribution created by curandCreatePoissonDistribution.
863  *
864  * \param discrete_distribution - pointer to device memory where the histogram is stored
865  *
866  * \return
867  * - CURAND_STATUS_NOT_INITIALIZED if the histogram was never created \n
868  * - CURAND_STATUS_SUCCESS if the histogram was destroyed successfully \n
869  */
870 curandStatus_t CURANDAPI
871 curandDestroyDistribution(curandDiscreteDistribution_t discrete_distribution);
872
873
874 /**
875  * \brief Generate Poisson-distributed unsigned ints.
876  *
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.
881  *
882  * Results are 32-bit unsigned int point values with Poisson distribution, with lambda \p lambda.
883  *
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
889  *
890  * \return
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
900  */
901
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);
909
910
911 /**
912  * \brief Setup starting states.
913  *
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.
919  *
920  * \param generator - Generator to update
921  *
922  * \return
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
928  */
929 curandStatus_t CURANDAPI 
930 curandGenerateSeeds(curandGenerator_t generator);
931
932 /**
933  * \brief Get direction vectors for 32-bit quasirandom number generation.
934  *
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.
938  *
939  * The array contains vectors for many dimensions.  Each dimension
940  * has 32 vectors.  Each individual vector is an unsigned int.
941  *
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)
945  *
946  * \param vectors - Address of pointer in which to return direction vectors
947  * \param set - Which set of direction vectors to use
948  *
949  * \return
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
952  */
953 curandStatus_t CURANDAPI
954 curandGetDirectionVectors32(curandDirectionVectors32_t *vectors[], curandDirectionVectorSet_t set);
955
956 /**
957  * \brief Get scramble constants for 32-bit scrambled Sobol' .
958  *
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.
962  *
963  * The array contains constants for many dimensions.  Each dimension
964  * has a single unsigned int constant.
965  *
966  * \param constants - Address of pointer in which to return scramble constants
967  *
968  * \return
969  * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
970  */
971 curandStatus_t CURANDAPI
972 curandGetScrambleConstants32(unsigned int * * constants);
973
974 /**
975  * \brief Get direction vectors for 64-bit quasirandom number generation.
976  *
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.
980  *
981  * The array contains vectors for many dimensions.  Each dimension
982  * has 64 vectors.  Each individual vector is an unsigned long long.
983  *
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)
987  *
988  * \param vectors - Address of pointer in which to return direction vectors
989  * \param set - Which set of direction vectors to use
990  *
991  * \return
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
994  */
995 curandStatus_t CURANDAPI
996 curandGetDirectionVectors64(curandDirectionVectors64_t *vectors[], curandDirectionVectorSet_t set);
997
998 /**
999  * \brief Get scramble constants for 64-bit scrambled Sobol' .
1000  *
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.
1004  *
1005  * The array contains constants for many dimensions.  Each dimension
1006  * has a single unsigned long long constant.
1007  *
1008  * \param constants - Address of pointer in which to return scramble constants
1009  *
1010  * \return
1011  * - CURAND_STATUS_SUCCESS if the pointer was set successfully \n
1012  */
1013 curandStatus_t CURANDAPI
1014 curandGetScrambleConstants64(unsigned long long * * constants);
1015
1016 /** @} */
1017
1018 #if defined(__cplusplus)
1019 }
1020 #endif /* __cplusplus */
1021
1022
1023 #endif /* !defined(CURAND_H_) */