library("clrng")
get_system_info()
## $`1. Operating System`
## [1] "Linux"
##
## $`2. CPU`
## [1] "Intel(R) Xeon(R) W-2145 CPU @ 3.70GHz"
##
## $`3. GPU`
## [1] "\020n\r\xaa9\177" "\020n\r\xaa9\177" "gfx906:sramecc+:xnack-"
##
## $`4. OpenCL Version`
## [1] "OpenCL 3.0 LINUX"
## [2] "OpenCL 1.2 Intel(R) FPGA SDK for OpenCL(TM), Version 20.3"
## [3] "OpenCL 2.1 AMD-APP (3614.0)"
if (detectGPUs()) {
setContext(grep("gpu", listContexts()$device_type)[1])
currentDevice()
streamsonCpu <- createStreamsCpu(n=4)
typeof(streamsonCpu)
t(as.matrix(vclMatrix(streamsonCpu)))
t(as.matrix(2*vclMatrix(streamsonCpu)))
t(as.matrix(2*vclMatrix(streamsonCpu, type="integer")))
type = c('float','double')[1+gpuR::deviceHasDouble()]
t(as.matrix(2*vclMatrix(streamsonCpu, type=type)))
t(as.matrix(vclMatrix(2*streamsonCpu)))
streamsonGpu <- createStreamsGpu(n=6)
t(as.matrix(streamsonGpu))
saveRDS(as.matrix(createStreamsCpu(n = 4)), "myStreams.rds")
streams_saved <- vclMatrix(readRDS("myStreams.rds"))
} else {
message("No GPU detected. Skipping GPU-dependent code.")
}