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

rand and friends default to Float64 #108

Closed
Sleort opened this issue Nov 20, 2019 · 1 comment
Closed

rand and friends default to Float64 #108

Sleort opened this issue Nov 20, 2019 · 1 comment
Labels
cuda array Stuff about CuArray. performance How fast can we go?

Comments

@Sleort
Copy link
Contributor

Sleort commented Nov 20, 2019

Describe the bug
The random number generator in CuArrays seems to default to Float64, although
https://github.com/JuliaGPU/CuArrays.jl/blob/7f7e72c1152c25855bbaea0cabdc6d5857c50c21/src/rand/random.jl#L134-L138
specifies that it should be Float32. I'm not sure why, though...

To Reproduce

julia> using CuArrays

julia> rng = CURAND.RNG()
CuArrays.CURAND.RNG(Ptr{Nothing} @0x00000000025b6be0, 100)

julia> rand(rng, 1)
1-element CuArray{Float64,1,Nothing}:
 0.4384508447184235

julia> randn(rng, 1)
1-element CuArray{Float64,1,Nothing}:
 0.8943739751223734

Expected behavior
The default element type should be Float32 for CuArrays

Environment details (please complete this section)
Details on Julia:

Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

Julia packages:

  • CuArrays.jl: v1.4.7
  • CUDAnative.jl: v2.5.5
  • CUDAdrv: v4.0.4
  • CUDAapi: v2.0.0

CUDA: toolkit and driver version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
@maleadt maleadt transferred this issue from JuliaGPU/CuArrays.jl May 27, 2020
@maleadt maleadt added cuda array Stuff about CuArray. performance How fast can we go? labels May 27, 2020
@maleadt
Copy link
Member

maleadt commented Apr 27, 2024

julia> rng = CUDA.RNG()
CUDA.RNG(0xd4039d1b, 0x00000000)

julia> rand(rng, 1)
1-element CuArray{Float32, 1, CUDA.DeviceMemory}:
 0.9444126

Defaults to Float32 now.

@maleadt maleadt closed this as completed Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda array Stuff about CuArray. performance How fast can we go?
Projects
None yet
Development

No branches or pull requests

2 participants