modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.38k stars 2.6k forks source link

[BUG] When printing the same SIMD vector with multiple print args, SIMD vector values are different #2376

Open VMois opened 7 months ago

VMois commented 7 months ago

Bug description

Values are different when printing SIMD vector as a single argument in print vs second argument.

Steps to reproduce

alias simd_width = 16

fn main():
    print(SIMD[DType.uint8, simd_width](0, 0x0f))
    print("arg 1", SIMD[DType.uint8, simd_width](0, 0x0f))
    print("arg 1", "arg 2", SIMD[DType.uint8, simd_width](0, 0x0f))

Output:

[0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15]
arg 1 [0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
arg 1 arg 2 [0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15]

The correct output should be a second print (arg1 only).

System information

- What OS did you do install Mojo on ? macOS 12.6
- Provide version information for Mojo by pasting the output of `mojo -v` 24.2.1 (2f0dcf11)
- Provide Modular CLI version by pasting the output of `modular -v` 0.6.0 (04c05243)

Host Information
  ================

  Target Triple: aarch64-unknown-macosx
  CPU: apple-m1
  CPU Features: aes, complxnum, crc, dotprod, fp-armv8, fp16fml, fullfp16, jsconv, lse, neon, pauth, ras, rcpc, rdm, sha2, sha3
jayzhan211 commented 7 months ago

I can't reproduce with mojo 2024.4.1618 (37a3e965), nightly

soraros commented 7 months ago

You didn't provide enough values for vector initialisation so I think it's suppose to be UB.