2010/06/18


ゴホンゴホン!

Miek - Thoughts on (technical) stuff - miek.nl

I'm writing a book about Go. Itis very much a work-in-progress, but I just wanted to mention thiswor...

http://www.miek.nl/blog/archives/2010/05/14/go_book/index.html
PDFで読めるよ。
go-book
Posted at by




今じゃぁgcc4が一般的なので、状況変わったかな?と思ったのでWindowsで再度試してみた。
Big Sky :: シャア専用memcpy

試してみた memcpy 最適化 - id:kazuhookuのメモ置き場バイト単位でコピーするアホなコードの方が、勝手にベクトル化される分、gcc 内蔵のヤツより最大3倍高速なんだってwwwx64じ...

http://mattn.kaoriya.net/software/gcc/20080617134829.htm
前回は効果が無かったけど、今回は --------------------------------------------------------------------------
gcc (GCC) 4.4.0
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--------------------------------------------------------------------------

# gcc -O3 -ftree-vectorize -msse2 test.c

adhock memcpy: 1.625031
normal memcpy: 3.734447

# gcc -O3 -ftree-vectorize -ftree-vectorizer-verbose=5 -mmmx -msse3 test.c

adhock memcpy: 1.609581
normal memcpy: 3.750480

# gcc test.c

adhock memcpy: 79.642154
normal memcpy: 4.968845

確かに3倍近いスコアが出てる。もうmemcpyとかinlineでいいんでね?
Posted at by




golangタグが既におかしいですが...
// ; hello world on win32 writen in asm.
// ; compile: 8a helloworld.s
// ; link   : 8l -o helloworld.exe helloworld.8
// ; run    : helloworld.exe
// ; 
// ; if you get the following compile error,
// ;   maybe, namespace separator was broken by copy-and-paste.
// ; open this file with text editor as utf-8 encoding, and fix following...
// ;
// ;   main!main
// ;   main!init
// ;   runtime!printstring
// ;
// ; ! should be code point 183 in unicode.

// ; main.main
TEXT    main·main+0(SB),$16-0
LEAL    gstring+0(SB),SI
LEAL    (SP),DI
CLD     ,
MOVSL   ,
MOVSL   ,
CALL    ,runtime·printstring+0(SB)
RET

// ; main.init
TEXT    main·init+0(SB),$4-0
RET

// ; data for native
GLOBL   string+0(SB),$14
DATA    string+0(SB)/8,$"hello, w"
DATA    string+8(SB)/7,$"orld!\n\z"

// ; data for gostring
GLOBL   gstring+0(SB),$8
DATA    gstring+0(SB)/4,$string+0(SB)
DATA    gstring+4(SB)/4,$13
END     ,
goではplan9形式のアセンブリで書けば8a(6a)でコンパイルでき、8l(6l)でリンク出来るので、上のソースをコンパイルすると見事に「hello, world!」と表示される。plan9のアセンブリってアライメントが必要なのね...。あと文字列リソースはgostring用と分けて書かないとlengthが違っちゃうみたい。

途中にある変な文字「·」はutf-8で183のコードポイントです。
gist: 434256 - GitHub

hello world on win32 writen in asm.

http://gist.github.com/434256
Posted at by