mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
config for x86 (32 bit only, for SH2 drc), add/revive profiling
This commit is contained in:
parent
78d817c370
commit
c1d15f7397
7 changed files with 91 additions and 15 deletions
8
Makefile
8
Makefile
|
@ -13,6 +13,10 @@ CFLAGS += -falign-functions=2
|
|||
endif
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
# profiling
|
||||
pprof ?= 0
|
||||
gperf ?= 0
|
||||
|
||||
all: config.mak target_
|
||||
|
||||
ifndef NO_CONFIG_MAK
|
||||
|
@ -118,6 +122,8 @@ OBJS += platform/gp2x/emu.o
|
|||
OBJS += platform/gp2x/vid_mmsp2.o
|
||||
OBJS += platform/gp2x/vid_pollux.o
|
||||
OBJS += platform/gp2x/warm.o
|
||||
OBJS += platform/gp2x/host_dasm.o
|
||||
OBJS += cpu/sh2/mame/sh2dasm.o
|
||||
USE_FRONTEND = 1
|
||||
PLATFORM_MP3 = 1
|
||||
PLATFORM_ZLIB = 1
|
||||
|
@ -204,7 +210,7 @@ else
|
|||
endif
|
||||
|
||||
pprof: platform/linux/pprof.c
|
||||
$(CC) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@
|
||||
$(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
tools/textfilter: tools/textfilter.c
|
||||
make -C tools/ textfilter
|
||||
|
|
|
@ -9,7 +9,7 @@ CFLAGS += -fno-gcse -funswitch-loops -fweb -ftree-loop-im #-fpredictive-commonin
|
|||
CFLAGS += -I/home/build/opt/GPH_SDK/tools/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/include -I/home/build/src/gp2x/armroot-eabi/include
|
||||
ASFLAGS += -mfloat-abi=soft -mcpu=arm920t
|
||||
LDFLAGS += -B/home/build/opt/GPH_SDK/tools/gcc-4.2.4-glibc-2.7-eabi/lib/gcc/arm-gph-linux-gnueabi/4.2.4 -B/home/build/opt/GPH_SDK/tools/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/lib -L/home/build/opt/GPH_SDK/tools/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/lib -L/home/build/src/gp2x/armroot-eabi/lib -static
|
||||
LDLIBS += -lpng -lm -ldl -lprofiler -lstdc++
|
||||
LDLIBS += -lpng -lm -ldl
|
||||
|
||||
ARCH = arm
|
||||
PLATFORM = gp2x
|
||||
|
|
15
config.x86
Normal file
15
config.x86
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Automatically generated by configure
|
||||
# Configured with: './configure' '--platform=generic'
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
AS = as
|
||||
STRIP = strip
|
||||
CFLAGS += -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wno-unused-result -m32 #-DGPERF -pg
|
||||
ASFLAGS +=
|
||||
LDFLAGS += -m32 #-pg
|
||||
LDLIBS += -L$(HOME)/opt/binutils-i386/usr/lib/ -lbfd-2.24-multiarch -lopcodes-2.24-multiarch
|
||||
LDLIBS += -L/usr/lib/i386-linux-gnu/debug -L/home/build/opt/lib32 -lSDL-1.2 -lasound -lpng -lz -lm -ldl
|
||||
|
||||
ARCH = x86
|
||||
PLATFORM = generic
|
||||
SOUND_DRIVERS = oss alsa sdl
|
|
@ -40,6 +40,10 @@ ifeq "$(pprof)" "1"
|
|||
DEFINES += PPROF
|
||||
SRCS_COMMON += $(R)platform/linux/pprof.c
|
||||
endif
|
||||
ifeq "$(gperf)" "1"
|
||||
DEFINES += GPERF
|
||||
LDFLAGS += -lprofiler -lstdc++
|
||||
endif
|
||||
|
||||
# ARM asm stuff
|
||||
ifeq "$(ARCH)" "arm"
|
||||
|
|
|
@ -90,6 +90,10 @@ int main(int argc, char *argv[])
|
|||
emu_init();
|
||||
menu_init();
|
||||
|
||||
#ifdef GPERF
|
||||
ProfilerStart("gperf.out");
|
||||
#endif
|
||||
|
||||
engineState = PGS_Menu;
|
||||
|
||||
if (argc > 1)
|
||||
|
@ -145,6 +149,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
endloop:
|
||||
#ifdef GPERF
|
||||
ProfilerStop();
|
||||
#endif
|
||||
|
||||
emu_finish();
|
||||
plat_finish();
|
||||
|
|
|
@ -1,21 +1,46 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <pico/pico_int.h>
|
||||
|
||||
int rc_mem[pp_total_points];
|
||||
|
||||
struct pp_counters *pp_counters;
|
||||
int *refcounts = rc_mem;
|
||||
static int shmemid;
|
||||
|
||||
static unsigned long devMem;
|
||||
volatile unsigned long *gp2x_memregl;
|
||||
volatile unsigned short *gp2x_memregs;
|
||||
|
||||
void pprof_init(void)
|
||||
{
|
||||
int this_is_new_shmem = 1;
|
||||
key_t shmemkey;
|
||||
void *shmem;
|
||||
|
||||
#if 0
|
||||
devMem = open("/dev/mem", O_RDWR);
|
||||
if (devMem == -1)
|
||||
{
|
||||
perror("pprof: open failed");
|
||||
return;
|
||||
}
|
||||
gp2x_memregl = (unsigned long *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, devMem, 0xc0000000);
|
||||
if (gp2x_memregl == (unsigned long *)-1)
|
||||
{
|
||||
perror("pprof: mmap failed");
|
||||
return;
|
||||
}
|
||||
gp2x_memregs = (unsigned short *)gp2x_memregl;
|
||||
#endif
|
||||
|
||||
#ifndef PPROF_TOOL
|
||||
unsigned int tmp = pprof_get_one();
|
||||
printf("pprof: measured diff is %u\n", pprof_get_one() - tmp);
|
||||
|
@ -28,11 +53,11 @@ void pprof_init(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef PPROF_TOOL
|
||||
//#ifndef PPROF_TOOL
|
||||
shmemid = shmget(shmemkey, sizeof(*pp_counters),
|
||||
IPC_CREAT | IPC_EXCL | 0644);
|
||||
if (shmemid == -1)
|
||||
#endif
|
||||
//#endif
|
||||
{
|
||||
shmemid = shmget(shmemkey, sizeof(*pp_counters),
|
||||
0644);
|
||||
|
@ -76,15 +101,18 @@ static const struct {
|
|||
IT(draw),
|
||||
IT(sound),
|
||||
IT(m68k),
|
||||
IT(s68k),
|
||||
IT(mem68),
|
||||
IT(z80),
|
||||
IT(msh2),
|
||||
IT(ssh2),
|
||||
IT(memsh),
|
||||
IT(dummy),
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned long long old[pp_total_points], new[pp_total_points];
|
||||
pp_type old[pp_total_points], new[pp_total_points];
|
||||
int base = 0;
|
||||
int l, i;
|
||||
|
||||
|
@ -107,11 +135,12 @@ int main(int argc, char *argv[])
|
|||
memcpy(new, pp_counters->counter, sizeof(new));
|
||||
for (i = 0; i < ARRAY_SIZE(pp_tab); i++)
|
||||
{
|
||||
unsigned long long idiff = new[i] - old[i];
|
||||
unsigned long long bdiff = (new[base] - old[base]) | 1;
|
||||
pp_type idiff = new[i] - old[i];
|
||||
pp_type bdiff = (new[base] - old[base]) | 1;
|
||||
printf("%6.2f ", (double)idiff * 100.0 / bdiff);
|
||||
}
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
memcpy(old, new, sizeof(old));
|
||||
|
||||
if (argc < 3)
|
||||
|
|
|
@ -7,21 +7,22 @@ enum pprof_points {
|
|||
pp_draw,
|
||||
pp_sound,
|
||||
pp_m68k,
|
||||
pp_s68k,
|
||||
pp_mem68,
|
||||
pp_z80,
|
||||
pp_msh2,
|
||||
pp_ssh2,
|
||||
pp_memsh,
|
||||
pp_dummy,
|
||||
pp_total_points
|
||||
};
|
||||
|
||||
struct pp_counters
|
||||
{
|
||||
unsigned long long counter[pp_total_points];
|
||||
};
|
||||
|
||||
extern struct pp_counters *pp_counters;
|
||||
extern int *refcounts;
|
||||
|
||||
#ifdef __i386__
|
||||
typedef unsigned long long pp_type;
|
||||
|
||||
static __attribute__((always_inline)) inline unsigned int pprof_get_one(void)
|
||||
{
|
||||
unsigned long long ret;
|
||||
|
@ -31,24 +32,38 @@ static __attribute__((always_inline)) inline unsigned int pprof_get_one(void)
|
|||
#define unglitch_timer(x)
|
||||
|
||||
#elif defined(__GP2X__)
|
||||
typedef unsigned long pp_type;
|
||||
|
||||
#if 0
|
||||
// XXX: MMSP2 only, timer sometimes seems to return lower vals?
|
||||
extern volatile unsigned long *gp2x_memregl;
|
||||
#define pprof_get_one() (unsigned int)gp2x_memregl[0x0a00 >> 2]
|
||||
#define unglitch_timer(di) \
|
||||
if ((signed int)(di) < 0) di = 0
|
||||
#else
|
||||
extern unsigned int (*gp2x_get_ticks_us)(void);
|
||||
#define pprof_get_one() gp2x_get_ticks_us()
|
||||
#define unglitch_timer(di) \
|
||||
if ((signed int)(di) < 0) di = 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error no timer
|
||||
#endif
|
||||
|
||||
struct pp_counters
|
||||
{
|
||||
pp_type counter[pp_total_points];
|
||||
};
|
||||
|
||||
#define pprof_start(point) { \
|
||||
unsigned int pp_start_##point = pprof_get_one()
|
||||
unsigned int pp_start_##point = pprof_get_one(); refcounts[pp_##point]++
|
||||
|
||||
#define pprof_end(point) \
|
||||
{ \
|
||||
unsigned int di = pprof_get_one() - pp_start_##point; \
|
||||
unglitch_timer(di); \
|
||||
pp_counters->counter[pp_##point] += di; \
|
||||
if (!--refcounts[pp_##point]) pp_counters->counter[pp_##point] += di; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -57,7 +72,7 @@ extern volatile unsigned long *gp2x_memregl;
|
|||
{ \
|
||||
unsigned int di = pprof_get_one() - pp_start_##point; \
|
||||
unglitch_timer(di); \
|
||||
pp_counters->counter[pp_##point] -= di; \
|
||||
if (--refcounts[pp_##point]) pp_counters->counter[pp_##point] -= di; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue