Skip to content

Instantly share code, notes, and snippets.

View bgeneto's full-sized avatar
🏠
Working from home

Bernhard Enders bgeneto

🏠
Working from home
View GitHub Profile
@bgeneto
bgeneto / fortran-vs-python-integration-loop.md
Last active January 11, 2024 23:55
Python vs Fortran performance on trapezoidal numerical integration

Python numerical integration performance

Out of the box performance of python numerical integration is poor. Here we present three python versions of the trapezoidal rule.

Python code (naive version)

import math
import time
@bgeneto
bgeneto / zsh4humans.md
Last active September 5, 2023 13:58
zsh install and config

Install sofware dependencies

#export pkgmngt=dnf
export pkgmngt=apt
sudo $pkgmngt update && sudo $pkgmngt install tree exa zsh wget curl unzip fontconfig -y

Font Install

@bgeneto
bgeneto / hermitianEigen-small.f90
Last active November 1, 2022 11:34
hermitianEigen fortran zheevd bench
! --------------------------------------------------------
! compile command line:
! ifort -O2 -i8 -mcmodel=medium -qmkl=parallel ./hermitianEigen-small.f90 -o ./hermitianEigen-small ${MKLROOT}/lib/intel64/libmkl_lapack95_ilp64.a -L${MKLROOT}/lib/intel64 -lpthread -lm -ldl
! --------------------------------------------------------
program hermitianEigen
use, intrinsic :: iso_fortran_env
use lapack95, only: heevd
@bgeneto
bgeneto / numpy-eigen-bench.md
Last active May 5, 2024 22:15
numpy eigen benchmark

Purpose

To benchmark Python (Numpy) default procedure to find all eigenvalues and eigenvectors of a complex (hermitian) matrix and compare the results with Fortran using either MKL and OpenBLAS libraries.

Python code

import time
import numpy as np
@bgeneto
bgeneto / hermitianEigen.f90
Last active August 2, 2022 03:18
OpenBLAS ZHEEV slow performance bug
! --------------------------------------------------------------------------------------
!
! 01. Purpose: Solves a simple eigenvalue/eigenvector problem in order to check
! for the zheev thread locking bug #1560
! https://github.com/xianyi/OpenBLAS/issues/1560
!
! 02. Compile and build
!
! export MAX_THREADS=4
! export OPENBLAS_NUM_THREADS=$MAX_THREADS
@bgeneto
bgeneto / intel-compilers-mkl-wsl2-via-repo.md
Last active January 11, 2024 23:56
Install Intel Compilers on Windows via WSL2

Install Intel Compilers on Windows via WSL2

Note: This step-by-step tutorial assumes that you already have a Linux distribution (Debian, Ubuntu...) installed on your WSL environment.

Update your package repository inside WSL2

sudo apt update
@bgeneto
bgeneto / openblas-bench.md
Last active August 25, 2022 13:43
Benchmarking with OpenBLAS

Timed Openblas library build

cd /tmp
libver=0.3.21
wget https://github.com/xianyi/OpenBLAS/releases/download/v$libver/OpenBLAS-$libver.tar.gz
tar xf OpenBLAS-$libver.tar.gz
cd OpenBLAS-$libver

export USE_THREAD=1
@bgeneto
bgeneto / minirc.md
Last active June 14, 2022 14:48
minicom minirc configuration file
cat <<EOF > $HOME/.minirc.dfl
pu localecho        Yes
pu addlinefeed      Yes
pu linewrap         Yes
pu addcarreturn     Yes
EOF
@bgeneto
bgeneto / ambigram_dates.py
Created February 22, 2022 19:58
Shows all ambigram dates between two given years
'''
Dados os dois anos abaixo, este programa exibe todas as datas
que são tanto palíndromas (capicuas) como ambigramas (rotacionais).
'''
ANO_INI = 2000
ANO_FIM = 2100
import datetime as dt