Intel® Advisor User Guide

ID 766448
Date 3/22/2024
Public
Document Table of Contents

Support for SYCL

Flow Graph Analyzer is a feature of Intel® Advisor that allows you to explore, debug, and analyze graph computation problems. Since the SYCL* runtime constructs an asynchronous task graph from submitted work, Flow Graph Analyzer allows you to visualize and interact with the asynchronous task graph, and its execution traces. The tool introduces the following features:

  • For a CPU device: Execution trace-based analytics.
  • For CPU and GPU devices: Graph-related analytics.
NOTE:

The data collection support for SYCL applications is currently supported only on Linux* OS.

The code sample below illustrates a simple example of a SYCL application that adds two vectors. The subsequent sections will use it as an example.

#include <CL/sycl.hpp>
#include <iostream>

#define VECTOR_SIZE 16384

using namespace cl::sycl;

void vec_add(queue &q, const float A[], const float B[], float C[],
             const int size) {
  // Create the buffers
  buffer<float, 1> bufA(A, range<1>(VECTOR_SIZE));
  buffer<float, 1> bufB(B, range<1>(VECTOR_SIZE));
  buffer<float, 1> bufC(C, range<1>(VECTOR_SIZE));

  q.submit([&](handler &cgh) {
    auto Acc = bufA.get_access<access::mode::read>(cgh);
    auto Bcc = bufB.get_access<access::mode::read>(cgh);
    auto Ccc = bufC.get_access<access::mode::write>(cgh);
    cgh.parallel_for<class saxpy_kernel>(range<1>(size), [=](id<1> idx) {
      Ccc[idx[0]] = Acc[idx[0]] + Bcc[idx[0]];
    });
  });
}

int main(int argc, char **argv) {
  if (argc < 2) {
    std::cout << "Usage:- " << argv[0] << " [cpu, gpu]\n";
    return 1;
  }

  float A[VECTOR_SIZE], B[VECTOR_SIZE], C[VECTOR_SIZE];

  if (std::string("cpu") == argv[1]) {
    cpu_selector device;
    queue q(device);
    vec_add(q, A, B, C, VECTOR_SIZE);

  } else if (std::string("gpu") == argv[1]) {
    gpu_selector device;
    queue q(device);
    vec_add(q, A, B, C, VECTOR_SIZE);
  }

  return 0;
}