JuliaGPU / JuliaGPU/CUDA.jl

Type unstable code can lead to loading from CPU boxes

Open
#541 1 comment 0 reactions 0 assignees View on GitHub
bug cuda kernels
Dominant language
Julia
Stars
1.4k
Forks
281
Avg merge
1d 7h
Merged PRs (30d)
30

Description

**Describe the bug**

In some cases assigning NaN to a cuda array of Float32 results in:

CUDA error: an illegal memory access was encountered (code 700, ERROR_ILLEGAL_ADDRESS)

assigning a NaN32 does not.

**To reproduce**

The Minimal Working Example (MWE) for this bug:

```julia
using CUDA
CUDA.allowscalar(false)

#return NaN if sum of colum c of A is 0, 0 otherwise
function core_test(A,c)
n = Int32(0)
for i in 1:size(A,1)
n += A[i,c]
end
if n == 0
return NaN # <===== NaN32 doesnt crash
else
return 0.0f0
end
end

#run core_test on each colum of A
function test_func!(out,A)
index = (blockIdx().x -1) * blockDim().x + threadIdx().x
stride = blockDim().x * gridDim().x
for c = index:stride:size(out,1)
@inbounds out[c] = core_test(A,c)
end
return nothing
end

A = cu([ 1 0 ])
out = CUDA.fill(NaN32, 2)

CUDA.@sync begin
@cuda test_func!(out,A)
end
@show out

```

Manifest.toml

```
CUDA: v2.1.0
GPUArrays: V6.1.1

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"
RollingFunctions = "b0e4dd01-7b14-53d8-9b45-175a3e362653"
ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
ThreadTools = "dbf13d8f-d36e-4350-8970-f3a99faba1a8"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
```

**Expected behavior**

I'd expect the same behavior as assign NaN32 or a compile-time error.

**Version info**

Details on Julia:

```
# please post the output of:
versioninfo()

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 7 1700 Eight-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 15
JULIA_EDITOR = "/usr/share/code/code"
```

Details on CUDA:

```
# please post the output of:
CUDA.versioninfo()

UDA toolkit 11.0.3, artifact installation
CUDA driver 11.0.0
NVIDIA driver 450.80.2

Libraries:
- CUBLAS: 11.2.0
- CURAND: 10.2.1
- CUFFT: 10.2.1
- CUSOLVER: 10.6.0
- CUSPARSE: 11.1.1
- CUPTI: 13.0.0
- NVML: 11.0.0+450.80.2
- CUDNN: 8.0.4 (for CUDA 11.0.0)
- CUTENSOR: 1.2.1 (for CUDA 11.0.0)

Toolchain:
- Julia: 1.5.2
- LLVM: 9.0.1
- PTX ISA support: 3.2, 4.0, 4.1, 4.2, 4.3, 5.0, 6.0, 6.1, 6.3, 6.4
- Device support: sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75

2 devices:
0: GeForce GTX 1060 6GB (sm_61, 5.784 GiB / 5.934 GiB available)
1: GeForce GTX 1060 3GB (sm_61, 93.438 MiB / 2.949 GiB available)

```

**Additional context**

Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.