---
title: 运行和验证
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengamg_02_0007.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengamg_02_0007.html
indexId: 5c6d40a74d6f92ae971e97af945a7ef527efdac7614396275d215e5ab942e87865
---
# 运行和验证

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令创建“hostfile”文件并添加节点信息。

```
echo
-e 'node1\nnode2\n…\nnodex' >
/
path/to/HOSTFILE
```


  “node1、node2、…、nodex”分别为各节点的主机名，可通过命令hostname查询各主机名，“\n”为换行符。 该步骤在多节点运行时为必须执行，单节点可跳过。

3. 执行以下命令进入“test”目录，编译后会生成“amg”二进制文件。

```
cd
/path/to/AMG
/AMG-1.2/test
```


4. 执行以下命令进入运行“amg”二进制文件。

```
mpirun --allow-run-as-root -mca btl ^openib --hostfile
/
path/to/HOSTFILE
-x OMP_NUM_THREADS=1 -x PATH -x LD_LIBRARY_PATH -N 96 amg -P 4 6 4 -n 100 100 100 -printstats
```


  “-p <Px> <Py> <Pz>”：定义每个零件的处理器拓扑，总计MPI流程为Px * Py * Pz。 “-n <nx> <ny> <nz>”：为多维数据集上的问题定义每个处理器的大小。“-n”选项允许每个MPI进程指定本地问题的大小， 导致<Px> * <nx>和<Py> * <ny>的<Pz> * <nz>的全局问题大小。 “-printstats”：打印出有关AMG预处理器的详细信息和迭代次数。 “-N”：为每个节点的任务数，且Px * Py * Pz的值必须等于-N的值乘以节点数的值。 单节点运行时执行以下命令： mpirun --allow-run-as-root -mca btl ^openib -x OMP_NUM_THREADS=1 -np 96 amg -P 4 6 4 -n 100 100 100 -printstats

  打印结果样例如下所示。

```
BoomerAMG SOLVER PARAMETERS:
Maximum number of cycles:         1
Stopping Tolerance:               0.000000e+00
Cycle type (1 = V, 2 = W, etc.):  1
Relaxation Parameters:
Visiting Grid:                     down   up  coarse
Number of sweeps:            2    2     1
Type 0=Jac, 3=hGS, 6=hSGS, 9=GE:     18   18     9
Point types, partial sweeps (1=C, -1=F):
Pre-CG relaxation (down):   0   0
Post-CG relaxation (up):   0   0
Coarsest grid:   0
=============================================
Problem 1: AMG Setup Time:
=============================================
PCG Setup:
wall clock time = 6.333697 seconds
wall MFLOPS     = 0.000000
cpu clock time  = 6.350000 seconds
cpu MFLOPS      = 0.000000
FOM_Setup: nnz_AP / Setup Phase Time: 4.452531e+08
=============================================
Problem 1: AMG-PCG Solve Time:
=============================================
PCG Solve:
wall clock time = 34.855871 seconds
wall MFLOPS     = 0.000000
cpu clock time  = 34.860000 seconds
cpu MFLOPS      = 0.000000
Iterations = 23
Final Relative Residual Norm = 6.624473e-09
FOM_Solve: nnz_AP * Iterations / Solve Phase Time: 1.860870e+09
Figure of Merit (FOM_1): 1.506966e+09
```
