I think you are maybe right. For the tests I always do the same
calcul. I suppose the compiler deletes many of them. But he doesn't do
that when code is in a function.
Unfortunately I think this DSP is too slow for my application. I
thought to find what took time in calculs.
Thanks for your answers.
Max
Reply by Stephan M. Bernsee●May 28, 20042004-05-28
Tim Wescott <tim@wescottnospamdesign.com> wrote:
> Stephan M. Bernsee wrote:
>
> > Tim Wescott <tim@wescottnospamdesign.com> wrote:
> >
> >>... Code Composter...
> >
> >
> > I like that one. Do you do a lot of gardening, Tim?
> >
> > :-)
> >
> > --smb
>
> I was wondering how long it would take someone to notice -- I've been
> calling it that on this list for a couple of months.
Most people don't notice spelling errors at all. Yuo can canhge the
oredr of lettres in a wrod to a graet exntet bfeore it bcoeems
unraedblae. As long as you leave the first and last as they are, that
is...
I generally skip threads that deal with hardware-specific questions.
Don't know what made me read this one... but usually, if I open up a
book or any paper I would immediately spot a spelling error (even if
it's just one in the whole thing you can be sure I'll see it within
the first five minutes without looking for it).
And yes, I also garden a lot. And it's the same there: if there's one
four-leaved clover you can be sure I'll find it, again, without
actually searching for it :-) That's my particular piece of luck I
guess... not that it would be very useful except for driving all
graphics and text people crazy...
> And yes, I do
> garden. The project that motivated me to invent the term was too busy,
> but some day I want to hack into the Code Composer executable so I can
> insert the 't' in the splash screen (with nice bright red edit marks, of
> course).
Can't you just patch the bitmap file? I don't know Code Composer, but
usually, the splash screen is a plain bitmapped graphics.
> Unfortunately that would not only demonstrate a dangerously high level
> of competence with Windows programming, which is something I try hard to
> avoid but it would also require that I _develop_ a higher level of
> Windows programming competence, which is something I avoid harder yet.
Same here... :-)
--smb
Reply by Tim Wescott●May 27, 20042004-05-27
Max wrote:
> Thanks for your answer.
> "return parameters" meant all this cases :
> - a parameter which is returned with the "return" keyword.
> - a parameter returned by argument out in function.
> The result is the same when I use each case.
> Excuse me, I didn't precise that.
>
> I pass parameter by pointer or by reference (in C++) and the parameter
> is a structure (composed by 4 doubles) or an object (in C++).
> First I programed in C++, so I tryed in C but the performances are the
> same.
> There is no difference in Debug mode but in Release mode.
>
> Program execution is too long for my application so I search what
> takes time. And I call many times this function.
>
> Below I give you an exemple of my program.
>
> Thanks a lot
>
> Max
>
> Program (in C++):
>
> typedef struct{
> double w;
> double x;
> double y;
> double z;
> }quat;
>
> void multiplication(quat& q,quat& q1, quat& q2)
> {
> q.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z;
> q.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y;
> q.y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x;
> q.z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w;
> }
>
> int main()
> {
> quat q1, q2, q;
> q1 = ini(1.25,0.36,2.56,8.9);
> q2 = ini(4.25,2.63,5.36,7.2);
> q = ini(0,0,0,0);
> while(1)
> {
> // First possibility:
> multiplication(q,q1,q2);
>
> // Second possibility; directly in code:
> q.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z *
> q2.z;
> q.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y;
> q.y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z *
> q2.x;
> q.z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z *
> q2.w;
>
> [...]
> }
> }
>
>
>
>
>
> Tim Wescott <tim@wescottnospamdesign.com> wrote in message news:<10b9n40dhhhr6a@corp.supernews.com>...
>
>>What are you returning that's making it 1000 times slower? My
>>experience with Code Composter doesn't indicate that it is nearly that bad.
>>
>>Are you benchmarking this with a routine that does nothing? If so Code
>>Composter may be optimizing your in-line stuff away entirely -- this
>>would certainly account for a 1000x speed difference, and Code Composter
>>will do that even when you tell it to turn optimizations off. Generally
>>Code Composter is very good at removing dead code but only if you don't
>>call a function.
>>
>>In C you mean "which returns a parameter" -- yes?
>>
>>If you are returning a structure the function return would be doing a
>>memory copy, which can take a lot of time. If this is what you are
>>doing then you probably want to pass the structure pointer and operate
>>on it directly within the function.
>>
>>You should try compiling to assembly language, then pick through the
>>output and figure out what it's doing to your code.
This shouldn't have a significant difference in execution speed, unless
the optimizer is getting ahold of it.
_Are_ you just benchmarking at this point, or are you actually doing
something with q? If you don't do anything with q then the optimizer
will see that it's value is never used and it will snip out the code.
You need to go look.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply by Max●May 27, 20042004-05-27
Thanks for your answer.
"return parameters" meant all this cases :
- a parameter which is returned with the "return" keyword.
- a parameter returned by argument out in function.
The result is the same when I use each case.
Excuse me, I didn't precise that.
I pass parameter by pointer or by reference (in C++) and the parameter
is a structure (composed by 4 doubles) or an object (in C++).
First I programed in C++, so I tryed in C but the performances are the
same.
There is no difference in Debug mode but in Release mode.
Program execution is too long for my application so I search what
takes time. And I call many times this function.
Below I give you an exemple of my program.
Thanks a lot
Max
Program (in C++):
typedef struct{
double w;
double x;
double y;
double z;
}quat;
void multiplication(quat& q,quat& q1, quat& q2)
{
q.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z;
q.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y;
q.y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x;
q.z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w;
}
int main()
{
quat q1, q2, q;
q1 = ini(1.25,0.36,2.56,8.9);
q2 = ini(4.25,2.63,5.36,7.2);
q = ini(0,0,0,0);
while(1)
{
// First possibility:
multiplication(q,q1,q2);
// Second possibility; directly in code:
q.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z *
q2.z;
q.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y;
q.y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z *
q2.x;
q.z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z *
q2.w;
[...]
}
}
Tim Wescott <tim@wescottnospamdesign.com> wrote in message news:<10b9n40dhhhr6a@corp.supernews.com>...
>
> What are you returning that's making it 1000 times slower? My
> experience with Code Composter doesn't indicate that it is nearly that bad.
>
> Are you benchmarking this with a routine that does nothing? If so Code
> Composter may be optimizing your in-line stuff away entirely -- this
> would certainly account for a 1000x speed difference, and Code Composter
> will do that even when you tell it to turn optimizations off. Generally
> Code Composter is very good at removing dead code but only if you don't
> call a function.
>
> In C you mean "which returns a parameter" -- yes?
>
> If you are returning a structure the function return would be doing a
> memory copy, which can take a lot of time. If this is what you are
> doing then you probably want to pass the structure pointer and operate
> on it directly within the function.
>
> You should try compiling to assembly language, then pick through the
> output and figure out what it's doing to your code.
Reply by Tim Wescott●May 27, 20042004-05-27
Stephan M. Bernsee wrote:
> Tim Wescott <tim@wescottnospamdesign.com> wrote:
>
>>... Code Composter...
>
>
> I like that one. Do you do a lot of gardening, Tim?
>
> :-)
>
> --smb
I was wondering how long it would take someone to notice -- I've been
calling it that on this list for a couple of months. And yes, I do
garden. The project that motivated me to invent the term was too busy,
but some day I want to hack into the Code Composer executable so I can
insert the 't' in the splash screen (with nice bright red edit marks, of
course).
Unfortunately that would not only demonstrate a dangerously high level
of competence with Windows programming, which is something I try hard to
avoid but it would also require that I _develop_ a higher level of
Windows programming competence, which is something I avoid harder yet.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply by Stephan M. Bernsee●May 27, 20042004-05-27
Tim Wescott <tim@wescottnospamdesign.com> wrote:
>
> ... Code Composter...
I like that one. Do you do a lot of gardening, Tim?
:-)
--smb
Reply by Tim Wescott●May 26, 20042004-05-26
(news) wrote:
> Hi everybody,
> I work on DSP C2000 and I don't understand:
> In release mode, a call to a function which returns parameters takes
> considerably more time than if I put direcly the same code in the main
> program.
> The difference is approximately 1000 times !
> I think the problem is when the function returns the parameters.
> I program in C and I use the default linker file in code composer studio.
> I must execute my program in less time !
> Thanks
> Max
>
>
What are you returning that's making it 1000 times slower? My
experience with Code Composter doesn't indicate that it is nearly that bad.
Are you benchmarking this with a routine that does nothing? If so Code
Composter may be optimizing your in-line stuff away entirely -- this
would certainly account for a 1000x speed difference, and Code Composter
will do that even when you tell it to turn optimizations off. Generally
Code Composter is very good at removing dead code but only if you don't
call a function.
In C you mean "which returns a parameter" -- yes?
If you are returning a structure the function return would be doing a
memory copy, which can take a lot of time. If this is what you are
doing then you probably want to pass the structure pointer and operate
on it directly within the function.
You should try compiling to assembly language, then pick through the
output and figure out what it's doing to your code.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply by (news)●May 26, 20042004-05-26
Hi everybody,
I work on DSP C2000 and I don't understand:
In release mode, a call to a function which returns parameters takes
considerably more time than if I put direcly the same code in the main
program.
The difference is approximately 1000 times !
I think the problem is when the function returns the parameters.
I program in C and I use the default linker file in code composer studio.
I must execute my program in less time !
Thanks
Max