Skip to content

Instantly share code, notes, and snippets.

View ivan-pi's full-sized avatar

Ivan Pribec ivan-pi

View GitHub Profile
ivan-pi / Makefile
Last active February 14, 2024 15:23
Lattice Boltzmann in 2D on a periodic domain
CXXFLAGS=-Wall -g -O2 -march=native
.PHONY: all
all: example
example: example.cpp
$(CXX) -o $@ $(CXXFLAGS) -fsycl -fsycl-targets=spir64_x86_64 $<
.PHONY: clean
ivan-pi / axpy.fypp
Created February 1, 2024 08:26
#:block parallel_for(d=1,name="axpy")
#:contains args
a, x, y
#:contains range
#:contains params
real, value :: a
real, intent(in) :: x(n)
real, intent(inout) :: y(n)
integer :: i
ivan-pi / test_banded.f90
Last active November 6, 2023 10:30
Banded system of linear equations solved using "gbsv" driver from LAPACK (Intel MKL)
!LINK="${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl"
!INC="-I${MKLROOT}/include/intel64/lp64/ -I${MKLROOT}/include/"
!ifort -O3 -warn all -o test_banded $INC test_banded.f90 $LINK
program test_banded
use lapack95, only: gbtrf, gbtrs, gbsv
use f95_precision, only: wp => dp
implicit none
integer, parameter :: kl = 2, ku = 1
ivan-pi /
Last active October 29, 2023 11:50
Diffusion in a shrinking cylinder using FEM
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
from math import sqrt
from scipy.integrate import solve_ivp
def l1kw(a,b):
"""Lobatto quadrature using 2 knots (trapezoid-like)"""
ivan-pi /
Created September 15, 2023 14:13
Cylindrical diffusion solver with uncertainty quantification campaign
from easyvvuq.actions import CreateRunDirectory, Encode, Decode
from easyvvuq.actions import CleanUp, ExecuteLocal, Actions
params = {
"max_time": {"type": "float", "default": 1.5 },
"alpha": {"type": "float"},
"outfile": {"type": "string", "default": "output.json"}
ivan-pi / qtree_example.f90
Created December 8, 2020 12:56
Quadtree example in Fortran with gnuplot output
module quadtree
! Adapted from the tutorial at
implicit none
integer, parameter :: wp = kind(1.0d0)
type :: qtnode
real(wp) :: c(2)
ivan-pi / LC-3.asm
Last active July 15, 2023 20:50
LC-3 Assembly Language definition for customasm
; LC3 Instruction Set Assembly for customasm (
; References:
; Patt, Yale N.; Patel, Sanjay (2003). Introduction to Computing Systems:
; From Bits and Gates to C and Beyond. New York, NY: McGraw-Hill Higher
; Education. ISBN 0-07-246750-9.
#bankdef lc3_bank
ivan-pi / csr_example.cpp
Last active June 18, 2023 22:38
CSR SpMV with oneAPI
// compile with:
// icpx -fsycl csr_example.cpp
#include <algorithm>
#include <oneapi/mkl.hpp>
#include <CL/sycl.hpp>
int main(int argc, char const *argv[])
ivan-pi / boyd_bvp_example.f90
Created March 18, 2019 00:59
Code example from book "Chebyshev and Fourier Spectral Methods" by John P. Boyd
program boyd_bvp
dimension xi(20),aphi(20),g(20),h(20,20),ugraph(101)
pi = 4.*atan(1.0)
! specify parameters
ivan-pi / cxxfi.hpp
Last active February 23, 2023 08:38
Example of calling Fortran from C++ using the enhanced C/Fortran interoperability
#pragma once
#include <complex>
#include <vector>
#include <array>
#include <type_traits>
#include <span> // C++ 20
#include <iostream>