public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to generate code-loops
@ 2006-09-30 13:39 David Livshin
  2006-09-30 13:55 ` Brian Budge
  0 siblings, 1 reply; 12+ messages in thread
From: David Livshin @ 2006-09-30 13:39 UTC (permalink / raw)
  To: gcc-help


Hi,

Is there a way ( command line option ) to instruct the compiler to 
generate code-loops ( when possible ):

Label:
    <code>
    conditional jump to 'Label'


Compiling

for ( k=0 ; k<n ; k++ )
{
    x[k] = y[k+1] - y[k];
}


with the command line options

" -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math 
-march=pentium4 -mfpmath=sse -msse2 -mmmx"

produces

.L1064:
    movsd as1+32032(,%edx,8), %xmm1
    subsd as1+32024(,%edx,8), %xmm1
    movsd %xmm1, as1+24016(,%edx,8)
    cmpl %ecx, %edx
    je .L1010
.L1012:
    leal 1(%edx), %esi
    movsd as1+32032(,%esi,8), %xmm0
    subsd as1+32024(,%esi,8), %xmm0
    movsd %xmm0, as1+24016(,%esi,8)
    leal 2(%edx), %ebx
    movsd as1+32032(,%ebx,8), %xmm7
    subsd as1+32024(,%ebx,8), %xmm7
    movsd %xmm7, as1+24016(,%ebx,8)
    leal 3(%edx), %eax
    movsd as1+32032(,%eax,8), %xmm6
    subsd as1+32024(,%eax,8), %xmm6
    movsd %xmm6, as1+24016(,%eax,8)
    leal 4(%edx), %esi
    movsd as1+32032(,%esi,8), %xmm5
    subsd as1+32024(,%esi,8), %xmm5
    movsd %xmm5, as1+24016(,%esi,8)
    leal 5(%edx), %ebx
    movsd as1+32032(,%ebx,8), %xmm4
    subsd as1+32024(,%ebx,8), %xmm4
    movsd %xmm4, as1+24016(,%ebx,8)
    leal 6(%edx), %eax
    movsd as1+32032(,%eax,8), %xmm3
    subsd as1+32024(,%eax,8), %xmm3
    movsd %xmm3, as1+24016(,%eax,8)
    leal 7(%edx), %esi
    movsd as1+32032(,%esi,8), %xmm2
    subsd as1+32024(,%esi,8), %xmm2
    movsd %xmm2, as1+24016(,%esi,8)
    addl $8, %edx
    jmp .L1064
.L1010:

which is not a loop; it is difficult to process ( and also runs slower 
then when the code is a loop ).

Thank you in advance,

David

-- 
David Livshin
david.livshin@dalsoft.com

http://www.dalsoft.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to generate code-loops
  2006-09-30 13:39 how to generate code-loops David Livshin
@ 2006-09-30 13:55 ` Brian Budge
  2006-09-30 18:38   ` David Livshin
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Budge @ 2006-09-30 13:55 UTC (permalink / raw)
  To: David Livshin; +Cc: gcc-help

Hi David -

a)  It looks like a loop to me.
b)  You instructed the compiler to unroll all loops, which is
apparently what it did.

Maybe I'm confused about what you are asking?

  Brian

On 9/30/06, David Livshin <david.livshin@dalsoft.com> wrote:
>
> Hi,
>
> Is there a way ( command line option ) to instruct the compiler to
> generate code-loops ( when possible ):
>
> Label:
>     <code>
>     conditional jump to 'Label'
>
>
> Compiling
>
> for ( k=0 ; k<n ; k++ )
> {
>     x[k] = y[k+1] - y[k];
> }
>
>
> with the command line options
>
> " -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math
> -march=pentium4 -mfpmath=sse -msse2 -mmmx"
>
> produces
>
> .L1064:
>     movsd as1+32032(,%edx,8), %xmm1
>     subsd as1+32024(,%edx,8), %xmm1
>     movsd %xmm1, as1+24016(,%edx,8)
>     cmpl %ecx, %edx
>     je .L1010
> .L1012:
>     leal 1(%edx), %esi
>     movsd as1+32032(,%esi,8), %xmm0
>     subsd as1+32024(,%esi,8), %xmm0
>     movsd %xmm0, as1+24016(,%esi,8)
>     leal 2(%edx), %ebx
>     movsd as1+32032(,%ebx,8), %xmm7
>     subsd as1+32024(,%ebx,8), %xmm7
>     movsd %xmm7, as1+24016(,%ebx,8)
>     leal 3(%edx), %eax
>     movsd as1+32032(,%eax,8), %xmm6
>     subsd as1+32024(,%eax,8), %xmm6
>     movsd %xmm6, as1+24016(,%eax,8)
>     leal 4(%edx), %esi
>     movsd as1+32032(,%esi,8), %xmm5
>     subsd as1+32024(,%esi,8), %xmm5
>     movsd %xmm5, as1+24016(,%esi,8)
>     leal 5(%edx), %ebx
>     movsd as1+32032(,%ebx,8), %xmm4
>     subsd as1+32024(,%ebx,8), %xmm4
>     movsd %xmm4, as1+24016(,%ebx,8)
>     leal 6(%edx), %eax
>     movsd as1+32032(,%eax,8), %xmm3
>     subsd as1+32024(,%eax,8), %xmm3
>     movsd %xmm3, as1+24016(,%eax,8)
>     leal 7(%edx), %esi
>     movsd as1+32032(,%esi,8), %xmm2
>     subsd as1+32024(,%esi,8), %xmm2
>     movsd %xmm2, as1+24016(,%esi,8)
>     addl $8, %edx
>     jmp .L1064
> .L1010:
>
> which is not a loop; it is difficult to process ( and also runs slower
> then when the code is a loop ).
>
> Thank you in advance,
>
> David
>
> --
> David Livshin
> david.livshin@dalsoft.com
>
> http://www.dalsoft.com
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to generate code-loops
  2006-09-30 13:55 ` Brian Budge
