hengck23
asked on
How to duplicate values in memory fast?
Dear all,
This is my code:
//Duplicate points
__asm {
mov esi, offsetCount
mov edx, memLocation1
mov eax, memLocation2
mov ecx,DWORD PTR[eax+esi*4] //last value1
mov edi,DWORD PTR[edx+esi*4] //last value2
//duplicate the last values 3 times
mov DWORD PTR[eax+esi*4+4], ecx
mov DWORD PTR[eax+esi*4+8], ecx
mov DWORD PTR[eax+esi*4+12], ecx
mov DWORD PTR[edx+esi*4+4], edi
mov DWORD PTR[edx+esi*4+8], edi
mov DWORD PTR[edx+esi*4+12], edi
add esi, 3
shr esi, 2 //make divisable by 4
mov offsetCount, esi
}
THis code seems to be a bit slow. Is there a better way of doing it?
thank you.
This is my code:
//Duplicate points
__asm {
mov esi, offsetCount
mov edx, memLocation1
mov eax, memLocation2
mov ecx,DWORD PTR[eax+esi*4] //last value1
mov edi,DWORD PTR[edx+esi*4] //last value2
//duplicate the last values 3 times
mov DWORD PTR[eax+esi*4+4], ecx
mov DWORD PTR[eax+esi*4+8], ecx
mov DWORD PTR[eax+esi*4+12], ecx
mov DWORD PTR[edx+esi*4+4], edi
mov DWORD PTR[edx+esi*4+8], edi
mov DWORD PTR[edx+esi*4+12], edi
add esi, 3
shr esi, 2 //make divisable by 4
mov offsetCount, esi
}
THis code seems to be a bit slow. Is there a better way of doing it?
thank you.
That's about as fast as you can store into memory. Why do you think it's slow?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Most PC's nowadays have CPU's that are far faster than memory, so it usually doesnt matter what memory fill code you use, you're limited by the CPU to memory bandwidth. Even with a 533MHz memory bus.
Anyways Case B I posted has potential to be about 40% faster then original code :)
Mainly because of faster execution on CPU :))
regards,
Kate
Mainly because of faster execution on CPU :))
regards,
Kate
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: _Katka_ {http:#13052527}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
mbizup
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: _Katka_ {http:#13052527}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
mbizup
EE Cleanup Volunteer