⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test14.c

📁 shpf 1.9一个并行编译器
💻 C
字号:

//   !hpf$ processors p(3, 2)
// 
//   !hpf$ template t(30, 30)
//   !hpf$ distribute t(block, block) onto p
// 
//   integer a(5, 6)
//   !hpf$ align a(i, j) with t(6 * i, 5 * j)
// 
//   integer i, j
// 
//   do i = 1, 5
//     do j = 1, 6
//       a(i, j) = 10 * i + j
//     enddo
//   enddo
// 
//   do i = 1, 5
//     print "(10i4)", a(i, : )
//   enddo
// 
//   print *
// 
//   a = cshift(a, 2, 1)
//   
//   do i = 1, 5
//     print "(10i4)", a(i, : )
//   enddo
// 
//   print *
// 
//   a = cshift(a, 2, 2)
//   
//   do i = 1, 5
//     print "(10i4)", a(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), BLK) ;

  Range x = t1.subrng(5, 5, 6) ;
  Range y = t2.subrng(6, 4, 5) ;

  Array2<int> a(p, x, y), result(p, x, y) ;

  on(p) {
    where(x) {
      where(y) {
	a(x, y) = 10 * (x + 1) + y + 1 ;
      } erewh(y) ;
    } erewh(x) ;
  } no(p) ;

  aprintf("%4d%*N", a, y.size()) ;
  gprintf("\n") ;

  shift(result, a, 2, 0, CYCL) ;
  copy(a, result) ;
  
  aprintf("%4d%*N", a, y.size()) ;
  gprintf("\n") ;

  shift(result, a, 2, 1, CYCL) ;
  copy(a, result) ;
  
  aprintf("%4d%*N", a, y.size()) ;

  AdlibFinalize() ;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -