Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Skybuck's FastSpawnGeneratorV3 (154 cycles for 100 threads..

 
   Game Forums (Home) -> Core War RSS
Next:  Skybuck's FasterSpawnGeneratorV2 (154 cycles for ..  
Author Message
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 1) Posted: Fri Dec 07, 2007 6:05 pm
Post subject: Skybuck's FastSpawnGeneratorV3 (154 cycles for 100 threads, final code size: 26 instructions, done no further optimizations possible. :))
Archived from groups: rec>games>corewar (more info?)

;redcode
;name FasterSpawnGeneratorV3
;author Skybuck Flying
;version 3
;history version 1,2 and 3 created on 7 december 2007

;
; version 3:
;
; Let's try to optimize further by for example using dual data variables and
such.
;
; If there was a division instruction which stored the remainder in a and
result in b then further optimization
; would be possible, now it's not possible
; only further optimization was one less variable used so code size a bit
smaller now.
;
; It looks pretty minimized so I see no further room for optimizations or
space gain without sacrificing program flexibility Wink
;
; So the code looks done and pretty much final... Smile
;
; Only 26 instructions used, nice !
; 154 cycles for 100 threads.
;

;
; version 2:
;
; Let's try to optimize it for even faster performance and less code size !
Wink =D
;
; By using only one spawn program pointer cycles have been reduced further
to:
;
; 154 cycles for 100 threads ! 4% improvement.
;


; version 1:
; Tested with 101 threads (nice figure to test with)
;
; Tested with 100 threads to compare against others: 162 cycles needed.
; Code Size: 31 not to bad ! Wink
; Beats John's implementation in cycles.
;
; and this is not even the optimized version lol Wink Smile
;
; Let's implement John's spawning algorithm but let's also try to write it
more efficient,
; meaning no stack and the generated spawn program will be placed before the
program start.

ProgramStart


mov #100, ThreadsToSpawn
sub #1, ThreadsToSpawn

mov.b ThreadsToSpawn, DivThreadsToSpawn
mov.ba ThreadsToSpawn, ModThreadsToSpawn

; algoritm is simple:
; just divide threads to spawn by 2
; just mod threads to spawn by 2
; use mod result as binary indicator
; place mov spawn, 0 at binary zero's in front of program start at spawn
program pointer
; place spl 1 for binary one's in front of program start at spawn program
pointer
; repeat until div result is zero.
;
; so we need two copies of threads to spawn, maybe later we can place it in
a dual data variable.
; but for now I don't want to complicate things... so for now we use two
copies or even three lol.

; initialize spawn program pointer
mov #(ProgramStart - SpawnProgramPointer), SpawnProgramPointer

; algorithm implementation:
LoopBegin

div.ab #2, DivThreadsToSpawn
mod.a #2, ModThreadsToSpawn

OutputBegin
jmz.a OutputDoubleThreadsMinusOne, ModThreadsToSpawn

OutputDoubleThreads
mov DoubleThreadsInstruction, <SpawnProgramPointer
jmp OutputEnd

OutputDoubleThreadsMinusOne
mov DoubleThreadsMinusOneInstruction, <SpawnProgramPointer
OutputEnd

mov.ba DivThreadsToSpawn, ModThreadsToSpawn

jmn LoopBegin, DivThreadsToSpawn
LoopEnd

; execute spawn program
jmp @SpawnProgramPointer

ProgramData
ModThreadsToSpawn
DivThreadsToSpawn
dat #0, #0 ; A = ModThreadsToSpawn, B = DivThreadsToSpawn

ThreadsToSpawn dat $0, #0

SpawnProgramPointer dat $0, $0

DoubleThreadsInstruction spl 1, 0
DoubleThreadsMinusOneInstruction mov DoubleThreadsInstruction, 0

ProgramEnd

 >> Stay informed about: Skybuck's FastSpawnGeneratorV3 (154 cycles for 100 threads.. 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 2) Posted: Fri Dec 07, 2007 6:14 pm
Post subject: Oops subject line was wrong. I have two different versions: FastGenerator and FasterGenerator. Subject should have been FasterGenerator. (New thread with correct subject line created) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This thread is to be ignored. (Wrong subject line Wink)

Bye,
Skybuck.

 >> Stay informed about: Skybuck's FastSpawnGeneratorV3 (154 cycles for 100 threads.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Score Surface for 94nop - Hi, some anonymous person (still called "bvowk" for simplicity ;-) is so kind to provide access to a pile of computers. I have suggested to calculate one score surface for standard settings. It takes roughly 1000 times the time of one "no...

Bug in pMARS - Hi, either I don't know how EQUs work or I have found a bug in the parser of pMARS. So far I cound pin it down to: ;redcode-tiny ;name test ;assert CORESIZE == 800 v3 EQU 3 * (3 / 2 + 1) + 3 v4 EQU (CORESIZE - v3) dat.f v3, v4 With the..

KOTH.ORG: Status - ICWS Experimental 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG ICWS Experimental 94..

KOTH.ORG: Status - MultiWarrior 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG Multiwarrior 94 CoreWar..

KOTH.ORG: Status - 94 No Pspace 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG 94 No Pspace CoreWar Hill...
   Game Forums (Home) -> Core War All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]