【高性能计算】常用工具命令

Linux常用命令

机器查询

whoami
hostname // ln0 logging node 0 cn10 compute node 10
lscpu
free -h //看内存

文件

ls
ls -l // 列表
ls -ltr // 时间倒序
ls *na* //
mkdir 
rm -rf
pwd
cd.. cd,
cd- cd~
touch
mv 
cp -r ./hh ./ 

查找

find ./src -name main.cpp
grep "include" -r ./*.cpp
cat -n makefile
head/tail -n/-f makefile
more makefile // 翻页
enter/q

压缩

tar -cvf jpg.tar *.jpg
tar -czf jpg.tar.gz *.jpg
tar -xf jpg.tar
tar -zxf jpg.tar.gz
zip jpg.zip *.jpg
unzip jpg.zip

环境变量

em //系统变量
echo $PATH
export PATH=/thfs1/home/bin:$PATH // 要衔接后面的环境变量

Vim文件编译

// 跳转
:1  
:$
// 离开编译器
:wq 
:q!
// 替换
s,:
:%s/n/m/g
v
dd
o
shife 1

GCC套件

// 1. 一步到位
gcc -o Helloworld main.c
// 2. 分步
g++ -o Hello.o -c main.cpp
g++ Hello.o -o exe -L -L
g++ -I[头文件位置] hello.c -o Helloworld
// 3. cflag可选选项
-O0
-g
-Wall //warning
-pg //gprof
-D
// 4. 静态链接库 -I库的位置 静态库
gcc -I/thfs1/home.../include cblas_sample.c -o cblas_sanple_static /thgs1/home.../lib/libcblas.a .../lib/libcblas.a -lgfortan
// 5. 动态链接库 -I库的位置 -L动态库搜索路径 -l链接这个库
// BLAS(fortan) LAPACK(BLAS底层) CBLAS
gcc -I/thfs1/home.../include cblas_sample.c -o cblas_sanple_shared -L/thfs1/home.../lib -lcblas
yhrun -N 1 -n 1 -p thcp1 ./cblas_sanple_static 
yhrun -N 1 -n 1 -p thcp1 ./cblas_sanple_shared
// 6. 动态库加入搜索路径
env | grep LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/thfs1/.../lib

Makefile

BIN=hello //最终的二进制文件
OBJ=main.o myfunc.o // 中间生成的object
SRC=hello.cpp
CFLAGS=-O0
cxx=g++
all:$(BIN)
$(BIN):$(SRC)
	$(cxx) $(CFLAGS) $(OBJ) -o $(BIN)
%.o:%.c
	$(cxx) $(CFLAGS) -c $< -o $@
// 上述等价
main.o:main.cpp
	$(cxx) $(CFLAGS) -c $< -o $@
myfunc.o:myfunc.cpp
	$(cxx) $(CFLAGS) -c $< -o $@
// 不会检查伪目标更新
`PHONY:clean
clean:
	rm -rf *.o $(BIN) 

SLURM

// 1. 节点 总进程 进程使用处理器个数
yhrun -N 1 -n 1 -p thcp1 ./exe
// 2. batch
vim run.sh
$./bin/bash
yhrun -N 1 -n 1 -p thcp1 ./exe
:wq!
yhbatch -p thcp1 run.sh
// 3. 
yhque
yhcancel 2209382

GDB

g++ -O0 -g -o exe file.cpp
gdb ./exe
ls
// 1. 打断点
b file.cpp:20 
// 2. 运行
r 
// 3. 打印
p n 
p sum
p &n
// 4. 步进
s
// 5. 退出当前函数
finish
// 6. 一行一行运行
n
// 7. 看n的变化
watch n
set args
// 8. 崩溃产生core
ulimit -c unlimited
// 9.程序调用
bt


Cmake

mkdir build
cd build
// 宏定义 安装目录 静态/动态 编译cblas
Cmake -DCMAKE_INSTALL_PREFIX=... -DBUILD_SHARED_LIBS=ON -DCBLAS=ON
// 指定上级目录,自动找到cmakelists,会生成makefile
// 并行多核编译
make -j 4 

程序性能分析

静态分析:understand

动态分析gprof

g++ -pg main.cpp -o main
yhrun -N 1 -n 1 -p thcp1 ./main
gprof main gmon.out > out.txt
vim out.txt
python 2 gprof2dot.py out.txt | dot -Tpng -o output.png
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值