Optimized memcpy to reduce cache misses

J

John Edwards

I'm trying to come up with a more cache efficient memcpy loop
to reduce the number of cache misses I'm experiencing.

My current solution:

for (i = 1; i < numlines; i++)
{
foo(Offset >= 0);
RMemCopy(CurrentPos, Line, (unsigned)Abs(Offset));
CurrentPos += Offset;
}



I'm even open to inline ASM.

Any ideas?
 
D

Dave Rahardja

I'm trying to come up with a more cache efficient memcpy loop
to reduce the number of cache misses I'm experiencing.

My current solution:

for (i = 1; i < numlines; i++)
{
foo(Offset >= 0);
RMemCopy(CurrentPos, Line, (unsigned)Abs(Offset));
CurrentPos += Offset;
}



I'm even open to inline ASM.

Any ideas?

This is not a C++-related question, but a microprocessor-specific one.

Having said that, I have written memcpy and memset routines that are
specifically targeted to take advantage of a particular microprocessor's
instruction and data cache architecture.

How I did it is beyond the scope of this newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top