Created
April 20, 2020 22:07
-
-
Save SteveBronder/77d3d798bab249ba978c4fb21e1bfba6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(data.table) | |
| library(ggplot2) | |
| mat_mul_dt = fread("./mat_mul_bench.csv") | |
| mat_mul_dt[1:25, bench := "old"] | |
| mat_mul_dt[26:50, bench := "new"] | |
| mm_strs = t(mat_mul_dt[, strsplit(Benchmark, "/")]) | |
| mat_mul_dt[, benchmark := mm_strs[, 1]] | |
| mat_mul_dt[, rows := as.numeric(mm_strs[, 2])] | |
| mat_mul_dt[, cols := as.numeric(mm_strs[, 3])] | |
| mm_dt = mat_mul_dt[, .(bench, rows, cols, Time)] | |
| mm_dt[, Time := as.numeric(gsub("ns", "", Time))] | |
| ggplot(mm_dt, aes(x = rows * cols, y = Time)) + | |
| geom_line(aes(color = bench)) + | |
| scale_x_continuous(trans = "log") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Benchmark | Time | CPU | Iterations | |
|---|---|---|---|---|
| matvec_mul/32/32 | 20318 ns | 20318 ns | 33214 | |
| matvec_mul/64/32 | 18391 ns | 18391 ns | 38173 | |
| matvec_mul/512/32 | 18288 ns | 18283 ns | 37986 | |
| matvec_mul/4096/32 | 19872 ns | 19868 ns | 34618 | |
| matvec_mul/10000/32 | 25192 ns | 25188 ns | 25698 | |
| matvec_mul/32/64 | 19458 ns | 19456 ns | 36367 | |
| matvec_mul/64/64 | 17630 ns | 17629 ns | 39975 | |
| matvec_mul/512/64 | 17285 ns | 17283 ns | 39954 | |
| matvec_mul/4096/64 | 20187 ns | 20184 ns | 34612 | |
| matvec_mul/10000/64 | 31602 ns | 31599 ns | 22107 | |
| matvec_mul/32/512 | 40933 ns | 40933 ns | 16964 | |
| matvec_mul/64/512 | 39607 ns | 39605 ns | 17753 | |
| matvec_mul/512/512 | 40256 ns | 40245 ns | 17471 | |
| matvec_mul/4096/512 | 61975 ns | 61959 ns | 10953 | |
| matvec_mul/10000/512 | 117112 ns | 117083 ns | 5807 | |
| matvec_mul/32/4096 | 211665 ns | 211631 ns | 3312 | |
| matvec_mul/64/4096 | 209608 ns | 209577 ns | 3331 | |
| matvec_mul/512/4096 | 323201 ns | 323162 ns | 2161 | |
| matvec_mul/4096/4096 | 385174 ns | 385172 ns | 1793 | |
| matvec_mul/10000/4096 | 819930 ns | 819821 ns | 770 | |
| matvec_mul/32/10000 | 492699 ns | 492588 ns | 1420 | |
| matvec_mul/64/10000 | 759497 ns | 759344 ns | 917 | |
| matvec_mul/512/10000 | 769558 ns | 769102 ns | 875 | |
| matvec_mul/4096/10000 | 918503 ns | 918226 ns | 692 | |
| matvec_mul/10000/10000 | 1994023 ns | 1993674 ns | 339 | |
| matvec_mul/32/32 | 20689 ns | 20689 ns | 33185 | |
| matvec_mul/64/32 | 18972 ns | 18972 ns | 37075 | |
| matvec_mul/512/32 | 18526 ns | 18525 ns | 37592 | |
| matvec_mul/4096/32 | 20018 ns | 20017 ns | 34622 | |
| matvec_mul/10000/32 | 24335 ns | 24333 ns | 27550 | |
| matvec_mul/32/64 | 20166 ns | 20163 ns | 34508 | |
| matvec_mul/64/64 | 18403 ns | 18398 ns | 37259 | |
| matvec_mul/512/64 | 18025 ns | 18023 ns | 35522 | |
| matvec_mul/4096/64 | 20122 ns | 20119 ns | 34590 | |
| matvec_mul/10000/64 | 32033 ns | 32027 ns | 21769 | |
| matvec_mul/32/512 | 47792 ns | 47778 ns | 14657 | |
| matvec_mul/64/512 | 46876 ns | 46865 ns | 14899 | |
| matvec_mul/512/512 | 46921 ns | 46915 ns | 14861 | |
| matvec_mul/4096/512 | 65810 ns | 65801 ns | 10416 | |
| matvec_mul/10000/512 | 118282 ns | 118274 ns | 5754 | |
| matvec_mul/32/4096 | 270275 ns | 270246 ns | 2592 | |
| matvec_mul/64/4096 | 272888 ns | 272827 ns | 2564 | |
| matvec_mul/512/4096 | 374477 ns | 374426 ns | 1867 | |
| matvec_mul/4096/4096 | 426703 ns | 426650 ns | 1338 | |
| matvec_mul/10000/4096 | 827558 ns | 827377 ns | 763 | |
| matvec_mul/32/10000 | 640994 ns | 640902 ns | 1090 | |
| matvec_mul/64/10000 | 908390 ns | 908346 ns | 768 | |
| matvec_mul/512/10000 | 901223 ns | 901090 ns | 752 | |
| matvec_mul/4096/10000 | 1024624 ns | 1024400 ns | 630 | |
| matvec_mul/10000/10000 | 2019169 ns | 2018561 ns | 334 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define STAN_OPENCL | |
| #define OPENCL_DEVICE_ID 0 | |
| #define OPENCL_PLATFORM_ID 2 | |
| #define CL_HPP_ENABLE_EXCEPTIONS | |
| #define CL_HPP_TARGET_OPENCL_VERSION 120 | |
| #define CL_HPP_MINIMUM_OPENCL_VERSION 120 | |
| #include <benchmark/benchmark.h> | |
| #include <stan/math.hpp> | |
| using namespace stan::math; | |
| static void matvec_mul(benchmark::State& state) { | |
| matrix_cl<double> m(Eigen::Matrix<double, -1, -1>::Random(state.range(0), state.range(1))); | |
| matrix_cl<double> v(Eigen::Matrix<double, -1, 1>::Random(state.range(1))); | |
| // matrix_cl<double> res = m * v; | |
| matrix_cl<double> res(state.range(0),1);// = matrix_vector_multiply(m, v); | |
| //res.wait_for_write_events(); | |
| benchmark::ClobberMemory(); | |
| for (auto _ : state) { | |
| res = m * v; | |
| // res = matrix_vector_multiply(m, v); | |
| res.wait_for_write_events(); | |
| } | |
| } | |
| BENCHMARK(matvec_mul)->Ranges({{32, 10000}, {32, 10000}}); | |
| BENCHMARK_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment