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

Skybuck's FasterSpawnGeneratorV2 (154 cycles for 100 threa..

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

External


Since: May 25, 2006
Posts: 295



(Msg. 1) Posted: Fri Dec 07, 2007 5:40 pm
Post subject: Skybuck's FasterSpawnGeneratorV2 (154 cycles for 100 threads, 4% improvement, still room for more improvement :))
Archived from groups: rec>games>corewar (more info?)

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

;
; 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.b 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 #2, DivThreadsToSpawn
mod #2, ModThreadsToSpawn

OutputBegin
jmz OutputDoubleThreadsMinusOne, ModThreadsToSpawn

OutputDoubleThreads
mov DoubleThreadsInstruction, <SpawnProgramPointer
jmp OutputEnd

OutputDoubleThreadsMinusOne
mov DoubleThreadsMinusOneInstruction, <SpawnProgramPointer
OutputEnd

mov.b DivThreadsToSpawn, ModThreadsToSpawn

jmn LoopBegin, DivThreadsToSpawn
LoopEnd

; execute spawn program
jmp @SpawnProgramPointer

ProgramData
ThreadsToSpawn dat $0, #0
DivThreadsToSpawn dat $0, #0
ModThreadsToSpawn dat $0, #0

SpawnProgramPointer dat $0, $0

DoubleThreadsInstruction spl 1, 0
DoubleThreadsMinusOneInstruction mov DoubleThreadsInstruction, 0

ProgramEnd

 >> Stay informed about: Skybuck's FasterSpawnGeneratorV2 (154 cycles for 100 threa.. 
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 ]