This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Optimize MIPS memcpy


On Tue, 2012-10-09 at 11:30 +1300, Maxim Kuvyrkov wrote:

> I too want to keep prepare-for-store prefetches is possible.  For debugging purposes you could amend
> prepare-for-store prefetch macros to trigger a loop that would unconditionally clobber memory locations
> that prepare-for-store is expected to zero-out.  Or add some other assertions to help out with debugging.
> 
> Thanks,
> 
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics

Maxim,

Could you try running this test program on your system.  I want to see
if it verifies that your machine is doing 32 byte prefetches.  The
output I get looks like:


0x004754a0, (0x004754a0 to 0x004754c0, 32 byte prefetch)
0x004754a1, (0x004754a0 to 0x004754c0, 32 byte prefetch)
0x004754a2, (0x004754a0 to 0x004754c0, 32 byte prefetch)
0x004754a3, (0x004754a0 to 0x004754c0, 32 byte prefetch)
0x004754a4, (0x004754a0 to 0x004754c0, 32 byte prefetch)
0x004754a5, (0x004754a0 to 0x004754c0, 32 byte prefetch)
.
.
.
0x0047589b, (0x00475880 to 0x004758a0, 32 byte prefetch)
0x0047589c, (0x00475880 to 0x004758a0, 32 byte prefetch)
0x0047589d, (0x00475880 to 0x004758a0, 32 byte prefetch)
0x0047589e, (0x00475880 to 0x004758a0, 32 byte prefetch)
0x0047589f, (0x00475880 to 0x004758a0, 32 byte prefetch)

Steve Ellcey
sellcey@mips.com
#include <stdio.h>

char dummy[409600];
char buffer[3072];


check_buffer(char *p)
{
	int i, zero_start, zero_stop;
	/* Initialize buffer to non-zero data */
	for (i = 0; i < 2048; i++)
		buffer[i] = 1;

	/* Clear buffer out of cache */
	for (i = 0; i < 409600; i++)
		dummy[i] = 9;

#if 1
	__asm__ ("pref 30, 0x0(%0)" : : "r" (p));
#endif

	/* Check contents for single block of zeros */
	zero_start = 0;
	while ((buffer[zero_start] == 1) && (zero_start < 2048)) zero_start++;
	zero_stop = zero_start;
	while ((buffer[zero_stop] == 0) && (zero_stop < 2048)) zero_stop++;
	for (i = zero_stop; i < 2048; i++)
		if (buffer[i] == 0) printf("Error, extra set of zeros\n");

	if (zero_start >= 2048)
		printf("0x%8.8x, (no zeros)\n", p);
	else
		printf("0x%8.8x, (0x%8.8x to 0x%8.8x, %d byte prefetch)\n", p, &buffer[zero_start], &buffer[zero_stop], (zero_stop - zero_start));

#if 0
	/* Dump buffer contents */
	for (i = 0; i < 2048; i++)
		printf("%1d", buffer[i]);
	printf("\n");
#endif
}

main()
{
	int i;
	for (i = 1024; i < 2048; i++)
		check_buffer(&buffer[i]);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]