* assembly programming on alphas
@ 1998-12-10 5:00 Bram
1998-12-12 5:00 ` Joachim Wesner
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Bram @ 1998-12-10 5:00 UTC (permalink / raw)
Hello,
I've been reading DEC's Assembly Language Programmer's Guide.
But I have a couple of questions.
How can I have egcs generate more verbose assembly output?
The samples in the guide show the C-source as comments in
the assembly file.
The output from egcc -S does not give these.
Also, isn't there a more convenient method for memory
to memory copying? It seems that the only way to move
data from memory to memory, is by loading, and then
storing registers.
On Intel, I use movsb/movsw/movsl a lot, but there
does not seem to be an alpha-equivalent.
I am curious how memcpy is implemented on the alpha.
What is the fastest way to copy, say, 32 bytes or more
from one location to another? And what if the data
is not alligned?
thanks in advance,
Bram Stolk
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: assembly programming on alphas 1998-12-10 5:00 assembly programming on alphas Bram @ 1998-12-12 5:00 ` Joachim Wesner 1998-12-12 5:00 ` Clifford T. Matthews 1998-12-19 5:00 ` Toon Moene 1998-12-12 5:00 ` Bradley DeJong ` (2 subsequent siblings) 3 siblings, 2 replies; 13+ messages in thread From: Joachim Wesner @ 1998-12-12 5:00 UTC (permalink / raw) Bram wrote: > > I've been reading DEC's Assembly Language Programmer's Guide. > But I have a couple of questions. > > How can I have egcs generate more verbose assembly output? > The samples in the guide show the C-source as comments in > the assembly file. > The output from egcc -S does not give these. To my knowledge, there is no way to have the assembly output mixed with the C-source on gcc/egcs. I would love to hear about any possibility. > Also, isn't there a more convenient method for memory > to memory copying? It seems that the only way to move > data from memory to memory, is by loading, and then > storing registers. > On Intel, I use movsb/movsw/movsl a lot, but there > does not seem to be an alpha-equivalent. NOPE, there is none. This is RISC philosophy, resp, the "load & store" architecture. Basically, the idea is to use the multiple issue possiblities, branch prediction etc. to emulate the x86 instructions at the same speed. Also, x86 mov** does no real memory to memory copy (some DMA controllers allow this if your memory subsystem can handle it), but instead feed it in parts through a temporary processor register. > I am curious how memcpy is implemented on the alpha. > What is the fastest way to copy, say, 32 bytes or more > from one location to another? And what if the data > is not alligned? If it's not aligned, you will get a slowdown due to the need to copy in smaller bunches. HOWEVER, the very same happens on x86, even if it is all handled in hardware/microcode. Alpha philosphy again is to avoid (if possible) any "non naturally" aligned data like "the plague". Actually, I do not know the source for memcpy on Linux/AXP. You could assemble/compile a simple program that uses it and look inside with gdb to get an idea how it is implemented. Joachim ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Joachim Wesner @ 1998-12-12 5:00 ` Clifford T. Matthews 1998-12-12 5:00 ` Joachim Wesner 1998-12-19 5:00 ` Toon Moene 1 sibling, 1 reply; 13+ messages in thread From: Clifford T. Matthews @ 1998-12-12 5:00 UTC (permalink / raw) >>>>> "Joachim" == Joachim Wesner <joachim.wesner@frankfurt.netsurf.de> writes: Joachim> Bram wrote: >> I've been reading DEC's Assembly Language Programmer's Guide. >> But I have a couple of questions. >> >> How can I have egcs generate more verbose assembly output? The >> samples in the guide show the C-source as comments in the assembly >> file. The output from egcc -S does not give these. Joachim> To my knowledge, there is no way to have the assembly output Joachim> mixed with the C-source on gcc/egcs. I would love to hear Joachim> about any possibility. alpha.ardi.com 1.5 objdump --disassemble --source foo.o foo.o: file format elf64-alpha Disassembly of section .text: 0000000000000000 <main>: { 0: f0 ff de 23 lda sp,-16(sp) 4: 00 00 5e b7 stq ra,0(sp) 8: 08 00 fe b5 stq fp,8(sp) c: 0f 04 de 47 mov sp,fp return 0; 10: 00 04 ff 47 clr v0 14: 00 00 e0 c3 br 18 <main+0x18> } 18: 1e 04 ef 45 mov fp,sp 1c: 00 00 5e a7 ldq ra,0(sp) 20: 08 00 fe a5 ldq fp,8(sp) 24: 1e 14 c2 43 addq sp,0x10,sp 28: 01 80 fa 6b ret zero,(ra),0x1 2c: 00 00 00 00 halt ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Clifford T. Matthews @ 1998-12-12 5:00 ` Joachim Wesner 0 siblings, 0 replies; 13+ messages in thread From: Joachim Wesner @ 1998-12-12 5:00 UTC (permalink / raw) Clifford T. Matthews wrote: > > >>>>> "Joachim" == Joachim Wesner <joachim.wesner@frankfurt.netsurf.de> writes: > > Joachim> Bram wrote: > >> I've been reading DEC's Assembly Language Programmer's Guide. > >> But I have a couple of questions. > >> > >> How can I have egcs generate more verbose assembly output? The > >> samples in the guide show the C-source as comments in the assembly > >> file. The output from egcc -S does not give these. > > Joachim> To my knowledge, there is no way to have the assembly output > Joachim> mixed with the C-source on gcc/egcs. I would love to hear > Joachim> about any possibility. > > alpha.ardi.com 1.5 objdump --disassemble --source foo.o > > foo.o: file format elf64-alpha > > Disassembly of section .text: > > 0000000000000000 <main>: > { > 0: f0 ff de 23 lda sp,-16(sp) > 4: 00 00 5e b7 stq ra,0(sp) > 8: 08 00 fe b5 stq fp,8(sp) > c: 0f 04 de 47 mov sp,fp > return 0; > 10: 00 04 ff 47 clr v0 > 14: 00 00 e0 c3 br 18 <main+0x18> > } > 18: 1e 04 ef 45 mov fp,sp > 1c: 00 00 5e a7 ldq ra,0(sp) > 20: 08 00 fe a5 ldq fp,8(sp) > 24: 1e 14 c2 43 addq sp,0x10,sp > 28: 01 80 fa 6b ret zero,(ra),0x1 > 2c: 00 00 00 00 halt 'scuse us, but this is just NOT what we were talking about, a .S file is even better, What is wanted is a listing that directly relates the C source code lines with assembly code blocks, to eliminate some initial but could be avoidable guessing/analysis when trying to understand gcc/egcs output. Joachim ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Joachim Wesner 1998-12-12 5:00 ` Clifford T. Matthews @ 1998-12-19 5:00 ` Toon Moene 1999-01-05 5:00 ` Alex Rhomberg 1 sibling, 1 reply; 13+ messages in thread From: Toon Moene @ 1998-12-19 5:00 UTC (permalink / raw) Joachim Wesner wrote: > Bram wrote: > > I've been reading DEC's Assembly Language Programmer's Guide. > > But I have a couple of questions. > > How can I have egcs generate more verbose assembly output? > > The samples in the guide show the C-source as comments in > > the assembly file. > > The output from egcc -S does not give these. > To my knowledge, there is no way to have the assembly output mixed with > the C-source on gcc/egcs. Well, I never got around writing this, but the egcc -g -S [other options] ... command should write the debugging information in the assembler file, and hence - because the debugging info contains the line number - it's possible (writing a small C program that reads both the .s and the .c file) to create a combined file with the assembler code interspersed with the original C code. HTH, -- Toon Moene (toon@moene.indiv.nluug.nl) Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Phone: +31 346 214290; Fax: +31 346 214286 g77 Support: fortran@gnu.org; egcs: egcs-bugs@cygnus.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-19 5:00 ` Toon Moene @ 1999-01-05 5:00 ` Alex Rhomberg 1999-01-06 5:00 ` Bram Stolk 0 siblings, 1 reply; 13+ messages in thread From: Alex Rhomberg @ 1999-01-05 5:00 UTC (permalink / raw) Toon Moene wrote: > > Joachim Wesner wrote: > > > Bram wrote: > > > > I've been reading DEC's Assembly Language Programmer's Guide. > > > But I have a couple of questions. > > > > How can I have egcs generate more verbose assembly output? > > > The samples in the guide show the C-source as comments in > > > the assembly file. > > > The output from egcc -S does not give these. > > > To my knowledge, there is no way to have the assembly output mixed with > > the C-source on gcc/egcs. > > Well, I never got around writing this, but the egcc -g -S [other > options] ... command should write the debugging information in the > assembler file, and hence - because the debugging info contains the line > number - it's possible (writing a small C program that reads both the .s > and the .c file) to create a combined file with the assembler code > interspersed with the original C code. Well, one could either write a large C program or a small perl script. This one takes the output of "gcc -g -S" and adds the corresponding source to the line information in the assembler output. I wrote this after just looking at some -S output, so it might be complete crap. It just worked with what I tried ( including code from an include file in a different directory) #!/usr/bin/perl #combines output of gcc -S -g with C source # by Alex Rhomberg <rhomberg@ife.ee.ethz.ch> #usage: # gcc -S -g --otheroptions blops.c # combasm blops.s while (<>) { chomp; # file name and directory information are in the .stabs line # in double quotes #example: #.stabs "/home/me/progs/tmp/",100,0,0,$Ltext0 #.stabs "blops.c",100,0,0,$Ltext0 #here, I search for .stabs followed by a name, and finally $Ltext if (m|^\.stabs \"(.*)\"[\s\d,]+\$Ltext\d+|) { $name = $1; if ($name =~ m|/$|) { #if the name ends in / it is the working directory chdir $name or die "couldn't chdir to $name"; } else { #otherwise it is the source file, which is read and chomped open CFILE, "$name" or die "couldn't open $name"; @cfile = <CFILE>; chomp @cfile; close CFILE; } } #line information lines start with .stabn, to numbers and the line number #if such a line is encountered, the source line is added #in optimized code, the same line could appear several times if (/^\s+\.stabn \d+,\d+,(\d+)/) { $_ .= "\t#" . $cfile[$1-1]; } print "$_\n"; } -- _________________________________________________________________ / \ | Alex Rhomberg Tel: +41 1 632 49 18 | | Institut fuer Elektronik Fax: +41 1 632 12 10 | | ETH Zuerich Zentrale: +41 1 632 11 11 | | Gloriastrasse 35 | | 8092 Zuerich email: rhomberg@ife.ee.ethz.ch | \_________________________________________________________________/ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1999-01-05 5:00 ` Alex Rhomberg @ 1999-01-06 5:00 ` Bram Stolk 0 siblings, 0 replies; 13+ messages in thread From: Bram Stolk @ 1999-01-06 5:00 UTC (permalink / raw) To: Alex Rhomberg Hi Alex Rhomberg wrote: > Well, one could either write a large C program or a small perl script. > This one takes the output of "gcc -g -S" and adds the corresponding > source to the line information in the assembler output. > I wrote this after just looking at some -S output, so it might be > complete crap. It just worked with what I tried ( including code from an > include file in a different directory) Well, it worked for me. thanks Bram ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-10 5:00 assembly programming on alphas Bram 1998-12-12 5:00 ` Joachim Wesner @ 1998-12-12 5:00 ` Bradley DeJong 1998-12-12 5:00 ` Reginald Beardsley 1998-12-12 5:00 ` Raymond Doetjes 1998-12-13 5:00 ` dontspam_esci 3 siblings, 1 reply; 13+ messages in thread From: Bradley DeJong @ 1998-12-12 5:00 UTC (permalink / raw) This isn't my real e-mail address. Please respond to the news group. I don't think that there is a way to get egcs to generate asm with the C code as comments. You could write it? :^) The Alpha is strictly a load-store architecture. One of the implications of that is that to do a memory-to-memory copy, you have to load a value into a register and then store the contents of that register to a new location. As for the "fastest" way to do a large memcpy, that depends on implementation. For example, if BWX is supported, the code may/will look different. Check the chapter on "Software Considerations" in the Alpha Architecture Handbook to get a better idea of all the options. For the unaligned prefix, you are probably better off loading the naturallly aligned quadwords containing both the first source and first target bytes, then shifting and masking before writing the result. After that prefetch cache blocks and unroll the read/write loop to take advantage of all the memory bandwidth. The problem of course is dealing with arbitrarily aligned data. (See A.3 in the Alpha Architecture Handbook for more detail on the software issues involved with read/write performance.) Assuming that you want to move a block of 40 bytes (5 quad words) that: 1. is not naturally aligned 2. straddles a cacheline boundary 3. does not straddle a page boundary (don't want to worry about page faults) To a block of 40 bytes that: 1. is not naturally aligned 2. does not have the same alignment within its quadword 3. straddles a cacheline boundary 4. does not straddle a page boundary 5. does not overlap with the source block 6. does not cause cache conflicts with the first block (is not mapped to the same cacheline as any part of the first block) This gives you data that looks something like this: Src = 11111aaa aaaaabbb bbbbbccc cccccddd dddddeee eeeee111 Dest = 222yyyyy xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx zzz22222 Where: 1: is a byte value that should not be copied 2: is a byte value that should remain unchanged a, b, c, d, and e: are byte values that are copied x, y, and z: are byte values that will be overwritten Then, the code does something similar to: load the 1st Src quadword (11111aaa) load the 1st Dest quadword (222yyyyy) prefetch the first quadword of the next cacheline of Src prefetch the first quadword of the next cacheline of Dest Doing these 4 loads 1st ensures that we encounter as few waits for the memory system as possible. All of the desired memory is now being loaded into the L1 cache. load the 2nd Src quadword (aaaaabbb) load the 3rd Src quadword (bbbbbccc) load the 4th Src quadword (cccccddd) load the 5th Src quadword (dddddeee) (this gives us 8 aligned quadword loads including the 2 touches. Digital recommends using no more than 8 consecutive aligned quadword loads to avoid overwhelming the memory subsystem, so now do some calculation before loading the last 2 quadwords) Start by using the 1st value that was loaded. Don't use it immediately after loading, because you need to allow for memory latency. shift (11111aaa) to (aaa00000) shift (aaa00000) back to (000aaa00) shift (222yyyyy) to (00000222) shift (00000222) back to (22200000) shift (aaaaabbb) to (000000aa) shift (aaaaabbb) to (aaabbb00) AND (000000aa) and (000aaa00) to (000aaaaa) AND (000aaaaa) ans (22200000) to (222aaaaa) store (222aaaaa) to the 1st quadword of Dest shift (bbbbbccc) to (000000bb) shift (bbbbbccc) to (bbbccc00) AND (aaabbb00) and (000000bb) to (aaabbbbb) store (aaabbbbb) to the 2nd quadword of Dest If this doesn't allow enough time since the previous 8 loads, move these loads to a later slot. load the 6th Src quadword (eeeee111) load the 6th Dest quadword (zzz22222) continue shifting and storing until done. Compare that code sequence to the code needed to do a memcpy between 2 non-overlapping blocks of memory that are aligned on 128 byte boundaries (sufficient to ensure alignment with cache blocks for all current Alpha implementations) and that have no cacheline conflicts. prefetch 1st quadword of Dest load 1st quadword of Src load 2nd quadword of Src load 3rd quadword of Src load 4th quadword of Src prefetch 5th quadword of Dest load 5th quadword of Src store 1st quadword to Dest store 2nd quadword to Dest store 3rd quadword to Dest store 4th quadword to Dest store 5th quadword to Dest You can see that if the compiler follows the additional alignment restrictions, the code can be much simpler/faster. Of course this also means that the compiler has to be smart enough to generate good code. Additional considerations due to calling conventions: With the Alpha architecture, you have 31 usable registers, so you can do this kind of load/manipulate/store sequence without running out of registers. Of course, you have to keep in mind the calling conventions of the OS you are using (does anybody know what they are on Linux/Alpha?). For example, 1 register is probably reserved for function call return addresses, 1 for compiler use, 8 for values that are maintained across function call boundaries, 8 for scratch use within a function, 8 for parameter passing, .... Even so, you can usually work out a code sequence that gives good performance. As an additional reference/case study, www.microway.com has a nice white paper on the kind of optimizations their compilers use for floating point code on Alpha. Bram wrote: > > Hello, > > I've been reading DEC's Assembly Language Programmer's Guide. > But I have a couple of questions. > > How can I have egcs generate more verbose assembly output? > The samples in the guide show the C-source as comments in > the assembly file. > The output from egcc -S does not give these. > > Also, isn't there a more convenient method for memory > to memory copying? It seems that the only way to move > data from memory to memory, is by loading, and then > storing registers. > On Intel, I use movsb/movsw/movsl a lot, but there > does not seem to be an alpha-equivalent. > > I am curious how memcpy is implemented on the alpha. > What is the fastest way to copy, say, 32 bytes or more > from one location to another? And what if the data > is not alligned? > > thanks in advance, > > Bram Stolk ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Bradley DeJong @ 1998-12-12 5:00 ` Reginald Beardsley 1998-12-16 5:00 ` Paul Repacholi 0 siblings, 1 reply; 13+ messages in thread From: Reginald Beardsley @ 1998-12-12 5:00 UTC (permalink / raw) Not quite the same thread, but close... I am looking for some short code fragments in C, FORTRAN or assembly which will achieve peak rates for several types of operations to use as guides in optimzing a very large signal processing operation (i.e CPU months per job for small jobs!) peak main memory to register transfer peak register to L3 transfer rate peak floating point performance peak vector performance wave pipeline setup and execution (are there OS limitations on using this mode? Development will be done on a DU box because of the need for a good FORTRAN compiler. Cluster nodes will run whatever works best in terms of total price-performance.) References to any literature discussing these issues greatly appreciated. I've bought or downloaded everything I can find and intend to buy anything else that is available. I have guesses about the answers based on reading various references. What I'm looking for is verification that I correctly understand the behavior of the 164LX board with a 533 MHz 21164A. Much to my astonishment the Compaq/DEC HPC group response was, "we have such examples, but they're proprietary". I'd hoped that the company attitude had improved in the 8-9 years since I last did business with DEC. It will be interesting to see if being a member of their ISV program improves the situation. Working for big oil didn't help in 1990 despite having 100's of DECstations in the shop. Of course, now there are none at all. Just Sun & SGI boxes... email appreciated. I read the group closely, but don't have a lot of confidence in the reliability of my feed yet. Thanks, Reg Beardsley rhb@acm.org ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Reginald Beardsley @ 1998-12-16 5:00 ` Paul Repacholi 0 siblings, 0 replies; 13+ messages in thread From: Paul Repacholi @ 1998-12-16 5:00 UTC (permalink / raw) Reginald Beardsley <esci@shell.fastlane.net> writes: > Not quite the same thread, but close... > > I am looking for some short code fragments in C, FORTRAN or assembly > which will achieve peak rates for several types of operations to > use as guides in optimzing a very large signal processing operation > (i.e CPU months per job for small jobs!) They don't exist... but, run, don't walk over to Gatekeeper and get DCPI for DU. To get apps like this fast, is pretty much machine and app specific. ~paul ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-10 5:00 assembly programming on alphas Bram 1998-12-12 5:00 ` Joachim Wesner 1998-12-12 5:00 ` Bradley DeJong @ 1998-12-12 5:00 ` Raymond Doetjes 1998-12-11 5:00 ` Bram 1998-12-13 5:00 ` dontspam_esci 3 siblings, 1 reply; 13+ messages in thread From: Raymond Doetjes @ 1998-12-12 5:00 UTC (permalink / raw) Wow were did you find the Alpha instruction set?? I want to program some assembler with the Alpha aswell but I cant seem to find the mnemonics for the Alpha anywhere. Raymond ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-12 5:00 ` Raymond Doetjes @ 1998-12-11 5:00 ` Bram 0 siblings, 0 replies; 13+ messages in thread From: Bram @ 1998-12-11 5:00 UTC (permalink / raw) To: Raymond Doetjes Raymond Doetjes wrote: > > Wow were did you find the Alpha instruction set?? > I want to program some assembler with the Alpha aswell but I cant seem > to find the mnemonics for the Alpha anywhere. Assembly Language Programmer's Guide is at: http://www.partner.digital.com/www-swdev/pages/Home/TECH/documents/osf1-docs-v3.0.html Other info, including mnemonics is at: http://ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html > > Raymond ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: assembly programming on alphas 1998-12-10 5:00 assembly programming on alphas Bram ` (2 preceding siblings ...) 1998-12-12 5:00 ` Raymond Doetjes @ 1998-12-13 5:00 ` dontspam_esci 3 siblings, 0 replies; 13+ messages in thread From: dontspam_esci @ 1998-12-13 5:00 UTC (permalink / raw) Bram <stolk@xs4all.nl> wrote: [snip] > How can I have egcs generate more verbose assembly output? > The samples in the guide show the C-source as comments in > the assembly file. > The output from egcc -S does not give these. [snip] You can intersperse C source in the assembly by compiling w/ cc -g -c foo.c and then disassembling w/ objdump -d -S foo.o Have fun! Reg Beardsley rhb @ acm . org ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~1999-01-06 5:00 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1998-12-10 5:00 assembly programming on alphas Bram 1998-12-12 5:00 ` Joachim Wesner 1998-12-12 5:00 ` Clifford T. Matthews 1998-12-12 5:00 ` Joachim Wesner 1998-12-19 5:00 ` Toon Moene 1999-01-05 5:00 ` Alex Rhomberg 1999-01-06 5:00 ` Bram Stolk 1998-12-12 5:00 ` Bradley DeJong 1998-12-12 5:00 ` Reginald Beardsley 1998-12-16 5:00 ` Paul Repacholi 1998-12-12 5:00 ` Raymond Doetjes 1998-12-11 5:00 ` Bram 1998-12-13 5:00 ` dontspam_esci
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox