Skip to content

Commit ebaac48

Browse files
Fix a ambigious reference to event_profiling (#1150)
* Fix a ambigious reference to event_profiling * Fix some ordering issues * Minor fixes
1 parent 3677167 commit ebaac48

File tree

1 file changed

+26
-24
lines changed
  • DirectProgramming/DPC++FPGA/Tutorials/Features/pipes/src

1 file changed

+26
-24
lines changed

DirectProgramming/DPC++FPGA/Tutorials/Features/pipes/src/pipes.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
using namespace sycl;
1212

13-
using ProducerToConsumerPipe =
14-
ext::intel::pipe< // Defined in the SYCL headers.
15-
class ProducerConsumerPipeId, // An identifier for the pipe.
16-
int, // The type of data in the pipe.
17-
4>; // The capacity of the pipe.
13+
using ProducerToConsumerPipe = ext::intel::pipe< // Defined in the SYCL headers.
14+
class ProducerConsumerPipeId, // An identifier for the pipe.
15+
int, // The type of data in the pipe.
16+
4>; // The capacity of the pipe.
1817

1918
// Forward declare the kernel names in the global scope.
2019
// This FPGA best practice reduces name mangling in the optimization reports.
@@ -41,7 +40,6 @@ event Producer(queue &q, buffer<int, 1> &input_buffer) {
4140
return e;
4241
}
4342

44-
4543
// An example of some simple work, to be done by the Consumer kernel
4644
// on the input data
4745
int ConsumerWork(int i) { return i * i; }
@@ -80,7 +78,7 @@ int main(int argc, char *argv[]) {
8078
#else
8179
size_t array_size = 1 << 20;
8280
#endif
83-
81+
8482
// allow the user to change the buffer size at the command line
8583
if (argc > 1) {
8684
std::string option(argv[1]);
@@ -98,7 +96,7 @@ int main(int argc, char *argv[]) {
9896
std::vector<int> consumer_output(array_size, -1);
9997

10098
// Initialize the input data with random numbers smaller than 46340.
101-
// Any number larger than this will have integer overflow when squared.
99+
// Any number larger than this will have integer overflow when squared.
102100
constexpr int max_val = 46340;
103101
for (size_t i = 0; i < array_size; i++) {
104102
producer_input[i] = rand() % max_val;
@@ -119,7 +117,7 @@ int main(int argc, char *argv[]) {
119117
// create the device queue with SYCL profiling enabled
120118
queue q(device_selector, fpga_tools::exception_handler, props);
121119

122-
// create the
120+
// create the producer and consumer buffers
123121
buffer producer_buffer(producer_input);
124122
buffer consumer_buffer(consumer_output);
125123

@@ -143,23 +141,27 @@ int main(int argc, char *argv[]) {
143141
std::terminate();
144142
}
145143

146-
// At this point, the producer_buffer and consumer_buffer have gone out
147-
// of scope. This will cause their destructors to be called, which will in
144+
// At this point, the producer_buffer and consumer_buffer have gone out
145+
// of scope. This will cause their destructors to be called, which will in
148146
// turn block until the Producer and Consumer kernels are finished and the
149147
// output data is copied back to the host. Therefore, at this point it is
150148
// safe and correct to access the contents of the consumer_output vector.
151149

152-
// print profiling information
153-
// alias the 'info::event_profiling' namespace to save column space
154-
using syclprof = info::event_profiling;
155-
156150
// start and end time of the Producer kernel
157-
double p_start = producer_event.get_profiling_info<syclprof::command_start>();
158-
double p_end = producer_event.get_profiling_info<syclprof::command_end>();
151+
double p_start =
152+
producer_event
153+
.get_profiling_info<sycl::info::event_profiling::command_start>();
154+
double p_end =
155+
producer_event
156+
.get_profiling_info<sycl::info::event_profiling::command_end>();
159157

160158
// start and end time of the Consumer kernel
161-
double c_start = consumer_event.get_profiling_info<syclprof::command_start>();
162-
double c_end = consumer_event.get_profiling_info<syclprof::command_end>();
159+
double c_start =
160+
consumer_event
161+
.get_profiling_info<sycl::info::event_profiling::command_start>();
162+
double c_end =
163+
consumer_event
164+
.get_profiling_info<sycl::info::event_profiling::command_end>();
163165

164166
// the total application time
165167
double total_time_ms = (c_end - p_start) * 1e-6;
@@ -178,12 +180,12 @@ int main(int argc, char *argv[]) {
178180
std::cout << "Profiling Info\n";
179181
std::cout << "\tProducer:\n";
180182
std::cout << "\t\tStart time: " << 0 << " ms\n";
181-
std::cout << "\t\tEnd time: +" << (p_end-p_start)*1e-6 << " ms\n";
182-
std::cout << "\t\tKernel Duration: " << (p_end-p_start)*1e-6 << " ms\n";
183+
std::cout << "\t\tEnd time: +" << (p_end - p_start) * 1e-6 << " ms\n";
184+
std::cout << "\t\tKernel Duration: " << (p_end - p_start) * 1e-6 << " ms\n";
183185
std::cout << "\tConsumer:\n";
184-
std::cout << "\t\tStart time: +" << (c_start-p_start)*1e-6 << " ms\n";
185-
std::cout << "\t\tEnd time: +" << (c_end-p_start)*1e-6 << " ms\n";
186-
std::cout << "\t\tKernel Duration: " << (c_end-c_start)*1e-6 << " ms\n";
186+
std::cout << "\t\tStart time: +" << (c_start - p_start) * 1e-6 << " ms\n";
187+
std::cout << "\t\tEnd time: +" << (c_end - p_start) * 1e-6 << " ms\n";
188+
std::cout << "\t\tKernel Duration: " << (c_end - c_start) * 1e-6 << " ms\n";
187189
std::cout << "\tDesign Duration: " << total_time_ms << " ms\n";
188190
std::cout << "\tDesign Throughput: " << throughput_mbs << " MB/s\n";
189191
std::cout << "\n";

0 commit comments

Comments
 (0)