Skip to content

Instantly share code, notes, and snippets.

View ZenanH's full-sized avatar
🔋
Charging

Zenan Huo ZenanH

🔋
Charging
View GitHub Profile
@ZenanH
ZenanH / wezterm.lua
Last active October 6, 2025 08:51
Wezterm config
local wezterm = require 'wezterm'
local config = wezterm.config_builder()
config.automatically_reload_config = true
config.disable_default_key_bindings = true
config.default_prog = { '/bin/zsh'}
-- >> APPEARANCE ---------------------------------------------------------------------------
using Adapt
using CUDA
using KernelAbstractions
struct KernelData{T1, T2, T3<:AbstractArray, T4<:AbstractArray}
scalar1 ::T1
scalar2 ::T2
mass ::T3
velocity::T4
end
@ZenanH
ZenanH / readmsh.jl
Last active December 18, 2024 13:36
Gmsh in julia
using Gmsh
"""
readmsh(msh_path::String; precision="FP32")
Description:
---
Read the mesh file (`.msh`) generated by Gmsh. The function will return the vertices and
faces for triangle. It's necessary to check the mesh qulity before using this function.
You can do it in MeshLab or Gmsh GUI. `precision` can be "FP64" or "FP32" in `String`.
"""
@ZenanH
ZenanH / test.jl
Last active May 8, 2024 16:37
Register Pressure
using KernelAbstractions
using CUDA
using BenchmarkTools
@inline function uGIMPbasis(Δx::T2, h::T2, lp::T2) where T2
T2 == Float32 ? T1 = Int32 :
T2 == Float64 ? T1 = Int64 : nothing
absΔx = abs(Δx); signΔx = sign(Δx)
c1 = absΔx<(T2(0.5)*lp)
c2 = (T2(0.5)*lp)≤absΔx<(h-T2(0.5)*lp)
@ZenanH
ZenanH / t10.jl
Created February 28, 2024 16:09
Allreduce() with CUDA-aware MPI
using MPI
using CUDA
using NVTX
function main()
MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
CUDA.device!(rank)
n = 263374721
using MPI
using CUDA
using Printf
function print_aligned_matrix_with_color(matrix::Array{String,2})
@info "MPI GPU Unidirectional P2P Bandwidth Test [GB/s]"
col_widths = [maximum(length.(matrix[:, i])) for i in 1:size(matrix, 2)]
for row in 1:size(matrix, 1)
for col in 1:size(matrix, 2)
if row == 1 || col == 1
@ZenanH
ZenanH / bash-colors.md
Created May 8, 2023 20:47 — forked from JBlond/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@ZenanH
ZenanH / makie.jl
Last active September 2, 2023 18:58
Makie.jl for a publication
using CairoMakie
pub_font_size = 10
figfont = "CMU Serif"
figuretheme = Theme(
Figure = (
font = figfont,
fontsize = pub_font_size
),