Skip to content

Instantly share code, notes, and snippets.

@t4c1
t4c1 / eigendecomposition_speed_precision.cpp
Created March 15, 2019 13:54
Performance and precision test for eigendecomposition
#include <stan/math.hpp>
#include <stan/math/prim/mat/fun/symmetric_eigensolver.hpp>
#include <chrono>
#include <cstdio>
using namespace std;
using namespace Eigen;
using namespace stan::math;
double residual(const MatrixXd& a, const VectorXd& eigenvals, const MatrixXd& eigenvecs) {
//
// Created by tadej on 27. 07. 2018.
//
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define USE_TIMING_OUTPUTS
//#include <CL/cl.hpp>
#include <Eigen/Dense>
#include <iostream>
#define STAN_OPENCL
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#ifdef STAN_OPENCL
#include <stan/math.hpp>
#include <stan/math/opencl/add.hpp>
@t4c1
t4c1 / cov_benchmark.cpp
Last active June 3, 2019 19:01
gp_cov_exp_quad benchmark
#include <iostream>
//#define STAN_OPENCL
//#define OPENCL_PLATFORM_ID 0
//#define OPENCL_DEVICE_ID 0
#include <stan/math.hpp>
#include <stan/math/opencl/copy.hpp>
#include <stan/math/opencl/matrix_cl.hpp>
#include <stan/math/rev/mat/fun/gp_exp_quad_cov.hpp>
@t4c1
t4c1 / cov_threshold.cpp
Created May 6, 2019 11:52
stan math gp_exp_quad_cov gpu thresholds
#include <iostream>
#define STAN_OPENCL
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#include <stan/math.hpp>
#include <stan/math/opencl/copy.hpp>
#include <stan/math/opencl/matrix_cl.hpp>
#include <stan/math/rev/mat/fun/gp_exp_quad_cov.hpp>
@t4c1
t4c1 / softmax_benchmark.cpp
Created May 15, 2019 13:10
softmax_regression benchmark
#define STAN_OPENCL
#define STAN_OPENCL_CACHE
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define __CL_ENABLE_EXCEPTIONS
#include <stan/math/prim/scal/meta/partials_return_type.hpp>
#include <stan/math.hpp>
#include <Eigen/Dense>
@t4c1
t4c1 / ordered_logistic_benchmark.cpp
Created May 23, 2019 14:13
benchamer for stan math ordinal regression
#define STAN_OPENCL
#define STAN_OPENCL_CACHE
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define __CL_ENABLE_EXCEPTIONS
#include <stan/math/prim/scal/meta/partials_return_type.hpp>
#include <stan/math.hpp>
#include <Eigen/Dense>
@t4c1
t4c1 / cov_benchmark.cpp
Created June 17, 2019 12:33
gp_exp_quad_cov data for more extreme cases
#include <iostream>
#define STAN_OPENCL
#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#include <stan/math.hpp>
#include <stan/math/opencl/copy.hpp>
#include <stan/math/opencl/matrix_cl.hpp>
#include <stan/math/rev/mat/fun/gp_exp_quad_cov.hpp>
@t4c1
t4c1 / plot_thresholds.py
Created September 2, 2019 10:16
Measurement and coefficient fitting for CPU-GPU threshold of GLMs in Stan
import pandas, numpy
import matplotlib.pyplot as plt
data = pandas.read_csv("thresholds.txt")
models=numpy.array(data["model"])
speedup=numpy.array(data["speedup"])
attributes=numpy.array(data["attributes"])
cases=numpy.array(data["cases"])
selection = numpy.logical_and(models!="normal_id",numpy.logical_or(cases>20000,numpy.logical_and(cases>8000, models=="negbin_log_2")))
@t4c1
t4c1 / clinfo1.txt
Created September 13, 2019 06:37
my clinfo
Number of platforms 2
Platform Name NVIDIA CUDA
Platform Vendor NVIDIA Corporation
Platform Version OpenCL 1.2 CUDA 10.1.120
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer
Platform Extensions function suffix NV
Platform Name Experimental OpenCL 2.1 CPU Only Platform
Platform Vendor Intel(R) Corporation