Skip to content

Surprisingly slow performance on tight loop with integer operations on SIMD/List get/set #2857

Locked Answered by rd4com
lukehoban asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @lukehoban , using references it should be faster! (Make sure to write some tests)

# nightly 2024.5.2705 (a737cd65)

fn main() raises:
    var program = List[UInt32]()
    var f = file.open("sandmark.umz", "r")
    while True:
        var byts = f.read_bytes(4)
        if len(byts) < 4:
            break
        var i: UInt32 = 0
        for n in range(4):
            i = (i << 8) + byts[n].cast[DType.uint8]().cast[DType.uint32]()
        program.append(i)
    var platters = List[List[UInt32]](program)
    var reg = SIMD[DType.uint32, 8](0,0,0,0,0,0,0,0)
    var finger = 0
    var iteration = 0
    var start = time.now()
    while True:
        var v = platters.__get_ref(0)[].__get_…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by lukehoban
Comment options

You must be logged in to vote
1 reply
@rd4com
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants