It is currently Mon Jun 18, 2018 9:51 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun May 20, 2018 7:35 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3117
Location: Brazil
My emulator is running at 330 FPS in my Core i5-2320 3GHz, not the most modern PC. By playing a NSF, it goes at 550 FPS. Even with all the recent optimizations, including the gcc -march=atom, my emulator stucks at 30 FPS in my netbook (HP Mini Intel Atom with Windows 7 Starter). In rare times, I got 70 FPS, but something seems wrong, since the speed seems to slowdown and get stuck at 30 or a value between 19 and 26 FPS. There's no secret in my gcc flags, -Ofast -Wall -funroll-loops -ffast-math -fomit-frame-pointer -pipe -flto.

Any thoughts?


Top
 Profile  
 
PostPosted: Sun May 20, 2018 7:45 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20159
Location: NE Indiana, USA (NTSC)
The CPU is an Atom N450, the same as in the Inspiron mini 1012 that I used to use. It has 1 in-order core and 2 threads. To get the most out of that core in the face of load and branch penalties, you'll need to keep both threads busy.

The first thing I'd try is to handle audio timing, such as the 240 Hz clock, in your CPU thread and signal generation in another thread. And if you're doing any video filtering, such as NTSC or Scale2x, I'd recommend pushing that out to a thread as well. On scanlines that don't contain sprite 0, you could run the PPU mostly in its own thread and pass only catch-up logs to the PPU thread.


Top
 Profile  
 
PostPosted: Sun May 20, 2018 7:51 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3076
Location: Tampere, Finland
If it runs fast at first but then slows down, that might be due to dynamic frequency scaling in the processor. For example, if the CPU heats up too much it will try compensate by tuning down the clock frequency. You may want to monitor the CPU clock frequency while you run the emulator.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Sun May 20, 2018 8:53 am 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 985
One thing I read is that -funroll-loops will not always help (this is due to the instruction cache, if the computer has one), so try removing that flag and see if it work better; see whether it is better with or without that flag.

_________________
.


Top
 Profile  
 
PostPosted: Sun May 20, 2018 8:57 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7211
Location: Seattle
Zepper wrote:
-funroll-loops
Unrolling loops doesn't necessarily make code faster; it trades branch penalties for RAM bandwidth.

Gcc's manual page says
This option makes code larger, and may or may not make it run faster.


I'd see what fell out of the profiler (-pg) to figure out what's consuming more time.

The person who wrote VirtualDub has a blog entry about optimizing code for the Atom and it's not clear that any compiler other than Intel's own knows how to optimize for the N450's in-order CPU.


Top
 Profile  
 
PostPosted: Sun May 20, 2018 9:41 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4050
How does QuickNES run on an Atom?

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun May 20, 2018 9:42 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3117
Location: Brazil
lidnariq wrote:
Zepper wrote:
-funroll-loops
Unrolling loops doesn't necessarily make code faster; it trades branch penalties for RAM bandwidth.

Gcc's manual page says
This option makes code larger, and may or may not make it run faster.


Removing the -funroll-loops makes the FPS to be... 274~280 (much slower).
On Atom, no difference... except the dropping effect in framerate again.


Last edited by Zepper on Sun May 20, 2018 9:49 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun May 20, 2018 9:44 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3117
Location: Brazil
Dwedit wrote:
How does QuickNES run on an Atom?

URL for downloading ?


Top
 Profile  
 
PostPosted: Sun May 20, 2018 9:57 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4050
QuickNES is available from these:


_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun May 20, 2018 11:51 am 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 308
Run it through a profiler. That's the most useful thing you could do right now.


Top
 Profile  
 
PostPosted: Sun May 20, 2018 1:05 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7211
Location: Seattle
Zepper wrote:
Removing the -funroll-loops makes the FPS to be... 274~280 (much slower).
On Atom, no difference... except the dropping effect in framerate again.
You're not going to get a single correct set of optimization flags for all possible architectures. Things that worked well on (e.g.) the pentium3 worked disastrously on the pentium4. (And things that worked well on the pentium 4 were ... passable but suboptimal on the pentium3)

Atom is a different enough ISA that you may well want to make a separate build for it.

It kinda looks like you might be able to get a free-as-in-beer copy of ICC from Intel for the cost of giving them your contact information (and needing to re-get it every three months)


Top
 Profile  
 
PostPosted: Sun May 20, 2018 2:36 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3117
Location: Brazil
pubby wrote:
Run it through a profiler. That's the most useful thing you could do right now.

What profiler do you suggest for it? (free)


Top
 Profile  
 
PostPosted: Sun May 20, 2018 4:11 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4050
Microsoft Visual Studio 2017 has a very nice profiler.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun May 20, 2018 4:50 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3117
Location: Brazil
I'm not familiar with... a profiler. :oops:
I got one named GlowCode and I can launch the emulator, but I couldn't find a way to link the EXE with the source code, sort of. All I did is compiling with -gstabs and debug it with GDB (usually only if my program's crashing).

My setup is gcc (MinGW.org GCC-6.3.0-1) 6.3.0 with Orwell's Dev-Cpp.


Top
 Profile  
 
PostPosted: Sun May 20, 2018 5:10 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4050
Got a nightly I could try? (preferably without symbols stripped)
Maybe also a suggested test case game...

Finally, use `cv2pdb` to generate PDB files out of the DWARF debug symbols. Debuggers and profilers prefer to see those files, then they can name the functions that are slow.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: 8bitMicroGuy and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group