📄 test8.c
字号:
// !hpf$ processors q(2, 3)
//
// !hpf$ template s(4, 10)
// !hpf$ distribute s(block, block) onto q
//
// integer b(5, 5)
// !hpf$ align b(*, j) with s(1, 8 - j)
//
// integer u(5), v(5)
// !hpf$ align u(i) with b(i, *)
// !hpf$ align v(j) with b(*, j)
//
// !hpf$ processors p(2, 3)
//
// !hpf$ template t(6, 3)
// !hpf$ distribute t(cyclic, block) onto p
//
// integer a(6, 6)
//
// !hpf$ align a(i, *) with t(i, *)
//
// integer i, j
//
// do i = 1, 5
// do j = 1, 5
// b(i, j) = 10 * (i - 1) + (j - 1)
// enddo
// enddo
//
// do i = 1, 5
// u(i) = 1 + mod((i - 1) * 11, 6)
// enddo
//
// do j = 1, 5
// v(j) = 1 + mod((j - 1) + 3, 6)
// enddo
//
// do i = 1, 6
// do j = 1, 6
// a(i, j) = 0.0
// enddo
// enddo
//
// a(u, v) = b
//
// do i = 1, 6
// do j = 1, 6
// print "(2i3, i10)", i - 1, j - 1, a(i, j)
// enddo
// enddo
//
// end
#include <iostream.h>
#include <stdio.h>
#include "ad++.h"
#include "admacros.h"
void main(int argc, char* argv[]) {
AdlibInit(argc, argv) ;
Procs2 qq(2, 3) ;
Range r(5) ;
Range s = Range(10, qq.dim(1), BLK).subrng(5, 6, -1) ;
Range t(4, qq.dim(0), BLK) ;
Group q(qq / t(0)) ;
Array2<int> b(q, r, s) ;
Array1<int> u(q, r) ;
Array1<int> v(q, s) ;
Procs2 p(3, 2) ;
Range x(6, p.dim(0), CYC) ;
Range y(6) ;
Array2<int> a(p, x, y) ;
on(q) {
where(r) {
u(r) = (r * 11) % 6 ;
where(s) {
b(r, s) = 10 * r + s ;
} erewh(s) ;
} erewh(r) ;
where(s) {
v(s) = (s + 3) % 6 ;
} erewh(s) ;
} no(q) ;
on(p) {
where(x) {
where(y) {
a(x, y) = 0 ;
} erewh(y) ;
} erewh(x) ;
} no(p) ;
vecScatter(b, a, u, v) ;
aprintf("%3R0%3R1%10d\n", a) ;
AdlibFinalize() ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -