Unrolled example [Two-Stage / GS Designs]

posted by ElMaestro  – Denmark, 2015-02-21 02:32 (3707 d 10:14 ago) – Posting: # 14482
Views: 12,350

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,424 posts in 4,927 threads, 1,708 registered users;
28 visitors (0 registered, 28 guests [including 10 identified bots]).
Forum time: 13:47 CEST (Europe/Vienna)

A Camel is a Horse designed by committee.    Anonymous

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