You are not logged in.

Read the FAQ and Knowledge Base before posting.
We won't make a 3DS/2DS emulator.

#1 Re: Technical » Pass by Reference Vs. Pass by Value » 2010-06-29 23:01:42

lig

Well you know were all just hobbyists so I don't want to take anything too seriously, and I don't really know what I'm doing so all I can do is guess, but thanks for the info about disassemble not being used because I was wondering what it was for.

#2 Re: Technical » Pass by Reference Vs. Pass by Value » 2010-06-29 21:13:32

lig

Yeah it didn't make much sense that it would run faster because copying a pointer and an int should take the same amount of time because they're the same size. I have another idea, however, there are a lot of small functions in disassemble.cpp and arm_instructions.cpp would using the inline keyword in the function declarations help any?

#3 Technical » Pass by Reference Vs. Pass by Value » 2010-06-29 17:56:34

lig
Replies: 5

I was looking through the code for desmume and noticed that a lot of the function were pass by value. I remember learning in school years ago that if you always pass by reference instead of by value then the program will run faster. So I did an experiment today and its true that pass by reference is always faster. Heres the code I ran:

#include <iostream>
#include <time.h>
using namespace std;

void pass_by_reference(const int& a, const int& b, const int& c)
{
 
}

void pass_by_const(const int a, const int b, const int c)
{
 
}

void pass_by_value(int a, int b, int c)
{

}

int main ()
{
  time_t start,end;
  double dif;
  int a, b, c;
  //reference
  time (&start);
  for(unsigned int i = 0; i < 4294967295; i++)
    pass_by_reference(a, b, c);
  time (&end);
  dif = difftime (end,start);
  cout << "Pass by reference: " << dif << endl;
  //const
  time (&start);
  for(unsigned int i = 0; i < 4294967295; i++)
    pass_by_const(a, b, c);
  time (&end);
  dif = difftime (end,start);
  cout << "Pass by const: " << dif << endl;
  //value
  time (&start);
  for(unsigned int i = 0; i < 4294967295; i++)
    pass_by_value(a, b, c);
  time (&end);
  dif = difftime (end,start);
  cout << "Pass by value: " << dif << endl;
 
  return 0;
}

************************************************************
The output is usually 17 seconds for pass by reference, 26 for const and value, respectively.

#4 Re: Technical » Has anyone considered a Dynamic Recompiler? » 2010-05-24 00:39:50

lig

I like how when you ask a question on this forum instead of some just giving you a hint they say something negative. Its like you guys never learned any social skills, but thats okay I'll just keep talking until someone answers me. So is it in NDSSystem.cpp?

#5 Technical » Has anyone considered a Dynamic Recompiler? » 2010-05-23 21:04:36

lig
Replies: 5

I was curious about whether anyone has thought about making a dynamic recompiler for desmume.  I was thinking that there could be a hash table that could use the program counter of each instruction as the key and the translated instructions as the buckets. Seems pretty simple to do I was just wondering if someone could point me in the right direction. Is there a spot in the code where the instruction is all the way translated where it could be stored into the hash table or is it not that simple?

#6 Re: Technical » Linux num_cores command line argument » 2010-05-17 06:05:24

lig

If you take your code for frame skipping and apply it to the gtk interface instead of cli it will limit the amount of frames skipped so that it doesn't just skip frames and make games unplayable. This is the best I have seen this emulator run.

#7 Re: Technical » Linux num_cores command line argument » 2010-05-17 04:59:29

lig

Nevermind its not the perfect solution it needs some adjustments because sometimes all it does is skip frames making games unplayable.

#8 Re: Technical » Linux num_cores command line argument » 2010-05-17 04:35:11

lig

Kouteiheika I got your frame skipping code to work on the svn checkout I have and I must say bravo! Works perfectly. This IS the way things should be. If you ever read this message I just want to say thanks.

#9 Re: Technical » Linux num_cores command line argument » 2010-05-03 16:03:37

lig

It didn't compile for me I got this error:

main.cpp: In function 'void desmume_cycle(int*, int*, configured_features*)':
main.cpp:387: error: cannot convert 'short unsigned int*' to 'ctrls_event_config*' for argument '2' to 'void process_ctrls_event(SDL_Event&, ctrls_event_config*)'

#10 Re: Technical » Linux num_cores command line argument » 2010-05-03 03:22:15

lig

"Instead of" was a poor use of words. I didn't mean get rid of it or replace. I was just doing experiments and was meaning to say that benefits were slight. I have no idea about what else could be run concurrently I would not even know where to start.

#11 Re: Technical » Linux num_cores command line argument » 2010-05-02 23:59:13

lig

kouteiheika can I see that code you wrote for frame skipping with the cli frontend?

#12 Re: Technical » Linux num_cores command line argument » 2010-05-02 21:17:56

lig

Zeromus which code are you talking about the little bit I wrote to test kouteiheika's code or the one kouteiheika posted on pastebin? The code that kouteiheika wrote is just a cleaned up version (that doesn't crash) of what you get when you check out from the svn.

I'm fairly certain that only one thread is running at a time. When the first thread comes in to run taskProc it sets the lock for mutual exclusion to the work function. When the second thread comes in it gets stopped at the lock until the first thread unlocks when the work is completed and so on.

I'm not using the opengl core by the way.

Which function or set of functions initializes the 3d core? I can tell you that CommonSettings.num_cores is set to 2 at the beginning of SoftRastInit(void) before the threads fork.

