Skip to content

Segfault with longer SIMD vectors #20961

@fredrikekre

Description

@fredrikekre

The following:

using SIMD
A = Vec{N, Float64}((rand(N)...))
B = A + A

works for N = (1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 36, 40, 48, 64, 65, 66, 68, 72, 80, 96) (tested up to N = 100) on v0.5. On master the above code segfaults for all N above 32 (e.g. N = 33, 34, 36, 40, 48, 64, 65, 66, 68, 72, 80, 96). The generated code look okay(?). Example with N = 36:

julia> @code_llvm A + A

define void @"julia_+_68162"(%Vec* noalias nocapture sret, %Vec*, %Vec*) #0 !dbg !5 {
top:
  %3 = getelementptr inbounds %Vec, %Vec* %1, i64 0, i32 0
  %4 = load <36 x double>, <36 x double>* %3, align 512
  %5 = getelementptr inbounds %Vec, %Vec* %2, i64 0, i32 0
  %6 = load <36 x double>, <36 x double>* %5, align 512
  %res.i = fadd <36 x double> %4, %6
  %.sroa.0.0..sroa_idx = getelementptr inbounds %Vec, %Vec* %0, i64 0, i32 0
  store <36 x double> %res.i, <36 x double>* %.sroa.0.0..sroa_idx, align 512
  ret void
}
julia> @code_native A + A
    .text
Filename: SIMD.jl
    pushq   %rbp
    movq    %rsp, %rbp
Source line: 567
    vmovapd 256(%rsi), %ymm0
    vmovapd 224(%rsi), %ymm1
    vmovapd 192(%rsi), %ymm2
    vmovapd 160(%rsi), %ymm3
    vmovapd 128(%rsi), %ymm4
    vmovapd (%rsi), %ymm5
    vmovapd 32(%rsi), %ymm6
    vmovapd 64(%rsi), %ymm7
    vmovapd 96(%rsi), %ymm8
    vaddpd  (%rdx), %ymm5, %ymm5
    vaddpd  32(%rdx), %ymm6, %ymm6
    vaddpd  64(%rdx), %ymm7, %ymm7
    vaddpd  96(%rdx), %ymm8, %ymm8
    vaddpd  128(%rdx), %ymm4, %ymm4
    vaddpd  160(%rdx), %ymm3, %ymm3
    vaddpd  192(%rdx), %ymm2, %ymm2
    vaddpd  224(%rdx), %ymm1, %ymm1
    vaddpd  256(%rdx), %ymm0, %ymm0
Source line: 993
    vmovapd %ymm0, 256(%rdi)
    vmovapd %ymm1, 224(%rdi)
    vmovapd %ymm2, 192(%rdi)
    vmovapd %ymm3, 160(%rdi)
    vmovapd %ymm4, 128(%rdi)
    vmovapd %ymm8, 96(%rdi)
    vmovapd %ymm7, 64(%rdi)
    vmovapd %ymm6, 32(%rdi)
    vmovapd %ymm5, (%rdi)
    movq    %rdi, %rax
    popq    %rbp
    vzeroupper
    retq
    nopl    (%rax)
julia> A + A

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
+ at /home/fredrik/.julia/v0.6/SIMD/src/SIMD.jl:0
unknown function (ip: 0x7f17757ef5e1)
jl_call_fptr_internal at /home/fredrik/julia-master/src/julia_internal.h:326 [inlined]
jl_call_method_internal at /home/fredrik/julia-master/src/julia_internal.h:345 [inlined]
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2225
do_call at /home/fredrik/julia-master/src/interpreter.c:75
eval at /home/fredrik/julia-master/src/interpreter.c:230
jl_interpret_toplevel_expr at /home/fredrik/julia-master/src/interpreter.c:34
jl_toplevel_eval_flex at /home/fredrik/julia-master/src/toplevel.c:577
jl_toplevel_eval_in at /home/fredrik/julia-master/src/builtins.c:484
eval at ./boot.jl:235
unknown function (ip: 0x7f1986e6a9bf)
jl_call_fptr_internal at /home/fredrik/julia-master/src/julia_internal.h:326 [inlined]
jl_call_method_internal at /home/fredrik/julia-master/src/julia_internal.h:345 [inlined]
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2225
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7f17757e30c6)
jl_call_fptr_internal at /home/fredrik/julia-master/src/julia_internal.h:326 [inlined]
jl_call_method_internal at /home/fredrik/julia-master/src/julia_internal.h:345 [inlined]
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2225
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7f17757dad2f)
jl_call_fptr_internal at /home/fredrik/julia-master/src/julia_internal.h:326 [inlined]
jl_call_method_internal at /home/fredrik/julia-master/src/julia_internal.h:345 [inlined]
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2225
jl_apply at /home/fredrik/julia-master/src/julia.h:1410 [inlined]
start_task at /home/fredrik/julia-master/src/task.c:261
unknown function (ip: 0xffffffffffffffff)
Allocations: 3349005 (Pool: 3347456; Big: 1549); GC: 4
Segmentation fault (core dumped)

Actually, doing anything with the Vec, like showing, also segfaults:

julia> A = Vec{36, Float64}((rand(36)...))
36-element SIMD.Vec{36,Float64}:

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
#showarray#256 at ./show.jl:1697
unknown function (ip: 0x7ff0ba4ff36d)
[...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions