主页

Shell多进程执行脚本

背景 要操作一个按行分割的大文件, 单进程跑比较慢, 这时候用多进程的方式来做, 需要先分割这个大文件, 然后逐进程处理, 需要保证行格式一致并且任务之间相对独立. shell 中可以用 split 分割这个大文件, 然后脚本需要批量读取分割好的小文件用于多进程处理, shell 的具名管道和文件描述符操作可以很好地实现这一点.  [optional] split 大文件 input_file=20241120_update input_file_line_num=$(wc -l $input_file) split_file_num=$(($input_file_line_num / 25000)) ## 整除  output_dir=${input_file%_*} ...

阅读更多

Godot,gdsdecomp在macos下编译

写在前面 用的最新的master 代码 https://github.com/godotengine/godot.git https://github.com/GDRETools/gdsdecomp.git brew install scons dotnet-sdk 需要把gdsdecomp 克隆到modules/gdsdecomp里面 ==> sh misc/scripts/install_vulkan_sdk_macos.sh ==> vi modules/gdsdecomp/SCsub +78 ##env_gdsdecomp.Append(CPPDEFINES=["ENABLE_3_X_SCENE_LOADING"]) scons p...

阅读更多

Bank conflict分析解决

写在前面 cuda 硬件: 存储视角 https://zhuanlan.zhihu.com/p/4746910252 写的真好 warp是SM的基本执行单元,一个block内相邻的32个线程划分为一个warp,一个warp内的32个线程按照SIMT的模式来执行指令。 Cuda shared memory按照4字节一个bank,总共32个bank(128字节)来组织,其store和load操作在一定情况下存在bank conflict的情况: 不同的线程访问同一bank的不同address时就会出现bank conflict。 bank conflict只发生在同一个warp的不同线程间。 如果多个线程访问shared memory的相同bank的相同a...

阅读更多

Libtorch 运行示例

写在前面 学习 torch 源码 doc; libtorch-2.9; #include <torch/torch.h> #include <iostream> int main() { // 创建张量 torch::Tensor tensor = torch::rand({2, 3}); std::cout << "随机张量:\n" << tensor << std::endl; // 基本运算 torch::Tensor a = torch::ones({2, 2}); torch::Tensor b = torch::eye(2); torc...

阅读更多

Latex绘制 shfl_xor_sync 洗牌函数示意图

写在前面 学习 CUDA 的束内洗牌函数__shfl_*_sync 比较感兴趣这里面的示意图怎么绘制的. 下面是用 tikz 的一些方式 __shfl_sync \documentclass[tikz,border=10pt,convert={density=500,outext=.jpg}]{standalone} \usepackage{tikz} \usetikzlibrary{positioning, arrows.meta} \begin{document} \begin{tikzpicture}[ thread/.style={rectangle,draw,minimum width=0.5cm,minimum height=0.5cm, ...

阅读更多

Cuda之wrap内洗牌函数与高效归约算法实现

写在前面 最近看了leetcuda 的 softmax kernel, 发现里面用到了很多的__shfl 开头的内部函数, 而不是像之前看的书中提到的用两步__syncthreads() . 自测发现效果要比直接归约快不少. 于是学习一下这个函数. ref: 【CUDA编程】束内洗牌函数(Warp Shuffle Functions) - 知乎; LeetCUDA/kernels/softmax/softmax.cu at main · xlite-dev/LeetCUDA; 内部函数 __shfl_sync() 允许 warp 中的线程之间交换变量,而无需使用共享内存。交换同时发生在 warp 中的所有活动线程(使用 mask 指定),根据...

阅读更多

Python的httpserver多文件显示

写在前面 背景 总要发一些结果文件(通常是文本文件) 给 PM. 但是每次都要 拉取文件到 Mac IM软件发给同事 比较麻烦. 并且每次要保存一份副本. 此时可以在物理机启动一个 httpserver, 然后每次共享链接即可 (内网开放端口在 8000-9000) 方法 ref: python http.server网页打开txt乱码问题解决_txt导入网页变乱码-CSDN博客 nohup python3 -c from http.server import test, SimpleHTTPRequestHandler as RH; RH.extensions_map={k:v+';charset=UTF-8' for k,v in RH.exte...

阅读更多

Python的httpserver优化文件传递

写在前面 一般来说, 如果要拉取一套线上资源. 需要这样 ## 线上 nohup python3 -m http.server 40091 &> /dev/null & ## 如果没有写权限. nohup python -m SimpleHTTPServer 40091 &> /dev/null & ## 如果没有 python3 ## 本地 wget --quiet -m -np -nH -R index.html hostname:40091/{bin,conf,data,shared_lib} 但是如果线上资源中已经有了 index.html(可能是之前上线时候忘记删掉了. 但是后续又新增了文件. 这就导致拉取文件缺失了. ...

阅读更多

Total views.
您是Zorch的第 个小伙伴
Hits