Here is something else that I find interesting:
pretty much when you get down to it the function that is being executed by the threads is mainLoop(SoftRasterizerEngine* const engine) and theres a for loop in that function

for(int i = 0;i < engine->clippedPolyCounter;i++)

which is where I figure most of the work gets done. Now if you change it to:

for(int i = 0;i < engine->clippedPolyCounter / 2;i++)

to try to simulate what it might be like running 2 threads at a time. It doesn't really help performance that much. Which makes my believe that something else should be done concurrently instead of the soft rasterizer.

#13 Re: Technical » Linux num_cores command line argument » 2010-05-02 14:02:23

lig

Is the multi-threading supposed to accomplish something other than running multiple threads at a time? (like responsiveness or something). Long story short I think I figured out that your code only runs one thread at a time. I modified your code a little bit:

void Task::Impl::taskProc()

{

    for( ;; )

    {

        if( killed ) break;

        pthread_t tid = pthread_self( );

        pthread_mutex_lock( &work_mutex );

        pthread_cond_wait( &work_incoming, &work_mutex );

        printf("thread# %u has started work\n", (unsigned int) tid);
        fflush(stdout);

        param = work(param);
        printf("thread# %u has finished work\n", (unsigned int) tid);
        fflush(stdout);
       

        pending = false;

        pthread_cond_signal( &work_done );

        pthread_mutex_unlock( &work_mutex );

    }

}

/**************************
end code
**************************/

and the output is:

thread# 2912476016 has started work
thread# 2912476016 has finished work
thread# 2920868720 has started work
thread# 2920868720 has finished work
thread# 2912476016 has started work
thread# 2912476016 has finished work
thread# 2920868720 has started work
thread# 2920868720 has finished work
thread# 2920868720 has started work
thread# 2920868720 has finished work
thread# 2912476016 has started work
thread# 2912476016 has finished work

/**************************
end output
**************************/

My system monitor does claim a 10% increase in CPU usage and there is one weird spot in the output:

thread# 2920868720 has started work
thread# 2920868720 has finished work
thread# 2920868720 has started work
thread# 2920868720 has finished work

#14 Re: Technical » Linux num_cores command line argument » 2010-05-01 05:25:34

lig

I uncommented the pthreads code in utils/task.cpp and removed the line:

if(!initialized) init( );

which seems to be a win32 code fragment.

Uncommenting this code does not help in fact I think it actually hurts performance a little. I can't prove it but it seems like the threads wait at the locks and then just run one at a time when they're not waiting. I'm going to try to figure this one out but it could take a long time.

#15 Re: Technical » Linux num_cores command line argument » 2010-04-30 22:54:01

lig

It's strange that desmume doesn't complain when you type in --num_cores instead of --num-cores but I figured out today, after I read the faq again, that --num-cores=2 does cause CommonSettings.num_cores to equal 2. Most of the time it complains like if you type in --num-core or make some other mistake.

#16 Re: Technical » Linux SS2 build » 2010-04-26 07:37:39

lig

Ok so really all you have to do is add this code to configure.ac:

AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [
CFLAGS="$CFLAGS -msse -msse2"
CXXFLAGS="$CXXFLAGS -msse -msse2"
])

And then just you can just run the commands:

autogen.sh
./configure --enable-sse
make
sudo make install

to make an sse linux build.

#17 Technical » Linux SS2 build » 2010-04-26 07:00:09

lig
Replies: 2

Is matrix.h the only source code file that had sse instructions? I made a linux sse build by the way. Although I'm positive I did not do it the right way. I just kinda hacked away and then by some dumb luck it actually worked. I edited the configure.ac file to give all the makefiles the -msse and -msse2 arguments in the CXXFLAGS and then I just deleted all the preprocessor #ifdef ENABLE_SSE and #ifdef ENABLE_SSE2 and their corresponding #else statements and #endif's.

#18 Technical » Linux num_cores command line argument » 2010-04-26 04:27:39

lig
Replies: 19

For anyone who cares:

When you type in --num_cores=2 the argument gets parsed in commandline.cpp. Line 121 says:

if(_num_cores != -1) CommonSettings.num_cores = _num_cores;

Yet when SoftRast gets initialized, in rasterize.cpp, CommonSettings.num_cores == 1. Manually setting this to 2 does not, however, make desmume use 2 cores according to System Monitor.

#19 Re: Technical » made some improvements to the joysticks handling » 2010-04-25 00:15:36

lig

@DottorLeo: The joystick axises did not work for up, down, left, and right movements for me because of the 'deadzone' coding. There was a spot in the code that said something was done a certain way to remove some sensitivity which is usually called a deadzone. I added the ability to use an axis as a buttons. I added hat motion.
@zeromus: How do you do that?

#20 Technical » made some improvements to the joysticks handling » 2010-04-24 22:14:57

lig
Replies: 4

This emulator has a come a long way since I seen it last. I've been using no$gba but it's buggy sound bothers me. So I saw how this emulator looks and sounds and the fact that its open source and was impressed. So then I wanted to play mario 64 ds on it but the joystick function didn't work that well, so I've been working on the joystick code to see if I could help. I've made some improvements that work better for me, but I'm not sure if they would work for everyone. If there is someone who knows something about the code and would like to test my joystick handling out let me know. I'll be watching this forum.

Board footer

Powered by FluxBB