高性能计算网络与数值线性代数问题求解环境
立即解锁
发布时间: 2025-08-25 01:06:52 阅读量: 1 订阅数: 9 


并行与分布式处理手册核心内容解析
# 高性能计算网络与数值线性代数问题求解环境
## 1. HIPPI - PH 模式下的数据接收与处理
### 1.1 HIPPI - PH 模式数据接收原理
在 HIPPI - PH 模式下,当设备文件以只读方式打开时,所有传入的数据都会被接收,HIPPI 子系统不会拒绝任何连接请求。应用程序通过特定的调用函数来检索数据,所有的 `read()` 函数会顺序检索接收到的数据。如果数据包包含 FP 头部和 D1 数据,HIPPI 子系统不会对它们进行解析,也不会将它们与 D2 数据分离,因此第一次 `read()` 可能会包含 FP 头部、D1 数据和/或 D2 数据。
为了确定数据包的边界,应用程序可以使用 `ioctl()` 调用函数来检索数据包的当前偏移量(已接收的字节数)。当返回值为 0 时,下一次 `read()` 将检索新数据包的第一个字节。所有应用程序的 `read()` 函数都必须指定 8 字节字对齐的缓冲区,并且数据字节数必须是 8 的倍数。具体操作代码如下:
```c
offset = ioctl (fd_hippi0, HIPIOCR_PKT_OFFSET);
/*when 0, nxt read is new pkt*/
read (fd_hippi0, buffer, size);
offset = ioctl (fd_hippi0, HIPIOCR_PKT_OFFSET);
/*when 0, nxt read is new pkt*/
read (fd_hippi0, buffer, size);
```
当应用程序希望停止接收数据时,使用 `close(fd_hippi0)` 调用函数关闭文件描述符。
### 1.2 示例程序代码
以下是一个简单的 “HelloWorld” 程序示例,它使用 HIPPI - PH 访问方法连接到目标主机并从缓冲区发送数据:
```c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/hippi.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#define I_TULIP 0x01000001
#define I_ELDER 0x01000002
#define HIPPIDEV "/dev/hippi0"
/* hippi device */
#define HIPPIDST I_ELDER
/* I - field value of the destination host*/
int n;
int pktsize, npkts;
int hip; /* file descriptor */
char *buf; /* buffer */
main(int argc, char *argv[]) {
pktsize = 2000;
npkts = 10;
buf = memalign(8, pktsize);
/* set the buffer size equal to 8 bytes */
int nread;
hip = open(HIPPIDEV, O_RDONLY);
/* open hippi device */
ioctl(hip, HIPIOC_BIND_ULP, HIPPI_ULP_PH);
/* access method HIPPI - PH */
read(hip, buf, pktsize);
/* wait for the first packet */
for (n = 0; n < npkts; n++) {
nread = read(hip, buf, pktsize);
/* receive the rest of the packets */
}
close(hip);
/* close hippi device*/
hip = open(HIPPIDEV, O_WRONLY);
/* open hippi device */
ioctl(hip, HIPIOC_BIND_ULP, HIPPI_ULP_PH);
/* access method HIPPI - PH */
ioctl(hip, HIPIOCW_CONNECT, HIPPIDST);
/* connect to destination host*/
strcpy(buf, "Hello world!");
write(hip, buf, pktsize);
/* send the first packet */
for (n = 0; n < npkts; n++) {
write(hip, buf, pktsize);
/* send the rest of the packets */
}
ioctl(hip, HIPIOCW_DISCONN);
/* disconnect */
close(hip);
/* close the device */
}
```
### 1.3 高性能计算网络的未来发展
当前通信系统的发展愿景可以通过观察和整合一些关于通信当前应用的重要事实来精确界定。如今,光纤是通信系统的主要传输介质,但其利用率甚至未达到理论容量的 10%。单处理器的计算能力达到了 1000 MIPS 或 1Gflops,超级计算机的 I/O
0
0
复制全文
相关推荐