@ 2006-09-30 18:38   ` David Livshin
  2006-09-30 19:50     ` Artūras Moskvinas
  2006-10-01  0:51     ` how to generate code-loops Tim Prince
  0 siblings, 2 replies; 12+ messages in thread
From: David Livshin @ 2006-09-30 18:38 UTC (permalink / raw)
  To: Brian Budge; +Cc: gcc-help

Brian Budge wrote:
> Hi David -
>
> a)  It looks like a loop to me.
No it is not a loop, at least not a loop I would like to have. Perhaps I 
had to mention this in my message, but the boy of the "loop" should be a 
basic block ( no jump to/from it ) - the code generated is not a such.
> b)  You instructed the compiler to unroll all loops, which is
> apparently what it did.
>
> Maybe I'm confused about what you are asking?
>
>  Brian
>
> On 9/30/06, David Livshin <david.livshin@dalsoft.com> wrote:
>>
>> Hi,
>>
>> Is there a way ( command line option ) to instruct the compiler to
>> generate code-loops ( when possible ):
>>
>> Label:
>>     <code>
>>     conditional jump to 'Label'
>>
>>
>> Compiling
>>
>> for ( k=0 ; k<n ; k++ )
>> {
>>     x[k] = y[k+1] - y[k];
>> }
>>
>>
>> with the command line options
>>
>> " -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math
>> -march=pentium4 -mfpmath=sse -msse2 -mmmx"
>>
>> produces
>>
>> .L1064:
>>     movsd as1+32032(,%edx,8), %xmm1
>>     subsd as1+32024(,%edx,8), %xmm1
>>     movsd %xmm1, as1+24016(,%edx,8)
>>     cmpl %ecx, %edx
>>     je .L1010
>> .L1012:
>>     leal 1(%edx), %esi
>>     movsd as1+32032(,%esi,8), %xmm0
>>     subsd as1+32024(,%esi,8), %xmm0
>>     movsd %xmm0, as1+24016(,%esi,8)
>>     leal 2(%edx), %ebx
>>     movsd as1+32032(,%ebx,8), %xmm7
>>     subsd as1+32024(,%ebx,8), %xmm7
>>     movsd %xmm7, as1+24016(,%ebx,8)
>>     leal 3(%edx), %eax
>>     movsd as1+32032(,%eax,8), %xmm6
>>     subsd as1+32024(,%eax,8), %xmm6
>>     movsd %xmm6, as1+24016(,%eax,8)
>>     leal 4(%edx), %esi
>>     movsd as1+32032(,%esi,8), %xmm5
>>     subsd as1+32024(,%esi,8), %xmm5
>>     movsd %xmm5, as1+24016(,%esi,8)
>>     leal 5(%edx), %ebx
>>     movsd as1+32032(,%ebx,8), %xmm4
>>     subsd as1+32024(,%ebx,8), %xmm4
>>     movsd %xmm4, as1+24016(,%ebx,8)
>>     leal 6(%edx), %eax
>>     movsd as1+32032(,%eax,8), %xmm3
>>     subsd as1+32024(,%eax,8), %xmm3
>>     movsd %xmm3, as1+24016(,%eax,8)
>>     leal 7(%edx), %esi
>>     movsd as1+32032(,%esi,8), %xmm2
>>     subsd as1+32024(,%esi,8), %xmm2
>>     movsd %xmm2, as1+24016(,%esi,8)
>>     addl $8, %edx
>>     jmp .L1064
>> .L1010:
>>
>> which is not a loop; it is difficult to process ( and also runs slower
>> then when the code is a loop ).
>>
>> Thank you in advance,
>>
>> David
>>
>> -- 
>> David Livshin
>> david.livshin@dalsoft.com
>>
>> http://www.dalsoft.com
>>
>>
>
>
>


-- 
David Livshin
david.livshin@dalsoft.com
tel:    +972-8-684-6104
mobile: +972-54-729-0998

http://www.dalsoft.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to generate code-loops
  2006-09-30 18:38   ` David Livshin
