chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Speeding up bit-vector operation (using iset)


From: Lasse Kliemann
Subject: [Chicken-users] Speeding up bit-vector operation (using iset)
Date: Tue, 16 Mar 2010 22:43:41 +0100

First, thank you everyone for the many answers to my last 
question. Here I've got a new issue that I'd like to discuss. It 
is about speeding up bit-vector operation using the iset 
extension. Consider the program given below. It creates two large 
bit-vectors, initializes them with random entries, and then 
performs and, ior, and nand operations (corresponding to 
intersection, union, and difference of the sets  defined by the 
vectors) a number of 10 times.

I compile this with:

  csc mini.scm -O5 -o mini -C '-O3 -fomit-frame-pointer -fno-strict-aliasing'

The time spent in computation is approx. 333 seconds on a 2.7 GHz 
AMD. I chose the declarations according to the FAQ (if I 
understand correctly, then standard-bindings and 
extended-bindings are enabled by default via usual-integrations 
anyway).

All those optimization settings do not seem to have a big effect.  
If I remove those declarations and also the compiler command line 
switches, computation time only increases to approx. 350 seconds.

Are there further possibilities to speed this up?

----------------------------------------------------------------

(declare
  (standard-bindings)
  (extended-bindings)
  (disable-interrupts)
  (unsafe))

(use iset)

(define n 67108864) ; 2^26

(define (randomize-bit-vector! bv)
  (do
    ((i 0 (+ i 1)))
    ((= i n))
    (if (= 1 (random 2)) (bit-vector-set! bv i #t))))

(define s1 (make-bit-vector n))
(define s2 (make-bit-vector n))
(randomize-bit-vector! s1)
(randomize-bit-vector! s2)

(print "starting computation")
(define mark (current-seconds))

(do
  ((i 0 (+ 1 i)))
  ((= i 10))
  (bit-vector-and s1 s2)
  (bit-vector-ior s1 s2)
  (bit-vector-and s1 (bit-vector-nand s2)))

(print "time spent in computation: " (- (current-seconds) mark))

----------------------------------------------------------------

Attachment: pgpX4U9sc4qw5.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]