Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing function rng::device::generate_single #476

Open
npolina4 opened this issue Apr 23, 2024 · 1 comment
Open

Missing function rng::device::generate_single #476

npolina4 opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
API A request to add/change/fix/improve the API feature A request to add a new feature

Comments

@npolina4
Copy link

Summary

Missing functions rng::device::generate_single and rng::host::generate_single.
I can see this functions in code, but I cannot see them in library after build.

Reproducer

#include <sycl/sycl.hpp>
#include <oneapi/mkl/rng/device.hpp>

namespace mkl_dev_rng = oneapi::mkl::rng::device;

int main(void)
{
    sycl::queue q{sycl::default_selector_v};

    const auto &dev = q.get_device();
    std::cout << "Device: " << dev.get_info<sycl::info::device::name>() << std::endl;
    std::cout << "Driver_version: " << dev.get_info<sycl::info::device::driver_version>() << std::endl;

    using T = float;
    constexpr std::size_t size = 10;
    T *data = sycl::malloc_device<T>(size, q);

    using EngineT = mkl_dev_rng::mcg59<2>;

    q.submit([&](sycl::handler &cgh) {
        cgh.parallel_for<>(sycl::range<1>(size/2), [=](sycl::id<1> id) {
            size_t i = id[0];

            constexpr std::uint32_t seed = 12345u;
            EngineT engine(seed, 2*i);
            mkl_dev_rng::gaussian<T> distr(0, 1);

            data[2*i] = mkl_dev_rng::generate_single(distr, engine);
            data[2*i + 1] = mkl_dev_rng::generate_single(distr, engine);
        });
    }).wait_and_throw();

    T *host_data = new T[size];
    q.memcpy(host_data, data, size * sizeof(T)).wait();

    std::cout << "Data:\n";
    for (std::uint16_t i = 0; i < size; i++) {
        std::cout << std::to_string(host_data[i]) << ", ";
    }
    std::cout << std::endl;

    sycl::free(data, q);
    delete[] host_data;
    return 0;
} 

build out: error: no member named 'generate_single' in namespace 'oneapi::mkl::rng::device’

@aelizaro
Copy link
Contributor

Hi @npolina4,

For device API the situation is the following:
Intel oneMKL product supports this function and it is available in #include <oneapi/mkl/rng/device.hpp> from the binary distribution

However, we deliberately didn't include this function into oneMKL specification and oneMKL interfaces as it seems a bit redundant (if vec_size = 1 for engine it acts the same as just generate).

Do you have a wide usage of this function or is it enough to use regular generate for your use cases?

@aelizaro aelizaro added feature A request to add a new feature API A request to add/change/fix/improve the API labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API A request to add/change/fix/improve the API feature A request to add a new feature
Projects
None yet
Development

No branches or pull requests

2 participants