Skip to content

Instantly share code, notes, and snippets.

@cheuerde
cheuerde / R with MKL
Last active August 29, 2015 14:05
How to compile R with MKL #install #R
#!/bin/bash
# We are going to compile the C/C++ parts with intel's icc/icpc
export CC="icc"
export CXX="icpc"
export AR="xiar"
export LD="xild"
export F77='gfortran'
export FC='gfortran'
@cheuerde
cheuerde / (G)LMM - R
Last active August 29, 2015 14:06
(Generalized) linear mixed models in R for continous and categorical traits for animal models #R
#### (Generalized) linear mixed models in R for continous and categorical traits for animal models ###
#
# General TasK: Fit (G)LMM in R for an animal model with hundreds
# of thousands of observations.
# This is generally a feasable task, as the pedigree-based covariance structure of
# the main random term is very sparse (A-Inverse).
# Nevertheless, this is far from trivial directly in R and there are a lot of
# caveats.
#
# Problems:
@cheuerde
cheuerde / R_OpenBLAS
Last active March 20, 2023 18:06
Compiling R against OpenBLAS #install #R
#####################################################
### How to compile R and link it against OpenBLAS ###
#####################################################
# Assuming no root priviledges on the destination machine,
# so we have to compile our software locally
# set default installation directory:
INSTDIR=$HOME/opt
@cheuerde
cheuerde / eigen_avx.txt
Last active August 29, 2015 14:07
Eigen with AVX-Vectorization #install #C++
### as of september 2014 Eigen offers in its devel branch avx vectorization
### see: http://comments.gmane.org/gmane.comp.lib.eigen/4545
### get the devel-headers
wget -O - http://bitbucket.org/eigen/eigen/get/default.tar.gz > Eigen-Devel.tar.gz
### or
hg clone https://bitbucket.org/eigen/eigen/
@cheuerde
cheuerde / gausse_seidel_netcdf.R
Last active August 29, 2015 14:07
Gauss Seidel Iteration on NetCDF-data #R #algorithm #genomic_prediction
####################################################
### Claas Heuer, Sep. 2014 ###
### Example of performing Gauss-Seidel with ###
### residual updating using NetCDF stored data. ###
### Algorithm adopted from: de los Campos (2012) ###
####################################################
# this library allows us to read/write NetCDF files in R
# Note: for compiling (on linux) the netcdf headers are required:
@cheuerde
cheuerde / crossproduct_mpi_mp.cpp
Last active August 29, 2015 14:07
MPI + OpenMP Crossproduct #MPI #OpenMP #parallel #C++
// Claas Heuer, August 2013
// Computing a dense crossproduct
// with distributed data using MPI and OpenMP.
// Depends Eigen (http://eigen.tuxfamily.org/index.php?title=Main_Page)
// compile:
// mpicxx -fopenmp -O2 -I/path/to/Eigen crossproduct_mpi_mp.cpp -o cross.o
//
// run the program (in shell):
// # MP = number of cores for openMP
@cheuerde
cheuerde / BLAS_change_R.txt
Last active August 29, 2015 14:07
Changing BLAS library for R #install #R
# it is straightforward to change the BLAS-library that is used by an R-instance.
# For this we can use the environmental variable LD_PRELOAD.
# This variable will load any library specified prior to all others, so we
# can define a priority for certain libraries
#
# So in terms of R we would do something like this:
# imagine my BLAS-library is located in /home/user/myBLAS/BLAS.so
# invoke R with 'myBLAS'
@cheuerde
cheuerde / cuBLAS_ACML_R.sh
Last active August 29, 2015 14:07
cuBLAS and AMD's ACML for R #install
# cuBLAS/cuBLAS-xt is a full CUDA implementation of BLAS 1-3
# ACML is AMD's BLAS 1-3 optimized for AMD GPUs and fma4-CPUs
### cuBLAS
#
# get cuBLAS (note: non-free, closed source)
https://developer.nvidia.com/cuda-downloads
# example of how to use: http://devblogs.nvidia.com/parallelforall/drop-in-acceleration-gnu-octave/
@cheuerde
cheuerde / ddot_daxpy_R.c
Last active August 29, 2015 14:07
ddot and daxpy for R #R #C++ #parallel
### using ddot and daxpy
# system("curl -O -s https://gist.githubusercontent.com/cheuerde/2f59dd5087e201daee78/raw/1222222c5b4b38c04c55571138da7a962a74f4d0/ddot_daxpy_R.c ")
# system("R CMD SHLIB ddot_daxpy_R.c")
# dyn.load("ddot_daxpy_R.so")
#
# in R:
#
# ddot:
# .Call("ddot",x,y)
#
@cheuerde
cheuerde / openblas_R_Mac.sh
Last active August 29, 2015 14:07
OpenBlas for R on a Mac #install #script
###############################################
### How to link R against OpenBLAS on a Mac ###
###############################################
# this will install brew to /usr/local
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor