并行串流访问 - 2023.2 简体中文

AI 引擎内核与计算图编程指南 (UG1079)

Document ID
UG1079
Release Date
2023-12-04
Version
2023.2 简体中文

AI 引擎能够并行使用两个串流输入或两个串流输出。

为了指引工具使用并行串流,请使用 aie_stream_resource_inaie_stream_resource_out 注解搭配不同的枚举值,例如,使用 aie_stream_resource_in::aaie_stream_resource_in::b 作为输入串流。例如:
void vect_mul(input_stream<int8>* __restrict data1, input_stream<int8>* __restrict data2,
      output_stream<int8>* __restrict out){
  while(true)
  chess_prepare_for_pipelining
  chess_loop_range(8,)
  {
    aie::vector<int8,16> va_int8=readincr_v<16,aie_stream_resource_in::a>(data1);
    aie::vector<int8,16> vb_int8=readincr_v<16,aie_stream_resource_in::b>(data2);
    auto vc=aie::mul(va_int8,vb_int8);

    // Avoid the write instruction to occur at the same cycle as the readincr of data1
    writeincr<aie_stream_resource_out::a>(out,vc.to_vector<int8>(0));

    va_int8=readincr_v<16,aie_stream_resource_in::a>(data1);
    vb_int8=readincr_v<16,aie_stream_resource_in::b>(data2);
    vc=aie::mul(va_int8,vb_int8);

    // This writeincr can be scheduled as soon as possible 
    // as there is the __restrict keyword in function signature
    writeincr(out,vc.to_vector<int8>(0));
  }
}

同样,aie_stream_resource_out::aaie_stream_resource_out::b 可用于表示两条并行输出串流。