@ 2006-09-30 19:50     ` Artūras Moskvinas
  2006-09-30 20:04       ` David Livshin
  2006-10-01  0:51     ` how to generate code-loops Tim Prince
  1 sibling, 1 reply; 12+ messages in thread
From: Artūras Moskvinas @ 2006-09-30 19:50 UTC (permalink / raw)
  To: David Livshin; +Cc: gcc-help


>> a)  It looks like a loop to me.
> No it is not a loop, at least not a loop I would like to have. Perhaps I
> had to mention this in my message, but the boy of the "loop" should be a
> basic block ( no jump to/from it ) - the code generated is not a such.
for loop before doing any instructions must check conditions and then
perform statements inside it. So your code is not right (there is no
check for conditions before starting the loop)(though sometimes it is
correct).

Label:
    <code>
    conditional jump to 'Label'

You might consider using:
do
{
code
} while (condition not satisfied)


>> b)  You instructed the compiler to unroll all loops, which is
>> apparently what it did.
>Maybe I'm confused about what you are asking?

You forced gcc compiler to unroll all loops in your code even if it
makes performance lower. "-funroll-all-loops"
From gcc manual:
"-funroll-all-loops" Unroll all loops, even if their number of
iterations is uncertain when the loop is entered. This usually makes
programs run more slowly.
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Optimize-Options.html#Optimize-Options

Try switching that setting of.

Arturas M.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to generate code-loops
  2006-09-30 19:50     ` Artūras Moskvinas
@ 2006-09-30 20:04       ` David Livshin
  2006-09-30 20:28         ` regarding privilege levels of pentium 4 ranjith kumar
  0 siblings, 1 reply; 12+ messages in thread
From: David Livshin @ 2006-09-30 20:04 UTC (permalink / raw)
  To: Artūras Moskvinas; +Cc: gcc-help

Artūras Moskvinas wrote:
>>> a)  It looks like a loop to me.
>>>       
>> No it is not a loop, at least not a loop I would like to have. Perhaps I
>> had to mention this in my message, but the boy of the "loop" should be a
>> basic block ( no jump to/from it ) - the code generated is not a such.
>>     
> for loop before doing any instructions must check conditions and then
> perform statements inside it. So your code is not right (there is no
> check for conditions before starting the loop)(though sometimes it is
> correct).
>
>   
The code in my posting is only small portion of the code generated; just 
to illustrate the problem.
> Label:
>     <code>
>     conditional jump to 'Label'
>
> You might consider using:
> do
> {
> code
> } while (condition not satisfied)
>
>
>   
>>> b)  You instructed the compiler to unroll all loops, which is
>>> apparently what it did.
>>>       
>> Maybe I'm confused about what you are asking?
>>     
>
> You forced gcc compiler to unroll all loops in your code even if it
> makes performance lower. "-funroll-all-loops"
> >From gcc manual:
> "-funroll-all-loops" Unroll all loops, even if their number of
> iterations is uncertain when the loop is entered. This usually makes
> programs run more slowly.
> http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Optimize-Options.html#Optimize-Options
>
> Try switching that setting of.
>
> Arturas M
>   
I would like to have unrolled "real loop".

-- 
David Livshin
david.livshin@dalsoft.com

http://www.dalsoft.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* regarding privilege levels of pentium 4
  2006-09-30 20:04       ` David Livshin
@ 2006-09-30 20:28         ` ranjith kumar
  2006-09-30 20:32           ` Sven Eschenberg
  0 siblings, 1 reply; 12+ messages in thread
From: ranjith kumar @ 2006-09-30 20:28 UTC (permalink / raw)
  To: gcc-help

 Hi,


  How can we tell at what privilege level a program is
running.
  Is it possible to run a program at privilege level
'zero' on a processor
like Pentium 4.

   Actually I want to disable interrupts while running
my program. This
can be done by "cli" instruction. Using "asm inline"
feature of GCC, we
can include assembly instructions  in programs of C,
C++...etc.

    But the problem is that "cli" instruction can be
executed only at
privilege level "zero".

Can anyone  help me.




Thanking you.


	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: regarding privilege levels of pentium 4
  2006-09-30 20:28         ` regarding privilege levels of pentium 4 ranjith kumar
@ 2006-09-30 20:32           ` Sven Eschenberg
  2006-09-30 22:09             ` ranjith kumar
  0 siblings, 1 reply; 12+ messages in thread
From: Sven Eschenberg @ 2006-09-30 20:32 UTC (permalink / raw)
  To: ranjith kumar; +Cc: gcc-help

Hi Ranjith,

I might be wrong on this, but I think the question is, if the Operating 
System permits it or under which circumstances. It's neither a question 
of what gcc or the hardware does, but what the OS you are using allows 
to which processes.
It might be, you need 'just' root priviledges, but I'd rather assume, 
that you need to be within the kernel's context, since a cli command 
endangers system stability (it could lead to a lock up) ...

Regards

-Sven

ranjith kumar wrote:
>  Hi,
>
>
>   How can we tell at what privilege level a program is
> running.
>   Is it possible to run a program at privilege level
> 'zero' on a processor
> like Pentium 4.
>
>    Actually I want to disable interrupts while running
> my program. This
> can be done by "cli" instruction. Using "asm inline"
> feature of GCC, we
> can include assembly instructions  in programs of C,
> C++...etc.
>
>     But the problem is that "cli" instruction can be
> executed only at
> privilege level "zero".
>
> Can anyone  help me.
>
>
>
>
> Thanking you.
>
>
> 	
> 	
> 		
> ___________________________________________________________ 
> All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
> http://uk.docs.yahoo.com/nowyoucan.html
>   

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: regarding privilege levels of pentium 4
  2006-09-30 20:32           ` Sven Eschenberg
@ 2006-09-30 22:09             ` ranjith kumar
  2006-09-30 22:28               ` Artūras Moskvinas
  2006-09-30 22:32               ` Sven Eschenberg
  0 siblings, 2 replies; 12+ messages in thread
From: ranjith kumar @ 2006-09-30 22:09 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 2405 bytes --]

