2009-04-03 Ken Werner <ken.werner@de.ibm.com>
* libc/machine/spu/spu-gmon.c: Tweaks to support simultaneous SPU profiling.
This commit is contained in:
parent
051f7595ff
commit
f42552e9e1
newlib
|
@ -1,3 +1,8 @@
|
||||||
|
2009-04-03 Ken Werner <ken.werner@de.ibm.com>
|
||||||
|
|
||||||
|
* libc/machine/spu/spu-gmon.c: Tweaks to support simultaneous SPU
|
||||||
|
profiling.
|
||||||
|
|
||||||
2009-04-03 Ken Werner <ken.werner@de.ibm.com>
|
2009-04-03 Ken Werner <ken.werner@de.ibm.com>
|
||||||
|
|
||||||
* libc/include/math.h: Remove duplicate copysign prototype.
|
* libc/include/math.h: Remove duplicate copysign prototype.
|
||||||
|
|
|
@ -43,6 +43,7 @@ Author: Ken Werner <ken.werner@de.ibm.com>
|
||||||
#include <spu_mfcio.h>
|
#include <spu_mfcio.h>
|
||||||
#include <spu_timer.h>
|
#include <spu_timer.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <sys/linux_syscalls.h>
|
||||||
|
|
||||||
/* Magic cookie. */
|
/* Magic cookie. */
|
||||||
#define GMON_MAGIC_COOKIE "gmon"
|
#define GMON_MAGIC_COOKIE "gmon"
|
||||||
|
@ -113,6 +114,13 @@ struct rawarc
|
||||||
extern char _start;
|
extern char _start;
|
||||||
extern char _etext;
|
extern char _etext;
|
||||||
|
|
||||||
|
/* EAR entry for the starting address of SPE executable image. */
|
||||||
|
extern const unsigned long long _EAR_;
|
||||||
|
asm (".section .toe,\"a\",@nobits\n\r"
|
||||||
|
".align 4\n\r"
|
||||||
|
".type _EAR_, @object\n\r"
|
||||||
|
".size _EAR_, 16\n" "_EAR_: .space 16\n" ".previous");
|
||||||
|
|
||||||
/* froms are indexing tos */
|
/* froms are indexing tos */
|
||||||
static __ea unsigned short *froms;
|
static __ea unsigned short *froms;
|
||||||
static __ea struct tostruct *tos = 0;
|
static __ea struct tostruct *tos = 0;
|
||||||
|
@ -251,8 +259,9 @@ __mcleanup (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__monstartup (void)
|
__monstartup (unsigned long long spu_id)
|
||||||
{
|
{
|
||||||
|
char filename[64];
|
||||||
s_lowpc =
|
s_lowpc =
|
||||||
ROUNDDOWN ((uintptr_t) & _start, HISTFRACTION * sizeof (HISTCOUNTER));
|
ROUNDDOWN ((uintptr_t) & _start, HISTFRACTION * sizeof (HISTCOUNTER));
|
||||||
s_highpc =
|
s_highpc =
|
||||||
|
@ -284,23 +293,35 @@ __monstartup (void)
|
||||||
}
|
}
|
||||||
memset_ea (tos, 0, tolimit * sizeof (struct tostruct));
|
memset_ea (tos, 0, tolimit * sizeof (struct tostruct));
|
||||||
|
|
||||||
|
/* Determine the gmon.out file name. */
|
||||||
|
if (spu_id)
|
||||||
|
snprintf (filename, sizeof (filename), "gmon-%d-%llu-%llu.out",
|
||||||
|
linux_getpid (), spu_id, _EAR_);
|
||||||
|
else
|
||||||
|
strncpy (filename, "gmon.out", sizeof (filename));
|
||||||
/* Open the gmon.out file. */
|
/* Open the gmon.out file. */
|
||||||
fd = open ("gmon.out", O_RDWR | O_CREAT | O_TRUNC, 0644);
|
fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
perror ("can't open gmon.out file");
|
char errstr[128];
|
||||||
|
snprintf (errstr, sizeof (errstr), "Cannot open file: %s", filename);
|
||||||
|
perror (errstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Truncate the file up to the size where the histogram fits in. */
|
/* Truncate the file up to the size where the histogram fits in. */
|
||||||
if (ftruncate (fd,
|
if (ftruncate (fd,
|
||||||
sizeof (struct gmon_hdr) + 1 + sizeof (struct gmon_hist_hdr) + hist_size) ==
|
sizeof (struct gmon_hdr) + 1 +
|
||||||
-1)
|
sizeof (struct gmon_hist_hdr) + hist_size) == -1)
|
||||||
perror ("can't truncate the gmon.out file");
|
{
|
||||||
|
char errstr[128];
|
||||||
|
snprintf (errstr, sizeof (errstr), "Cannot truncate file: %s", filename);
|
||||||
|
perror (errstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start the histogram sampler. */
|
/* Start the histogram sampler. */
|
||||||
spu_slih_register (MFC_DECREMENTER_EVENT, spu_clock_slih);
|
spu_slih_register (MFC_DECREMENTER_EVENT, spu_clock_slih);
|
||||||
timer_id = spu_timer_alloc (spu_timebase () / SAMPLE_INTERVAL,
|
timer_id = spu_timer_alloc (spu_timebase () / SAMPLE_INTERVAL, __sample);
|
||||||
__sample);
|
|
||||||
spu_clock_start ();
|
spu_clock_start ();
|
||||||
spu_timer_start (timer_id);
|
spu_timer_start (timer_id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue