Cuda核函数的定义与参数
CUDA 核函数参数的配置CUDA execution-configuration;
Any call to a __global__ function must specify the execution configuration for that call. The execution configuration defines the dimension of the grid and blocks that will be used to execute the function on the device, as well as the associated stream (see CUDA Runtime for a description of streams)...
矩阵乘法基础cuda实现
写在前面
学一下 CUDA. 关键在于并行思维. 当然还要了解一些矩阵/线性代数相关的内容, 还有算法/深度学习的一些公式的推导. 这里先做一下 leetgpu 里面的第二题. 矩阵乘法.
https://leetgpu.com/challenges/matrix-multiplication
$M\times N$的矩阵 A 还有$N\times K$的矩阵 B 相乘, 得到$M\times K$ 的矩阵 C. 用 CUDA 实现. 传入的就是每一个矩阵线性化之后的一维数组.
基本实现
#include <cuda_runtime.h>
__global__ void matrix_multiplication_kernel(const float* ...
编辑距离与进阶题型解析
工具函数
#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (auto x : v) {
os << x << "\t";
}
os << '\n';
return os;
}
template <typename T>
ostream& operator<<(ostream& os,...
Lcs 的几种写法与回溯找lcs 字符串
https://leetcode.cn/problems/longest-common-subsequence/description/?envType=problem-list-v2&envId=dynamic-programming
ref https://leetcode.cn/problems/longest-common-subsequence/solutions/2133188/jiao-ni-yi-bu-bu-si-kao-dong-tai-gui-hua-lbz5
””
a
c
e
””
0
...
Shell的炫酷效果peace for all
写在前面
在 xhs 看到了一个有意思的图片, 想试试能不能把内容反解出来. (后来还是求助了大模型 hh)
shell 源码
Linux/MacOS 下运行良好.
#!/bin/bash
text=" PEACE FOR ALL PEACE FOR ALL "
# 获取终端尺寸
cols=$(tput cols)
lines=$(tput lines)
text_length=${#text}
# 频率和幅度控制
freq=0.3
amplitude=10
# 隐藏光标,恢复时清屏
tput civis
trap "tput cnorm; clear; exit" SIGINT
# 无限动画循环
for (( t = 0; ; t++ )); ...
Macos Virtual Machine Benchmark
写在前面
环境
macOS 15.5
xcode 26beta
M2 16GB
container run -it --arch amd64 --name fedora_amd fedora
container start fedora_amd
container exec -it fedora_amd bash
测试命令
==> sysbench --version
sysbench 1.0.20
# 单核性能
sysbench cpu --cpu-max-prime=20000 --threads=1 run
# 多核性能
sysbench cpu --cpu-max-prime=20000 --threads=4 run
指标
CPU spee...
共计 478 篇文章,60 页。
您是Zorch的第 个小伙伴
Hits