mojo
mojo copied to clipboard
[BUG] `SIMD.store/load` for `DType.bool`
Bug description
Hello, after implementing List.__contains__
for Scalar[DT]
,
tests failed with DType.bool
!
Minimal repro:
alias width = simdwidthof[DType.bool]()
var x = DTypePointer[DType.bool].alloc(width)
alias T = SIMD[DType.bool, width]
T.store(x, T(True))
print(T.load(x)) #32 elements True
x[0] = False
print(T.load(x)) #8 firsts elements False
x.free()
Note: it seem to work correctly with others DType
Important: if we initialized with T.store(x, T(False))
instead,
and do x[0] = True
, it seem to work correctly, but it's not:
assigning to offset 1 results in item 8 being changed
This test shows different results:
for i in range(width):
print(x[i])` # see first four bytes
Possible fix:
It seem to think that the size of the type is 8 bytes
(debugging with DTypePointer.__setitem__
and __getitem__
)
(ping to @laszlokindrat)
Steps to reproduce
Nothing special, the steps are in the description :+1:
System information
- Ubuntu 23.10
- mojo 2024.7.1105 (211527ca)
- modular 0.7.2 (d0adc668)