knitr::opts_chunk$set(echo = TRUE)
Here is an example of how our package functions run. For our data set, we are using a "SGEMM GPU kernel performance Data Set," which measures the running times of a matrix-matrix product, given different parameter combinations.
Below, all 4 functions in the package (calculating linear regression bootstrap, calculating confidence intervals for coefficients, prediction intervals, and confidence intervals for sigma^2) are much faster using C++ than using R. Overhead with complex functions such as map, apply, and reduce may takes a large amount of time with R so that the C++ version that only uses RcppArmadillo and functions from std namespace is much faster. Use of syntactic sugar from Rcpp is minimized in the C++ functions.
library(devtools) library(tidyverse) library(STA141CFinal) library(furrr) set.seed(141) dat = read_csv("sgemm_product.csv") dat = dat[sample(241000, 1000),] dat2 = dat[1:100,]
#We specifiy a specific column set y = dat$`Run1 (ms)` x = dat[,1:(ncol(dat)-4)] #linear model objects fit = linear_reg_bs_C(x, y, s = 10, r = 1000)
(b0 = bench::mark( linear_reg_bs(x = x, y = y, s = 10, r = 1000), linear_reg_bs_par(x = x, y = y, s = 10, r = 1000), linear_reg_bs_C(x, y, s = 10, r = 1000), check = FALSE) ) ggplot2::autoplot(b0)
coef_CI(fit, alpha = 0.05) coef_CI_par(fit,alpha = 0.05) coef_CI_C(fit,alpha = 0.05) (b1 = bench::mark( coef_CI(fit, alpha = 0.05), coef_CI_par(fit,alpha = 0.05), coef_CI_C(fit, alpha = 0.05), check = FALSE) ) ggplot2::autoplot(b1)
plan(multiprocess, workers = 4) PI(fit, dat2[1:3, 1:14], alpha = 0.05) PI_par(fit, dat2[1:3, 1:14], alpha = 0.05) PI_C(fit, dat2[1:3, 1:14], alpha = 0.05) (b2 = bench::mark( PI(fit, dat2[1:3, 1:14], alpha = 0.05), PI_par(fit, dat2[1:3, 1:14], alpha = 0.05), PI_C(fit, dat2[1:3, 1:14], alpha = 0.05), check = FALSE) ) ggplot2::autoplot(b2)
s2_CI(fit, alpha = 0.05) s2_CI_par(fit, alpha = 0.05) s2_CI_C(fit, alpha = 0.05) (b3 = bench::mark( s2_CI(fit, alpha = 0.05), s2_CI_par(fit, alpha = 0.05), s2_CI_C(fit, alpha = 0.05), check = FALSE) ) ggplot2::autoplot(b3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.