--- Sven Eschenberg <eschenb@cs.uni-frankfurt.de>
wrote:

> Hi Ranjith,
> 
> I might be wrong on this, but I think the question
> is, if the Operating 
> System permits it or under which circumstances. It's
> neither a question 
> of what gcc or the hardware does, but what the OS
> you are using allows 
> to which processes.
Thanks. I am sending more details of my problem.

The OS I am using       : Linux.
The language in which the program is written : C(I am
attaching the program)
The compiler : gcc 3.2.3
Processor   : Pentium 4
I know password for root login. I logged in as root
and compiled my program. When compiled no errors were
reported. But when I run the program it simply shows
"Segmentation fault". 

My goal is to measure performance parameters (for
example the number of branch instructions that were
mispredicted), on Pentium 4, using "RDMSR" and "WRMSR"
instructions. Also I want to disble interrupts while
running my program.
The problem is that those instructions can be run only
at privilege level zero.

Can you help me.
Thanks.


> It might be, you need 'just' root priviledges, but
> I'd rather assume, 
> that you need to be within the kernel's context,
> since a cli command 
> endangers system stability (it could lead to a lock
> up) ...
> 
> Regards
> 
> -Sven
> 
> ranjith kumar wrote:
> >  Hi,
> >
> >
> >   How can we tell at what privilege level a
> program is
> > running.
> >   Is it possible to run a program at privilege
> level
> > 'zero' on a processor
> > like Pentium 4.
> >
> >    Actually I want to disable interrupts while
> running
> > my program. This
> > can be done by "cli" instruction. Using "asm
> inline"
> > feature of GCC, we
> > can include assembly instructions  in programs of
> C,
> > C++...etc.
> >
> >     But the problem is that "cli" instruction can
> be
> > executed only at
> > privilege level "zero".
> >
> > Can anyone  help me.
> >
> >
> >
> >
> > Thanking you.
> >
> >
> > 	
> > 	
> > 		
> >
>
___________________________________________________________
> 
> > All new Yahoo! Mail "The new Interface is stunning
> in its simplicity and ease of use." - PC Magazine 
> > http://uk.docs.yahoo.com/nowyoucan.html
> >   
> 
> 


	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3988338151-test.c --]
[-- Type: text/x-c; name="test.c", Size: 229 bytes --]

#include<stdio.h>
int main(void)
{
unsigned int p1;
asm volatile ("cli;");


asm volatile (" movl $0x300, %%ecx;"
"RDPMC;"
"movl %%eax, %0;"
:"=r"(p1)
:
:"%ecx","%edx","%eax");

printf("\n %u\n",p1);


asm volatile ("sti;");

}


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: regarding privilege levels of pentium 4
  2006-09-30 22:09             ` ranjith kumar
@ 2006-09-30 22:28               ` Artūras Moskvinas
  2006-10-01  1:03                 ` Tim Prince
  2006-09-30 22:32               ` Sven Eschenberg
  1 sibling, 1 reply; 12+ messages in thread
From: Artūras Moskvinas @ 2006-09-30 22:28 UTC (permalink / raw)
  To: ranjith kumar; +Cc: gcc-help


> --- Sven Eschenberg <eschenb@cs.uni-frankfurt.de>
> wrote:
> 
>> Hi Ranjith,
>>
>> I might be wrong on this, but I think the question
>> is, if the Operating 
>> System permits it or under which circumstances. It's
>> neither a question 
>> of what gcc or the hardware does, but what the OS
>> you are using allows 
>> to which processes.
> Thanks. I am sending more details of my problem.
> 
> The OS I am using       : Linux.
> The language in which the program is written : C(I am
> attaching the program)
> The compiler : gcc 3.2.3
> Processor   : Pentium 4
> I know password for root login. I logged in as root
> and compiled my program. When compiled no errors were
> reported. But when I run the program it simply shows
> "Segmentation fault". 
> 
> My goal is to measure performance parameters (for
> example the number of branch instructions that were
> mispredicted), on Pentium 4, using "RDMSR" and "WRMSR"
> instructions. Also I want to disble interrupts while
> running my program.
> The problem is that those instructions can be run only
> at privilege level zero.
You should consider using Kernel mode linux (kernel recompilation
needed) or write kernel module:
kernel mode linux:
http://web.yl.is.s.u-tokyo.ac.jp/~tosh/kml/


