主页

Shell打通跳板机访问剪贴板

背景 之前写了 vim 中打通开发机和 mac 剪贴板的方式, 最近突发奇想感觉直接在 shell 里面也可以实现, 下面来看看 脚本 #!/bin/bash # 检查是否有输入 if [ -t 0 ]; then echo "Usage: cat file | $0" exit 1 fi # 读取标准输入内容 content=$(cat) # 使用 base64 编码 encoded=$(echo -n "$content" | base64 -w 0) # 输出 ANSI 控制序列到终端 echo -e "\e]52;c;${encoded}\a" 使用 chmod +x copy mv copy ~/local/bin cat file_you...

阅读更多

Shell常用的提效工具,脚本

写在前面 alias 篇 export LANG="zh_CN.utf8" export LC_CTYPE="zh_CN.UTF-8" export MANPATH=/usr/local/share/man:$HOME/local/share/man:$MANPATH ulimit -c unlimited alias vi=vim alias vimdiff='vimdiff -c "windo set wrap" ' alias vb='vi ~/.bashrc' alias vt='vi ~/code/tool/linux_tool.sh' alias sb='source ~/.bashrc' alias vv="vi ~/.vimrc" alias ll="ls -a...

阅读更多

Cuda性能测试工具与 cuda 常用命令行

写在前面 cuda工具集 查询显卡的算力 nvidia-smi --query-gpu=name,compute_cap --format=csv name, compute_cap NVIDIA A10, 8.6 name, compute_cap NVIDIA L20, 8.9 nvprof 自测计时类 //utils.h #pragma once #include <chrono> #include <iostream> #include <cuda_runtime.h> using namespace std::chrono; #define CUDA_CHECK(call) ...

阅读更多

Cuda硬件基础

写在前面 常见概念与关系 一个更形象的映射: Grid ├── Block 0 │ ├── Warp 0 → 32 threads │ ├── Warp 1 → 32 threads │ └── ... ├── Block 1 │ ├── Warp 0 → 32 threads │ └── ... └── ... 在硬件执行时: 多个 block 被分配到不同的 SM 上执行 **每个 SM 内的 warp scheduler 调度 warp 级别的执行 ** **每个 warp 内的 32 个线程同时执行相同指令(SIMT) ** 软件抽象 硬件实体 特征...

阅读更多

Cuda 实现softmax与优化

写在前面 https://leetgpu.com/challenges/softmax https://leetgpu.com/challenges/softmax-attention 前置知识 safe-softmax 的原理与推导 https://arxiv.org/pdf/1805.02867 传统的 softmax 是 \(y=Softmax(x)\ \ \text{define as:}\\ y_i=\frac{e^{x_i}}{\sum\limits_{j=1}^Ve^{x_j}}\) 但是直接计算的过程中存在过大或者过小的问题. 于是有了下面的 safe-softmax \(y_i=\frac{e^{x_i-\max_{k=1}^Vx_k...

阅读更多

Cuda 实现归约 reduction 与优化

写在前面 https://leetgpu.com/challenges/reduction 可以说是 CUDA 入门的第一个算子, 对于理解并行编程比较有帮助 reduction 实现与 性能测试(CPU vs GPU) #include "utils.h" constexpr int BLOCK_SIZE = 256; __global__ void block_reduce_v1(const float* input, float* partial, int N) { __shared__ float cache[BLOCK_SIZE]; // BLOCK_SIZE must use global variable int tid = thread...

阅读更多

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* ...

阅读更多

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