Running ‘buffer.R’
  Running ‘kernel.R’ [0m/90m]
Running the tests in ‘tests/buffer.R’ failed.
Complete output:
  > # 0. Create context
  > library(OpenCL)
  > 
  > if (!length(oclPlatforms())) {
  +     cat("== Cannot run tests as there is no platform")
  +     q("no")
  + }
  > 
  > ctx<-oclContext()
  > 
  > # 1. Create single-precision buffer and fill with values
  > buf <- clBuffer(ctx, 16, "single")
  > buf[] <- 1:16
  > 
  > #    Inspect the resulting buffer
  > class(buf)
  [1] "clBuffer"
  > print(attributes(buf)$mode)
  [1] "single"
  > print(buf)
  OpenCL buffer, 16 elements of type single 
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
  > length(buf)
  [1] 16
  > 
  > #    subsetting
  > buf[2:5]       # contiguous
  [1] 2 3 4 5
  > buf[c(1,6)]    # non-contiguous
  [1] 1 6
  > buf[-1]        # negative
   [1]  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
  > buf[buf[] > 6] # logical
   [1]  7  8  9 10 11 12 13 14 15 16
  > buf[c(NA, 4)]  # NA
  [1] NA  4
  > 
  > #    subassignment
  > buf[2:3] = 0 # contiguous
  > buf[1:5]
  [1] 1 0 0 4 5
  > sum(buf[1:4])
  [1] 5
  > buf[5:4] = c(1,2) # non-contiguous (reversed)
  > buf[1:5]
  [1] 1 0 0 2 1
  > 
  > #    Check if memory accounting works.
  > oclMemLimits()$used
  [1] 64
  > rm(buf)
  > invisible(gc())
  > oclMemLimits()$used
  [1] 0
  > 
  > # 2. The same for an integer buffer
  > ints <- clBuffer(ctx, 32, "integer")
  > ints[] <- 16:47
  > 
  > #    Inspect the resulting buffer
  > class(ints)
  [1] "clBuffer"
  > print(attributes(ints)$mode)
  [1] "integer"
  > print(ints)
  OpenCL buffer, 32 elements of type integer 
   [1] 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  [26] 41 42 43 44 45 46 47
  > length(ints)
  [1] 32
  > 
  > # 3. Let's see if we can guess the type correctly
  > numeric.buf <- as.clBuffer(sqrt(3:18), ctx)
  > print(numeric.buf)
  OpenCL buffer, 16 elements of type double 
   [1] 1.732051 2.000000 2.236068 2.449490 2.645751 2.828427 3.000000 3.162278
   [9] 3.316625 3.464102 3.605551 3.741657 3.872983 4.000000 4.123106 4.242641
  > integer.buf <- as.clBuffer(-1:14, ctx)
  > print(integer.buf)
  OpenCL buffer, 16 elements of type integer 
   [1] -1  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14
  > 
  > # 4. Other functions
  > c(is.clBuffer(ints), is.clBuffer(1:16), is.clBuffer(ctx))
  [1]  TRUE FALSE FALSE
  > 
  > proc.time()
     user  system elapsed 
    0.516   0.111   1.082 
  double free or corruption (!prev)
Running the tests in ‘tests/kernel.R’ failed.
Complete output:
  > # 0. Create context and read kernel file
  > library(OpenCL)
  > 
  > if (!length(oclPlatforms())) {
  +     cat("== Cannot run tests as there is no platform")
  +     q("no")
  + }
  > 
  > ctx <- oclContext()
  > code <- readChar("kernel.cl", nchars=file.info("kernel.cl")$size)
  > 
  > # 1. Create kernel without inputs and run it
  > linear <- oclSimpleKernel(ctx, "linear", code, "integer")
  > oclRun(linear, 4)
  OpenCL buffer, 4 elements of type integer 
  [1] 0 1 2 3
  > oclRun(linear, 32)
  OpenCL buffer, 32 elements of type integer 
   [1]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  [26] 25 26 27 28 29 30 31
  > 
  > # 2. Run kernel with a numeric input buffer
  > square <- oclSimpleKernel(ctx, "square", code)
  > input <- as.clBuffer(sqrt(1:16), ctx)
  > output <- oclRun(square, 16, input)
  > output
  OpenCL buffer, 16 elements of type double 
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
  > oclRun(square, 16, output)
  OpenCL buffer, 16 elements of type double 
   [1]   1   4   9  16  25  36  49  64  81 100 121 144 169 196 225 256
  > 
  > # 3. Run kernel with a buffer argument and a scalar argument
  > multiply <- oclSimpleKernel(ctx, "multiply", code)
  > input <- as.clBuffer((1:16)^2, ctx)
  > output <- oclRun(multiply, 16, input, 2.5)
  > output
  OpenCL buffer, 16 elements of type double 
   [1]   2.5  10.0  22.5  40.0  62.5  90.0 122.5 160.0 202.5 250.0 302.5 360.0
  [13] 422.5 490.0 562.5 640.0
  > 
  > proc.time()
     user  system elapsed 
    0.759   0.164   1.410