Arturas M.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: regarding privilege levels of pentium 4
  2006-09-30 22:09             ` ranjith kumar
  2006-09-30 22:28               ` Artūras Moskvinas
@ 2006-09-30 22:32               ` Sven Eschenberg
  1 sibling, 0 replies; 12+ messages in thread
From: Sven Eschenberg @ 2006-09-30 22:32 UTC (permalink / raw)
  To: gcc-help

Again, this is not a gcc question, but a linxu question. The right place 
might be kerneltrap etc., but for now, try digging google for CPU rings 
/ CPU ring levels ...

For x86, ring level 0 is the only ring allowing cli/sti among some other 
calls. In Linux those are exclusive for KERNEL SPACE, thus, no user 
program can perform these instructions, it will trigger a segmentation 
fault, since it tries to cross the limits of the ring it is run in (I 
assume ring 3, I am not sure though) ....

Regards

-Sven

P.S.: You certainly will have to write a kernel driver/module to use 
those calls - I assume that's why there is a kernel profiling 
infrastructure (Read the kernel's documentation) ...

P.P.S.: Further Reading I recommend, aside from the kernel docs: CPU 
Manual on Protected Mode and Rings, general Books on Operating systems ...

ranjith kumar wrote:
> --- Sven Eschenberg <eschenb@cs.uni-frankfurt.de>
> wrote:
>
>   
>> Hi Ranjith,
>>
>> I might be wrong on this, but I think the question
>> is, if the Operating 
>> System permits it or under which circumstances. It's
>> neither a question 
>> of what gcc or the hardware does, but what the OS
>> you are using allows 
>> to which processes.
>>     
> Thanks. I am sending more details of my problem.
>
> The OS I am using       : Linux.
> The language in which the program is written : C(I am
> attaching the program)
> The compiler : gcc 3.2.3
> Processor   : Pentium 4
> I know password for root login. I logged in as root
> and compiled my program. When compiled no errors were
> reported. But when I run the program it simply shows
> "Segmentation fault". 
>
> My goal is to measure performance parameters (for
> example the number of branch instructions that were
> mispredicted), on Pentium 4, using "RDMSR" and "WRMSR"
> instructions. Also I want to disble interrupts while
> running my program.
> The problem is that those instructions can be run only
> at privilege level zero.
>
> Can you help me.
> Thanks.
>
>
>   
>> It might be, you need 'just' root priviledges, but
>> I'd rather assume, 
>> that you need to be within the kernel's context,
>> since a cli command 
>> endangers system stability (it could lead to a lock
>> up) ...
>>
>> Regards
>>
>> -Sven
>>
>> ranjith kumar wrote:
>>     
>>>  Hi,
>>>
>>>
>>>   How can we tell at what privilege level a
>>>       
>> program is
>>     
>>> running.
>>>   Is it possible to run a program at privilege
>>>       
>> level
>>     
>>> 'zero' on a processor
>>> like Pentium 4.
>>>
>>>    Actually I want to disable interrupts while
>>>       
>> running
>>     
>>> my program. This
>>> can be done by "cli" instruction. Using "asm
>>>       
>> inline"
>>     
>>> feature of GCC, we
>>> can include assembly instructions  in programs of
>>>       
>> C,
>>     
>>> C++...etc.
>>>
>>>     But the problem is that "cli" instruction can
>>>       
>> be
>>     
>>> executed only at
>>> privilege level "zero".
>>>
>>> Can anyone  help me.
>>>
>>>
>>>
>>>
>>> Thanking you.
>>>
>>>
>>> 	
>>> 	
>>> 		
>>>
>>>       
> ___________________________________________________________
>   
>>> All new Yahoo! Mail "The new Interface is stunning
>>>       
>> in its simplicity and ease of use." - PC Magazine 
>>     
>>> http://uk.docs.yahoo.com/nowyoucan.html
>>>   
>>>       
>>     
>
>
> 	
> 	
> 		
> ___________________________________________________________ 
> All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
> http://uk.docs.yahoo.com/nowyoucan.html
> ------------------------------------------------------------------------
>
> #include<stdio.h>
> int main(void)
> {
> unsigned int p1;
> asm volatile ("cli;");
>
>
> asm volatile (" movl $0x300, %%ecx;"
> "RDPMC;"
> "movl %%eax, %0;"
> :"=r"(p1)
> :
> :"%ecx","%edx","%eax");
>
> printf("\n %u\n",p1);
>
>
> asm volatile ("sti;");
>
> }
>
>   

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to generate code-loops
  2006-09-30 18:38   ` David Livshin
  2006-09-30 19:50     ` Artūras Moskvinas
@ 2006-10-01  0:51     ` Tim Prince
  1 sibling, 0 replies; 12+ messages in thread
