Fill the n entries of x with normal numbers of the given mean and standard deviation.
Normal numbers are generated in pairs, as the cuRAND backend of oneMath requires, so the last entry of an odd n is taken from a pair generated into scratch.
340{
341 if (n == 0)
342 {
343 return;
344 }
345
347#if defined(SYCL_ENABLE_HIP)
348 auto scratch = reinterpret_cast<TData *>(engine.scratch);
349
350 if (n % 2 == 0)
351 {
352 GenerateNormal(engine.generator, mean, sigma, n, x, streamID);
353 }
354 else
355 {
356 GenerateNormal(engine.generator, mean, sigma, n - 1, x, streamID);
357 GenerateNormal(engine.generator, mean, sigma, size_t(2), scratch,
358 streamID);
359 deviceMemcpy<eDeviceToDevice>(x + n - 1, scratch, sizeof(TData),
360 streamID);
361 }
362#elif defined(NEKTAR_SYCL_HAVE_RNG_LIBRARY)
363 auto scratch = reinterpret_cast<TData *>(engine.scratch);
364
365 if (n % 2 == 0)
366 {
367 Generate(rng::gaussian<TData>(mean, sigma), *engine.generator, n, x,
368 streamID);
369 }
370 else
371 {
372 Generate(rng::gaussian<TData>(mean, sigma), *engine.generator, n - 1, x,
373 streamID);
374 Generate(rng::gaussian<TData>(mean, sigma), *engine.generator, 2,
375 scratch, streamID);
376 deviceMemcpy<eDeviceToDevice>(x + n - 1, scratch, sizeof(TData),
377 streamID);
378 }
379#else
380 std::normal_distribution<TData> distribution(mean, sigma);
381 std::vector<TData> host(n);
382 for (auto &value : host)
383 {
384 value = distribution(engine.generator);
385 }
387#endif
388}
static void CopyToDevice(const std::vector< TData > &host, TData *x, const unsigned int streamID)