Lines Matching +full:- +full:r
9 static PetscErrorCode PetscRandomSeed_CURAND(PetscRandom r) in PetscRandomSeed_CURAND() argument
11 PetscRandom_CURAND *curand = (PetscRandom_CURAND *)r->data; in PetscRandomSeed_CURAND()
14 PetscCallCURAND(curandSetPseudoRandomGeneratorSeed(curand->gen, r->seed)); in PetscRandomSeed_CURAND()
20 static PetscErrorCode PetscRandomGetValuesReal_CURAND(PetscRandom r, PetscInt n, PetscReal *val) in PetscRandomGetValuesReal_CURAND() argument
22 PetscRandom_CURAND *curand = (PetscRandom_CURAND *)r->data; in PetscRandomGetValuesReal_CURAND()
23 size_t nn = n < 0 ? (size_t)(-2 * n) : (size_t)n; /* handle complex case */ in PetscRandomGetValuesReal_CURAND()
27 PetscCallCURAND(curandGenerateUniform(curand->gen, val, nn)); in PetscRandomGetValuesReal_CURAND()
29 PetscCallCURAND(curandGenerateUniformDouble(curand->gen, val, nn)); in PetscRandomGetValuesReal_CURAND()
31 if (r->iset) PetscCall(PetscRandomCurandScale_Private(r, nn, val, (PetscBool)(n < 0))); in PetscRandomGetValuesReal_CURAND()
35 static PetscErrorCode PetscRandomGetValues_CURAND(PetscRandom r, PetscInt n, PetscScalar *val) in PetscRandomGetValues_CURAND() argument
40 PetscCall(PetscRandomGetValuesReal_CURAND(r, -n, (PetscReal *)val)); in PetscRandomGetValues_CURAND()
42 PetscCall(PetscRandomGetValuesReal_CURAND(r, n, val)); in PetscRandomGetValues_CURAND()
47 static PetscErrorCode PetscRandomDestroy_CURAND(PetscRandom r) in PetscRandomDestroy_CURAND() argument
49 PetscRandom_CURAND *curand = (PetscRandom_CURAND *)r->data; in PetscRandomDestroy_CURAND()
52 PetscCallCURAND(curandDestroyGenerator(curand->gen)); in PetscRandomDestroy_CURAND()
53 PetscCall(PetscFree(r->data)); in PetscRandomDestroy_CURAND()
67 PETSCCURAND - access to the CUDA random number generator from a `PetscRandom` object
72 …This random number generator is available when PETSc is configured with ``./configure --with-cuda=…
77 PETSC_EXTERN PetscErrorCode PetscRandomCreate_CURAND(PetscRandom r) in PetscRandomCreate_CURAND() argument
88 PetscCallCURAND(curandCreateGenerator(&curand->gen, CURAND_RNG_PSEUDO_DEFAULT)); in PetscRandomCreate_CURAND()
89 PetscCallCURAND(curandSetStream(curand->gen, *stream)); in PetscRandomCreate_CURAND()
90 /* https://docs.nvidia.com/cuda/curand/host-api-overview.html#performance-notes2 */ in PetscRandomCreate_CURAND()
91 PetscCallCURAND(curandSetGeneratorOrdering(curand->gen, CURAND_ORDERING_PSEUDO_SEEDED)); in PetscRandomCreate_CURAND()
92 r->ops[0] = PetscRandomOps_Values; in PetscRandomCreate_CURAND()
93 PetscCall(PetscObjectChangeTypeName((PetscObject)r, PETSCCURAND)); in PetscRandomCreate_CURAND()
94 r->data = curand; in PetscRandomCreate_CURAND()
95 PetscCall(PetscRandomSeed_CURAND(r)); in PetscRandomCreate_CURAND()