From: Tim Prince @ 2006-10-01  0:51 UTC (permalink / raw)
  To: David Livshin; +Cc: Brian Budge, gcc-help

David Livshin wrote:
> Brian Budge wrote:
>> Hi David -
>>
>> a)  It looks like a loop to me.
> No it is not a loop, at least not a loop I would like to have. Perhaps I 
> had to mention this in my message, but the boy of the "loop" should be a 
> basic block ( no jump to/from it ) - the code generated is not a such.
>> b)  You instructed the compiler to unroll all loops, which is
>> apparently what it did.

When you ask gcc to unroll a loop, without vectorization, it will jump 
in at the appropriate point, rather than using a remainder loop.  If you 
are serious about wanting some other style, you could write out the 
details, including a main loop which works in dictated groups of 8 
iterations.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: regarding privilege levels of pentium 4
  2006-09-30 22:28               ` Artūras Moskvinas
@ 2006-10-01  1:03                 ` Tim Prince
  0 siblings, 0 replies; 12+ messages in thread
From: Tim Prince @ 2006-10-01  1:03 UTC (permalink / raw)
  To: Artūras Moskvinas; +Cc: ranjith kumar, gcc-help

Artūras Moskvinas wrote:
>> --- Sven Eschenberg <eschenb@cs.uni-frankfurt.de>
>> wrote:
>>

>> The OS I am using       : Linux.
>> The language in which the program is written : C(I am
>> attaching the program)
>> The compiler : gcc 3.2.3
>> Processor   : Pentium 4
>> I know password for root login. I logged in as root
>> and compiled my program. When compiled no errors were
>> reported. But when I run the program it simply shows
>> "Segmentation fault". 
>>
>> My goal is to measure performance parameters (for
>> example the number of branch instructions that were
>> mispredicted), on Pentium 4, using "RDMSR" and "WRMSR"
>> instructions. Also I want to disble interrupts while
>> running my program.
>> The problem is that those instructions can be run only
>> at privilege level zero.
> You should consider using Kernel mode linux (kernel recompilation
> needed) or write kernel module:
> kernel mode linux:
> http://web.yl.is.s.u-tokyo.ac.jp/~tosh/kml/
> 

Also, consider whether you need to re-invent the wheel, when both open 
and closed source profilers exist for this purpose.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-10-01  1:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-30 13:39 how to generate code-loops David Livshin
2006-09-30 13:55 ` Brian Budge
2006-09-30 18:38   ` David Livshin
2006-09-30 19:50     ` Artūras Moskvinas
2006-09-30 20:04       ` David Livshin
2006-09-30 20:28         ` regarding privilege levels of pentium 4 ranjith kumar
2006-09-30 20:32           ` Sven Eschenberg
2006-09-30 22:09             ` ranjith kumar
2006-09-30 22:28               ` Artūras Moskvinas
2006-10-01  1:03                 ` Tim Prince
2006-09-30 22:32               ` Sven Eschenberg
2006-10-01  0:51     ` how to generate code-loops Tim Prince

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).