Skip to content

Instantly share code, notes, and snippets.

View huanglangwen's full-sized avatar

huanglangwen

  • ETHZ
  • Zurich, Swizerland
View GitHub Profile
@huanglangwen
huanglangwen / StructralMatrices.md
Created September 8, 2019 09:42
Doc for coloring of structured matrices and integration of sparsediff in OrdinaryDiffEq.jl

Structured Matrices

We specialize matrix coloring and iterating in ArrayInterface.jl for structured matrices including:

  • Diagonal
  • Bidiagonal
  • Tridiagonal
  • BandedMatrix
  • BlockBandedMatrix
  • BandedBlockBandedMatrix

Coloring

The coloring function matrix_colors for structured matrices are overloaded by analytical results assuming all of the valid entries in the structured matrices are non-zero. Therefore, it is several magnitude faster than the default coloring algorithm. It is recommended to use the overloaded matrix_colors as long as the majority of the entries are filled by nonzero values. If not, you could further exploit the sparsity by convert the structured matrix into SparseCSC matrix and apply default coloring algorithm to it.

@huanglangwen
huanglangwen / Benchmarkjac.jl
Last active September 22, 2019 12:39
Benchmarking the performance of `forward_color_jacobian!` and `ForwardDiff.jacobian!`
using ForwardDiff, SparseDiffTools, DiffTests, DiffResults
using BenchmarkTools
######################Test/utils.jl
using ForwardDiff: DEFAULT_CHUNK_THRESHOLD
using Test
using Random
# seed RNG, thus making result inaccuracies deterministic
# so we don't have to retune EPS for arbitrary inputs
@huanglangwen
huanglangwen / Dockerfile
Last active October 14, 2020 12:40
Dockerfile for gt4py cuda
FROM nvidia/cuda:10.2-devel-ubuntu18.04
ARG CUDAVER=10.2
ARG CUDAVER_ND=cuda102
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends \
strace \
build-essential \