README.md 2.85 KB
Newer Older
wangkaixiong's avatar
update  
wangkaixiong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# FSL-components

---

- [fsl-eddy 编译](#fsl-eddy编译)

- [fsl-ptx2-cuda 编译](#fsl-ptx2-cuda编译)

---


### fsl-eddy编译

[回到文档开头](#)  fsl编译:
wangkx1's avatar
change  
wangkx1 committed
15

wangkx1's avatar
wangkx1 committed
16
17
快速开始:

wangkaixiong's avatar
update  
wangkaixiong committed
18
19
```shell
git clone http://developer.sourcefind.cn/codes/tsoc/fsl-components.git
wangkx1's avatar
wangkx1 committed
20
21
# 注意点:使用之前确保DTK没有激活 cuda 环境

wangkaixiong's avatar
update  
wangkaixiong committed
22
23
24
使用:fsl-components/FSL-install-config/config  覆盖真正的  FSL-install/config

cd fsl-eddy
wangkx1's avatar
wangkx1 committed
25
26
27
28
29
30
bash compile.sh
```




wangkx1's avatar
change  
wangkx1 committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
基于 2401.2 版本,实现hip转码。配合 6.0.7.19 的 FSL 可以在DCU上正常运行

在这里分享下 hip 转码 的经验;

1、基于 DTK-25.04.1 完成转码以及 FSL 工程的适配;

```bash
hipconvertinplace-perl.sh fsl-eddy/cuda
```
cuda 文件夹下原有的代码,转码后以 org-name.h/cu.prehip 形式存储在当前目录

由于要使用hip编译, 因此所有的 cu 后缀, 修改为 hip 或者 cpp;

2、对应Makefile, 所有的 cu 后缀, 修改为 hip 或者 cpp;

cudabuild/cuda${CUDA_VER}/%.o: cuda/%.cu ==>  cudabuild/cuda${CUDA_VER}/%.o: cuda/%.cpp

原有的nvcc 编译器修改为 hipcc

3、代码中编译的问题解决:

- CublasHandleManager.h

```cpp
#if !defined(ROCM_SYMLINK_HIPBLAS_H)
#error hipblas.h must be included at the very top of any file including CublasHandleManager.h
#endif

 CUBLAS_V2_H_ 更改为  ROCM_SYMLINK_HIPBLAS_H
```

- 增加文件: math_constants.h

- EddyMatrixKernels.cpp 中不支持 min 的问题解决

```bash
__global__ void QR(// Input
		   const float  *K,     // Row-first matrices to decompose
		   unsigned int m,      // Number of rows of K
		   unsigned int n,      // Number of columns of K
		   unsigned int nmat,   // Number of matrices
		   // Output
		   float        *Qt,    // nmat mxm Q matrices
		   float        *R)     // nmat mxn R matrices
{
  extern __shared__ float scratch[];

  if (blockIdx.x < nmat && threadIdx.x < m) {
    unsigned int id = threadIdx.x;
    // unsigned int ntpm = min(m,blockDim.x); // Number of threads per matrix
    unsigned int ntpm = (m < blockDim.x) ? m : blockDim.x;
    float *v = scratch;
    float *w = &scratch[m];
    const float *lK = &K[blockIdx.x*m*n];
    float *lQt = &Qt[blockIdx.x*m*m];
    float *lR = &R[blockIdx.x*m*n];
    qr_single(lK,m,n,v,w,id,ntpm,lQt,lR);
  }
  return;
}
wangkx1's avatar
wangkx1 committed
91
```
wangkaixiong's avatar
update  
wangkaixiong committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


### fsl-ptx2-cuda编译


快速开始:

```shell
git clone http://developer.sourcefind.cn/codes/tsoc/fsl-components.git

注意点:使用之前确保DTK没有激活 cuda 环境

FSL-install 代表之前的 FSL 安装目录

使用 fsl-components/FSL-install-config/config  覆盖真正的 FSL-install/config

使用 fsl-ptx2-cuda-11.0 替换 FSL-install/src 之中的 fsl-ptx2-cuda-11.0

cd FSL-install/src/fsl-ptx2-cuda-11.0

source /opt/dtk/cuda/env.sh
make cpu=1 gpu=1 -j$(nproc)
make install

即可得到适配DCU的  FSL-install/bin/probtrackx2_gpu11.8

测试之前, 激活 cuda 环境
source /opt/dtk/cuda/env.sh


```