flat assembler
Message board for the users of flat assembler.
Index
> Main > Another question: lock move [edi],eax (for example) |
Author |
|
revolution 16 Jan 2023, 23:08
It won't work. And it doesn't make sense anyway. There is no need for lock if you are only storing a value, or only reading a value. The only use case that is meaningful is when you read-modify-write a value. So lock has been restricted to only those cases.
|
|||
16 Jan 2023, 23:08 |
|
Furs 17 Jan 2023, 14:05
mov is atomic without a lock. Don't be mislead by all the bullshit around the internet claiming stuff like "if you don't use LOCK prefix you'll end up with two different copies in different cache lines of the same memory!". It's not true. Cache invalidation is not rocket science. This can't happen. At least not on x86.
|
|||
17 Jan 2023, 14:05 |
|
Zoltanmatey31 17 Jan 2023, 17:52
ok. I was probably thinking on the line: If instruction handles memory in multiple steps and needs the memory, then why not locking it always?
or if so locking could be always necessery by hand done procedure. |
|||
17 Jan 2023, 17:52 |
|
Furs 18 Jan 2023, 14:31
Zoltanmatey31 wrote: ok. I was probably thinking on the line: If instruction handles memory in multiple steps and needs the memory, then why not locking it always? |
|||
18 Jan 2023, 14:31 |
|
revolution 18 Jan 2023, 18:49
Furs wrote: LOCKing the bus is expensive. Some results I recorded previously showed a 44x slowdown. Code: ~ ./no_lock real 0m0.081s user 0m0.072s sys 0m0.004s ~ ./with_lock real 0m3.202s user 0m3.152s sys 0m0.000s Code: format elf64 executable SYS64_EXIT = 60 MEM_COUNT = 1 shl 16 LOOPS = 1 shl 7 segment executable readable writeable mov rdx,LOOPS .loop_outer: lea rsi,[foo] mov ecx,MEM_COUNT .loop_inner: lock ;toggle these two instructions for lock vs no lock ; nop ;toggle these two instructions for lock vs no lock inc qword[rsi] add rsi,8 loop .loop_inner dec rdx jnz .loop_outer mov eax,SYS64_EXIT syscall foo rq MEM_COUNT Note: the foo array is unaligned. This was a deliberate choice for the test that was done at the time. |
|||
18 Jan 2023, 18:49 |
|
DimonSoft 19 Jan 2023, 15:08
Comparison of summing matrix elements iterating by rows vs by columns usually gave me something around 40x. Just as an example of something close in its effect on performance.
|
|||
19 Jan 2023, 15:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.