-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathtest_benchmark.c
More file actions
638 lines (590 loc) · 20.8 KB
/
test_benchmark.c
File metadata and controls
638 lines (590 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/* Headless benchmark tool: loads core via dlopen, runs N frames, and
reports wall-clock timing (total, FPS, ms/frame).
Usage: test_benchmark <core.dylib> <rom_file> [num_frames]
[--blitter fast|accurate] [--warmup N] [--load-srm file]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __APPLE__
#include <mach/mach_time.h>
#else
#include <time.h>
#endif
#include "../../libretro-common/include/libretro.h"
/* Function pointers loaded from the core */
static void (*pretro_set_environment)(retro_environment_t);
static void (*pretro_set_video_refresh)(retro_video_refresh_t);
static void (*pretro_set_audio_sample)(retro_audio_sample_t);
static void (*pretro_set_audio_sample_batch)(retro_audio_sample_batch_t);
static void (*pretro_set_input_poll)(retro_input_poll_t);
static void (*pretro_set_input_state)(retro_input_state_t);
static void (*pretro_init)(void);
static void (*pretro_deinit)(void);
static bool (*pretro_load_game)(const struct retro_game_info *);
static void (*pretro_run)(void);
static void (*pretro_unload_game)(void);
static void *(*pretro_get_memory_data)(unsigned);
static size_t (*pretro_get_memory_size)(unsigned);
static size_t (*pretro_serialize_size)(void);
static bool (*pretro_unserialize)(const void *, size_t);
/* Optional: only present when the core was built with BENCH_PROFILE=1. */
static void (*pperf_counters_dump)(FILE *);
static unsigned long long *(*pperf_counters_find)(const char *);
/* Options state */
static int bios_option_set = 0;
static const char *blitter_value = "enabled"; /* default: fast blitter */
/* High-resolution timer helpers */
#ifdef __APPLE__
static mach_timebase_info_data_t timebase_info;
static uint64_t timer_now(void)
{
return mach_absolute_time();
}
static double timer_elapsed_sec(uint64_t start, uint64_t end)
{
uint64_t elapsed = end - start;
if (timebase_info.denom == 0)
mach_timebase_info(&timebase_info);
/* Convert to nanoseconds, then seconds */
return (double)elapsed * (double)timebase_info.numer / (double)timebase_info.denom / 1e9;
}
#else
static uint64_t timer_now(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)ts.tv_sec * 1000000000ULL + (uint64_t)ts.tv_nsec;
}
static double timer_elapsed_sec(uint64_t start, uint64_t end)
{
return (double)(end - start) / 1e9;
}
#endif
static void log_printf(enum retro_log_level level, const char *fmt, ...)
{
va_list ap;
const char *lvl_str = "???";
switch (level) {
case RETRO_LOG_DEBUG: lvl_str = "DBG"; break;
case RETRO_LOG_INFO: lvl_str = "INF"; break;
case RETRO_LOG_WARN: lvl_str = "WRN"; break;
case RETRO_LOG_ERROR: lvl_str = "ERR"; break;
default: break;
}
fprintf(stderr, "[%s] ", lvl_str);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
static bool environment_cb(unsigned cmd, void *data)
{
switch (cmd)
{
case RETRO_ENVIRONMENT_GET_LOG_INTERFACE:
{
struct retro_log_callback *cb = (struct retro_log_callback *)data;
cb->log = log_printf;
return true;
}
case RETRO_ENVIRONMENT_SET_PIXEL_FORMAT:
return true;
case RETRO_ENVIRONMENT_GET_VARIABLE:
{
struct retro_variable *var = (struct retro_variable *)data;
if (strcmp(var->key, "virtualjaguar_bios") == 0)
{
var->value = "enabled";
bios_option_set = 1;
return true;
}
if (strcmp(var->key, "virtualjaguar_pal") == 0)
{
var->value = "disabled";
return true;
}
if (strcmp(var->key, "virtualjaguar_usefastblitter") == 0)
{
var->value = blitter_value;
return true;
}
var->value = NULL;
return false;
}
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE:
{
bool *updated = (bool *)data;
*updated = false;
return true;
}
case RETRO_ENVIRONMENT_SET_MEMORY_MAPS:
case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS:
case RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2:
case RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK:
return true;
case RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION:
{
unsigned *version = (unsigned *)data;
*version = 2;
return true;
}
case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
return true;
case RETRO_ENVIRONMENT_GET_INPUT_BITMASKS:
return false;
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
*(const char **)data = "test/roms/private";
return true;
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
*(const char **)data = "/tmp";
return true;
default:
return false;
}
}
static void video_refresh(const void *data, unsigned width, unsigned height, size_t pitch)
{
(void)data; (void)width; (void)height; (void)pitch;
}
static void audio_sample(int16_t left, int16_t right)
{
(void)left; (void)right;
}
static size_t audio_sample_batch(const int16_t *data, size_t frames)
{
(void)data;
return frames;
}
static void input_poll(void) {}
static int16_t input_state(unsigned port, unsigned device, unsigned index, unsigned id)
{
(void)port; (void)device; (void)index; (void)id;
return 0;
}
static void print_usage(const char *progname)
{
fprintf(stderr,
"Usage: %s <core.dylib> <rom_file> [num_frames]\n"
" [--blitter fast|accurate] [--warmup N] [--load-srm file]\n"
" [--load-state file]\n"
"\n"
"Options:\n"
" num_frames Number of frames to benchmark (default: 300)\n"
" --blitter fast Use fast blitter (default)\n"
" --blitter accurate Use accurate (Midsummer2) blitter\n"
" --warmup N Run N warmup frames before timing\n"
" --load-srm file Load EEPROM save data from file\n"
" --load-state file Load a save state into the core after retro_load_game.\n"
" Accepts raw retro_serialize() payloads or RetroArch\n"
" RASTATE container files (the MEM chunk is extracted).\n",
progname);
}
int main(int argc, char **argv)
{
void *handle;
const char *core_path;
const char *rom_path;
const char *srm_load_path = NULL;
const char *state_load_path = NULL;
struct retro_game_info info;
FILE *f;
long fsize;
int i;
int num_frames = 300;
int warmup_frames = 0;
uint64_t t_start, t_end;
double elapsed, fps, ms_per_frame;
if (argc < 3)
{
print_usage(argv[0]);
return 1;
}
core_path = argv[1];
rom_path = argv[2];
/* Parse optional arguments */
for (i = 3; i < argc; i++)
{
if (strcmp(argv[i], "--blitter") == 0 && i + 1 < argc)
{
const char *mode = argv[++i];
if (strcmp(mode, "fast") == 0)
blitter_value = "enabled";
else if (strcmp(mode, "accurate") == 0)
blitter_value = "disabled";
else
{
fprintf(stderr, "Unknown blitter mode: %s (use 'fast' or 'accurate')\n", mode);
return 1;
}
}
else if (strcmp(argv[i], "--warmup") == 0 && i + 1 < argc)
warmup_frames = atoi(argv[++i]);
else if (strcmp(argv[i], "--load-srm") == 0 && i + 1 < argc)
srm_load_path = argv[++i];
else if (strcmp(argv[i], "--load-state") == 0 && i + 1 < argc)
state_load_path = argv[++i];
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
{
print_usage(argv[0]);
return 0;
}
else
num_frames = atoi(argv[i]);
}
#ifdef __APPLE__
/* Initialize timebase for mach_absolute_time conversion */
mach_timebase_info(&timebase_info);
#endif
/* Load ROM */
f = fopen(rom_path, "rb");
if (!f)
{
fprintf(stderr, "Cannot open ROM: %s\n", rom_path);
return 1;
}
fseek(f, 0, SEEK_END);
fsize = ftell(f);
fseek(f, 0, SEEK_SET);
info.data = malloc(fsize);
info.size = fsize;
info.path = rom_path;
info.meta = NULL;
if (fread((void *)info.data, 1, fsize, f) != (size_t)fsize)
{
fprintf(stderr, "Failed to read ROM\n");
fclose(f);
return 1;
}
fclose(f);
/* Load core */
handle = dlopen(core_path, RTLD_LAZY);
if (!handle)
{
fprintf(stderr, "dlopen failed: %s\n", dlerror());
free((void *)info.data);
return 1;
}
#define LOAD_SYM(sym) do { \
p##sym = dlsym(handle, #sym); \
if (!p##sym) { fprintf(stderr, "Missing symbol: " #sym "\n"); return 1; } \
} while(0)
LOAD_SYM(retro_set_environment);
LOAD_SYM(retro_set_video_refresh);
LOAD_SYM(retro_set_audio_sample);
LOAD_SYM(retro_set_audio_sample_batch);
LOAD_SYM(retro_set_input_poll);
LOAD_SYM(retro_set_input_state);
LOAD_SYM(retro_init);
LOAD_SYM(retro_deinit);
LOAD_SYM(retro_load_game);
LOAD_SYM(retro_run);
LOAD_SYM(retro_unload_game);
LOAD_SYM(retro_get_memory_data);
LOAD_SYM(retro_get_memory_size);
LOAD_SYM(retro_serialize_size);
LOAD_SYM(retro_unserialize);
/* Optional perf-counter access; absent unless built with BENCH_PROFILE=1. */
pperf_counters_dump = dlsym(handle, "perf_counters_dump");
pperf_counters_find = dlsym(handle, "perf_counters_find");
pretro_set_environment(environment_cb);
pretro_set_video_refresh(video_refresh);
pretro_set_audio_sample(audio_sample);
pretro_set_audio_sample_batch(audio_sample_batch);
pretro_set_input_poll(input_poll);
pretro_set_input_state(input_state);
pretro_init();
fprintf(stderr, "--- Benchmark configuration ---\n");
fprintf(stderr, " Core: %s\n", core_path);
fprintf(stderr, " ROM: %s\n", rom_path);
fprintf(stderr, " Blitter: %s\n",
strcmp(blitter_value, "enabled") == 0 ? "fast" : "accurate");
fprintf(stderr, " BIOS: %s\n", bios_option_set ? "enabled" : "enabled (pending)");
fprintf(stderr, " Warmup: %d frames\n", warmup_frames);
fprintf(stderr, " Measure: %d frames\n", num_frames);
fprintf(stderr, "---\n");
if (!pretro_load_game(&info))
{
fprintf(stderr, "retro_load_game failed!\n");
free((void *)info.data);
dlclose(handle);
return 1;
}
/* Load SRM (EEPROM save) if provided */
if (srm_load_path)
{
void *save_data = pretro_get_memory_data(0);
size_t save_size = pretro_get_memory_size(0);
if (save_data && save_size > 0)
{
FILE *sf = fopen(srm_load_path, "rb");
if (sf)
{
size_t srm_size;
fseek(sf, 0, SEEK_END);
srm_size = (size_t)ftell(sf);
fseek(sf, 0, SEEK_SET);
if (srm_size <= save_size)
{
if (fread(save_data, 1, srm_size, sf) == srm_size)
fprintf(stderr, "--- Loaded SRM from %s (%zu bytes into %zu) ---\n",
srm_load_path, srm_size, save_size);
}
fclose(sf);
}
else
fprintf(stderr, "WARNING: Cannot open SRM file: %s\n", srm_load_path);
}
else
fprintf(stderr, "WARNING: Core reports no SAVE_RAM area\n");
}
/* Load save state if provided. Accepts both raw retro_serialize()
* payloads and RetroArch RASTATE container files (extracts the
* MEM chunk). See https://github.com/libretro/RetroArch on the
* RASTATE format. */
if (state_load_path)
{
FILE *stf = NULL;
long st_total = 0;
uint8_t *st_buf = NULL;
const uint8_t *payload = NULL;
size_t payload_size = 0;
size_t expected;
const char *state_err = NULL;
stf = fopen(state_load_path, "rb");
if (!stf)
{
state_err = "cannot open state file";
goto state_fail;
}
if (fseek(stf, 0, SEEK_END) != 0)
{
state_err = "fseek to end failed";
goto state_fail;
}
st_total = ftell(stf);
if (st_total <= 0)
{
state_err = "ftell failed or empty state file";
goto state_fail;
}
if (fseek(stf, 0, SEEK_SET) != 0)
{
state_err = "fseek to start failed";
goto state_fail;
}
st_buf = (uint8_t *)malloc((size_t)st_total);
if (!st_buf)
{
state_err = "malloc failed for state buffer";
goto state_fail;
}
if (fread(st_buf, 1, (size_t)st_total, stf) != (size_t)st_total)
{
state_err = "short read on state file";
goto state_fail;
}
fclose(stf);
stf = NULL;
payload = st_buf;
payload_size = (size_t)st_total;
/* RASTATE container? "RASTATE" + 1 version byte, then chunks. */
if (st_total >= 16 && memcmp(st_buf, "RASTATE", 7) == 0)
{
const uint8_t *p = st_buf + 8; /* past magic+version */
const uint8_t *end = st_buf + st_total;
int found = 0;
/* Each chunk: 4-byte type + 4-byte LE size + payload. */
while (p + 8 <= end)
{
uint32_t chunk_size = (uint32_t)p[4] | ((uint32_t)p[5] << 8)
| ((uint32_t)p[6] << 16) | ((uint32_t)p[7] << 24);
/* Bounds-check the declared chunk size against the buffer. */
if (chunk_size > (uint32_t)(end - (p + 8)))
{
state_err = "RASTATE chunk size overruns buffer";
goto state_fail;
}
if (memcmp(p, "MEM ", 4) == 0)
{
payload = p + 8;
payload_size = chunk_size;
found = 1;
break;
}
p += 8 + chunk_size;
}
if (!found)
{
state_err = "no MEM chunk in RASTATE file";
goto state_fail;
}
fprintf(stderr, "--- RASTATE: extracted MEM chunk (%zu bytes) ---\n", payload_size);
}
expected = pretro_serialize_size();
fprintf(stderr, "--- State payload: %zu bytes (core expects %zu) ---\n",
payload_size, expected);
if (!pretro_unserialize(payload, payload_size))
{
state_err = "retro_unserialize failed";
goto state_fail;
}
fprintf(stderr, "--- State loaded from %s ---\n", state_load_path);
free(st_buf);
st_buf = NULL;
if (0)
{
state_fail:
fprintf(stderr, "ERROR: %s: %s\n",
state_err ? state_err : "state load error",
state_load_path);
if (stf) fclose(stf);
if (st_buf) free(st_buf);
pretro_unload_game();
pretro_deinit();
free((void *)info.data);
dlclose(handle);
return 1;
}
}
/* Run warmup frames (not timed) */
if (warmup_frames > 0)
{
fprintf(stderr, "--- Running %d warmup frames ---\n", warmup_frames);
for (i = 0; i < warmup_frames; i++)
pretro_run();
fprintf(stderr, "--- Warmup complete ---\n");
}
/* Timed run with per-frame samples to expose variance. Audio
* dropouts in real frontends are caused by *worst-case* frames
* exceeding the 16.6 ms (60 Hz) budget, not by the average. */
{
double *frame_ms = (double *)malloc((size_t)num_frames * sizeof(double));
unsigned long long *blit_calls_at_frame = (unsigned long long *)malloc((size_t)num_frames * sizeof(unsigned long long));
unsigned long long *blit_inner_at_frame = (unsigned long long *)malloc((size_t)num_frames * sizeof(unsigned long long));
double frame_budget_ms = 1000.0 / 60.0;
int over_budget = 0;
double max_ms = 0.0;
double p50_ms = 0.0, p99_ms = 0.0, p999_ms = 0.0;
unsigned long long *blit_calls_ctr = pperf_counters_find ? pperf_counters_find("blitter_calls") : NULL;
unsigned long long *blit_inner_ctr = pperf_counters_find ? pperf_counters_find("blitter_inner") : NULL;
unsigned long long blit_calls_prev = blit_calls_ctr ? *blit_calls_ctr : 0;
unsigned long long blit_inner_prev = blit_inner_ctr ? *blit_inner_ctr : 0;
if (!frame_ms || !blit_calls_at_frame || !blit_inner_at_frame)
{
fprintf(stderr, "ERROR: malloc failed for per-frame timing\n");
pretro_unload_game(); pretro_deinit();
free((void *)info.data); dlclose(handle);
return 1;
}
fprintf(stderr, "--- Benchmarking %d frames ---\n", num_frames);
t_start = timer_now();
for (i = 0; i < num_frames; i++)
{
uint64_t f0 = timer_now();
uint64_t f1;
pretro_run();
f1 = timer_now();
frame_ms[i] = timer_elapsed_sec(f0, f1) * 1000.0;
if (blit_calls_ctr) {
blit_calls_at_frame[i] = *blit_calls_ctr - blit_calls_prev;
blit_calls_prev = *blit_calls_ctr;
} else blit_calls_at_frame[i] = 0;
if (blit_inner_ctr) {
blit_inner_at_frame[i] = *blit_inner_ctr - blit_inner_prev;
blit_inner_prev = *blit_inner_ctr;
} else blit_inner_at_frame[i] = 0;
}
t_end = timer_now();
elapsed = timer_elapsed_sec(t_start, t_end);
fps = (double)num_frames / elapsed;
ms_per_frame = (elapsed * 1000.0) / (double)num_frames;
/* Quicksort copy so the original order is preserved for any
* later analysis (currently we don't print it, but cheap). */
{
double *sorted = (double *)malloc((size_t)num_frames * sizeof(double));
int j;
if (sorted)
{
memcpy(sorted, frame_ms, (size_t)num_frames * sizeof(double));
/* Insertion sort (small N typical). */
for (i = 1; i < num_frames; i++)
{
double key = sorted[i];
j = i - 1;
while (j >= 0 && sorted[j] > key) { sorted[j + 1] = sorted[j]; j--; }
sorted[j + 1] = key;
}
p50_ms = sorted[(int)((double)num_frames * 0.50)];
p99_ms = sorted[(int)((double)num_frames * 0.99)];
p999_ms = sorted[(int)((double)num_frames * 0.999)];
max_ms = sorted[num_frames - 1];
free(sorted);
}
}
for (i = 0; i < num_frames; i++)
if (frame_ms[i] > frame_budget_ms) over_budget++;
/* Print results */
printf("\n=== BENCHMARK RESULTS ===\n");
printf("Blitter mode: %s\n",
strcmp(blitter_value, "enabled") == 0 ? "fast" : "accurate");
printf("Frames measured: %d\n", num_frames);
printf("Warmup frames: %d\n", warmup_frames);
printf("Total time: %.3f s\n", elapsed);
printf("Frames/sec: %.2f\n", fps);
printf("Time/frame avg: %.3f ms\n", ms_per_frame);
printf("Time/frame p50: %.3f ms\n", p50_ms);
printf("Time/frame p99: %.3f ms\n", p99_ms);
printf("Time/frame p999: %.3f ms\n", p999_ms);
printf("Time/frame max: %.3f ms\n", max_ms);
printf("Over 16.67 ms: %d / %d frames (%.2f%%)\n",
over_budget, num_frames, 100.0 * over_budget / num_frames);
printf("=========================\n");
/* If we have per-frame blitter counters, dump the slowest frames
* so we can correlate blit volume with frame-time spikes. */
if (over_budget > 0 && blit_calls_ctr) {
int j;
double avg_calls = 0.0, avg_inner = 0.0;
double slow_calls = 0.0, slow_inner = 0.0;
int slow_n = 0;
printf("\n--- Worst frames (>16.67ms) -----------------------------\n");
printf(" idx frame_ms blit_calls blit_inner_iter\n");
for (j = 0; j < num_frames; j++) {
avg_calls += blit_calls_at_frame[j];
avg_inner += blit_inner_at_frame[j];
if (frame_ms[j] > frame_budget_ms) {
slow_calls += blit_calls_at_frame[j];
slow_inner += blit_inner_at_frame[j];
slow_n++;
if (slow_n <= 12)
printf(" %4d %7.2f %10llu %15llu\n",
j, frame_ms[j],
blit_calls_at_frame[j],
blit_inner_at_frame[j]);
}
}
printf("---\n");
printf("Avg per frame (all): blits=%.0f inner_iter=%.0f\n",
avg_calls / num_frames, avg_inner / num_frames);
if (slow_n > 0)
printf("Avg per frame (slow): blits=%.0f inner_iter=%.0f (%dx, %dx vs avg)\n",
slow_calls / slow_n, slow_inner / slow_n,
(int)((slow_calls / slow_n) / (avg_calls / num_frames + 1e-9)),
(int)((slow_inner / slow_n) / (avg_inner / num_frames + 1e-9)));
printf("=========================================================\n");
}
free(frame_ms);
free(blit_calls_at_frame);
free(blit_inner_at_frame);
}
if (pperf_counters_dump)
pperf_counters_dump(stderr);
pretro_unload_game();
pretro_deinit();
free((void *)info.data);
dlclose(handle);
return 0;
}