📄 test17.c
字号:
// !hpf$ processors p(3, 2)
//
// !hpf$ template t(30, 30)
// !hpf$ distribute t(block, cyclic(10)) onto p
//
// integer a(2, 3)
// !hpf$ align a(i, j) with t(3 + 3 * i, 5 * j)
//
// integer b(2, 4)
// !hpf$ align b(*, j) with t(*, 25 - 2 * j)
//
// integer v(6)
// !hpf$ align v(j) with t(j, *)
//
// integer pad(2)
// !hpf$ align pad(j) with t(3, 27 + j)
//
// integer shape(2), order(2)
//
// integer i
//
// do i = 1, 6
// v(i) = i
// enddo
//
// pad(1) = 0
// pad(2) = 0
//
// shape(1) = 2
// shape(2) = 3
//
// a = reshape(v, shape)
//
// print *, 'a...'
// do i = 1, 2
// print "(10i4)", a(i, : )
// enddo
//
// shape(1) = 2
// shape(2) = 4
//
// order(1) = 2
// order(2) = 1
//
// b = reshape(v, shape, pad, order)
//
// print *, 'b...'
// do i = 1, 2
// print "(10i4)", b(i, : )
// enddo
//end
#include <stdio.h>
#include "ad++.h"
#include "admacros.h"
void main(int argc, char* argv[]) {
AdlibInit(argc, argv) ;
Procs2 p(3, 2) ;
Range t1(30, p.dim(0), BLK) ;
Range t2(30, p.dim(1), CYC, 10) ;
Range x = t1.subrng(2, 5, 3) ;
Range y = t2.subrng(3, 4, 5) ;
Array2<int> a(p, x, y) ;
Range i(2) ;
Range j = t2.subrng(4, 22, -2) ;
Array2<int> b(p, i, j) ;
Range k = t1.subrng(6, 0) ;
Array1<int> v(p, k) ;
Range l = t2.subrng(2, 27) ;
Group q(p / t1(2)) ;
Array1<int> pad(q, l) ;
on(p) {
where(k) {
v(k) = k + 1 ;
} erewh(k) ;
} no(p) ;
on(q) {
where(l) {
pad(l) = 0 ;
} erewh(l) ;
} no(q) ;
reshape(a, v) ;
gprintf("a...\n") ;
aprintf("%4d%*N", a, y.size()) ;
Array2<int> dst(p, j, i, b, seq(1, 0)) ; // transpose promotion
reshape(dst, v, pad) ;
gprintf("b...\n") ;
aprintf("%4d%*N", b, j.size()) ;
AdlibFinalize() ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -