AI エンジンのランタイム イベント API を使用したパフォーマンスの計測 - 2023.2 日本語

Versal アダプティブ SoC システム統合および検証設計手法ガイド (UG1388)

Document ID
UG1388
Release Date
2023-11-15
Version
2023.2 日本語

Vitis ツールまたは aiecompiler を使用してグラフをコンパイルしたら、各 AI エンジン アレイ インターフェイス (またはシム タイル) を監視して特定のイベントをカウントできます。いくつかのプロファイリング イベントを使用して、AI エンジン アレイ インターフェイス内の有効な AXI4-Stream データ トランザクションをカウントできます。API が呼び出されると、PS により一連の AXI4-MM コマンドが発行され、有効なイベントをカウントするために AI エンジン アレイ インターフェイスが設定されます。AI エンジン アレイ インターフェイスのイベント カウンターにより、システムにハードウェアを追加することなくシステムを計測できます。

注記:AI エンジン アレイ インターフェイスに含まれるパフォーマンス カウンターは 2 つのみですが、各 AI エンジン アレイ インターフェイスには 64b ストリームが 14 個あります。そのため、これらのプローブ API を使用して一度に監視できる AI エンジン-PL インターフェイスは 2 つのみです。

次の例では、io_stream_start_to_bytes_transferred_cycles イベント API を使用してグラフのスループットを計測しています。この API は、2 つのパフォーマンス カウンターを使用して転送されたバイト数とかかったサイクル数を監視します。このイベント API は、グラフを介して指定量のデータを転送する際のアクティブ、ストール、アイドル サイクルの総数を収集して算出します。この API は、入力ストリームおよび出力ストリームの両方で使用できます。

gr.init();
event::handle handle = event::start_profiling(plio_out,
event::io_stream_start_to_bytes_transferred_cycles, 256*sizeof(int32));
gr.run(8);
gr.wait();
long long cycle_count = event::read_profiling(handle);
event::stop_profiling(handle);
double throughput = (double)256 * sizeof(int32) / (cycle_count * 1e-9); //
byte per second

転送されるバイト数がわかっていない場合は、別のイベント API を使用できます。次の例では、io_stream_running_event_count イベント API を使用してグラフのスループットを計測しています。ストリームは指定の時間実行され、ストリーム アクティブ イベントの数が収集されます。

...
...
using namespace adf;
event::handle handle_0;
PLIO duc_plio[2] = {*duc_in0, *duc_out0};
d=0;
while(d < NUM_DUC_SLAVES) {
    long long throughput_out_min = 990000000; // initial value to some high number
    long long throughput_out_max = 0;
    int iter=0;
    while(iter < 5) {
        long long count_start, count_end;
        long long throughput;
        handle_0 = event::start_profiling(duc_plio[d], event::io_stream_running_event_count);
        count_start = event::read_profiling(handle_0);
        //precision of usleep is dependent on linux system call
        usleep(1000000); //1s
        count_end = event::read_profiling(handle_0);
        event::stop_profiling(handle_0);
        if (count_end > count_start) throughput = (count_end-count_start);
        else throughput = (count_end-count_start+0x100000000); //roll over correction for 32b performance counter
        if (throughput<throughput_out_min) throughput_out_min = throughput;
        if (throughput>throughput_out_max) throughput_out_max = throughput;
        iter++;
    }
    printf("[throughput] %d\tMin:%llu\tMax:%llu\tRange:%llu\n", d, throughput_out_min, throughput_out_max, throughput_out_max-throughput_out_min );
    d++;
}
printf("[main] Performance measurements Done ... \n");
...
...

詳細は、 『AI エンジン ツールおよびフロー ユーザー ガイド』 (UG1076)このセクションを参照してください。