Unrolled example [Two-Stage / GS Designs]

posted by ElMaestro  – Denmark, 2015-02-21 02:32 (4129 d 17:22 ago) – Posting: # 14482
Views: 14,626

Hi Hötzi,

just tried to implement something that more or less corresponded to the example you had.

I get about a 10% speedup difference if I unroll 4x:

runs  <- 1e5
run   <- 1:runs
ptm   <- proc.time()
i=1
v2    <- vector("numeric", length=runs)
while (i<=runs)
{
  v2[i] <- rnorm(1, mean=0, sd=1)
  i=i+1
}
 
t2    <- proc.time()-ptm
cat("Simple time: ", t2[3], "seconds.\n")
#
#



runs  <- 1e5
run   <- 1:runs
ptm   <- proc.time()
i=1
v2    <- vector("numeric", length=runs)
while (i<=runs)
{
  v2[i]    <- rnorm(1, mean=0, sd=1)
  v2[i+1]  <- rnorm(1, mean=0, sd=1)
  v2[i+2]  <- rnorm(1, mean=0, sd=1)
  v2[i+3]  <- rnorm(1, mean=0, sd=1)

  i=i+4
}
 
t2    <- proc.time()-ptm
cat("Unrolled x4 time: ", t2[3], "seconds.\n")
#
#



10% isn't bad, actually. One could probably even optimise the number of unrolls.

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
23,653 posts in 4,991 threads, 1,571 registered users;
117 visitors (0 registered, 117 guests [including 20 identified bots]).
Forum time: 20:54 CEST (Europe/Vienna)

Outside his own ever-narrowing field of specialization,
a scientist is a layman.
What members of an academy of science have in common
is a certain form of semiparasitic living.    Erwin Chargaff

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5