Skip to content

rand_xoshiro crate = runtime error #203

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

Open
brandonros opened this issue Apr 20, 2025 · 4 comments
Open

rand_xoshiro crate = runtime error #203

brandonros opened this issue Apr 20, 2025 · 4 comments

Comments

@brandonros
Copy link

Reproduction:

#[kernel]
#[allow(improper_ctypes_definitions, clippy::missing_safety_doc)]
pub unsafe fn find_vanity_private_key(a: &[u8]) {
    let idx = thread::index_1d() as usize;

    let mut rng_seed: u64 = 42; // TODO: make this unique for each thread?
    let mut num_iterations: u64 = 0;

    for _ in 0..10000 {
        // generate random input for seed
        let mut rng = Xoroshiro128StarStar::seed_from_u64(rng_seed); // if i change this to MockXoroshiro128StarStar it works fine
        let mut input = [0u8; 32];
        rng.fill_bytes(&mut input);
         ...
@jorge-ortega
Copy link
Collaborator

Hi @brandonros,

Thanks for the report. I'm not able to reproduce this atm. Can you also share how you launch from the host side?

My kernel currently looks like this:

#[kernel]
#[allow(improper_ctypes_definitions, clippy::missing_safety_doc)]
pub unsafe fn rng_test() {

    let rng_seed: u64 = 42;

    for _ in 0..10000 {
        let mut rng = Xoroshiro128StarStar::seed_from_u64(rng_seed);
        let mut input = [0u8; 32];
        rng.fill_bytes(&mut input);
    }
}

And I launch like this:

unsafe {
    launch!(
        module.rng_test<<<32, 32, 0, stream>>>()
    )?;
}

The path-tracer example uses DefaultRand, which uses Xorohiro128StarStar. The render kernel receives it as a parameter, which the host side provides when launching. Hope that helps.

@brandonros
Copy link
Author

I'll report back if I'm able to reproduce. I moved to XorShiftRng for now which doesn't seem to have this issue. Not sure if it is related to resources (too many threads/blocks).

I had the problem trying to launch it with cust and https://github.com/coreylowman/cudarc but I do not want to waste your time tracking it down.

Would a compiled output like .ll help at all?

@brandonros
Copy link
Author

brandonros/ed25519-vanity-rs@424ee9d

if you switch Xoroshiro128StarStar and XorShiftRng on this branch it should reproduce

@brandonros brandonros reopened this Apr 29, 2025
@brandonros
Copy link
Author

@brandonros brandonros changed the title Xoroshiro128StarStar::seed_from_u64 causes Error: IllegalAddress failure rand_xoshiro crate = runtime error Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants