Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Set line buffering mode for stderr for some assert tests #872

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SYCL/Assert/assert_in_simultaneous_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// RUN: %ACC_RUN_PLACEHOLDER %t.out &> %t.txt
// RUN: %ACC_RUN_PLACEHOLDER FileCheck %s --check-prefix=CHECK-ACC --input-file %t.txt
//
// CHECK: {{.*}}assert_in_simultaneous_kernels.hpp:12: void assertFunc(): global id: [9,7,0], local id: [0,0,0]
// CHECK: {{.*}}assert_in_simultaneous_kernels.hpp:13: void assertFunc(): global id: [9,7,0], local id: [0,0,0]
// CHECK-SAME: Assertion `false && "from assert statement"` failed.
// CHECK-NOT: The test ended.
//
// CHECK-ACC-NOT: {{.*}}assert_in_simultaneous_kernels.hpp:12: void assertFunc(): global id: [9,7,0], local id: [0,0,0]
// CHECK-ACC-NOT: {{.*}}assert_in_simultaneous_kernels.hpp:13: void assertFunc(): global id: [9,7,0], local id: [0,0,0]
// CHECK-ACC: The test ended.

#include "assert_in_simultaneous_kernels.hpp"
10 changes: 10 additions & 0 deletions SYCL/Assert/assert_in_simultaneous_kernels.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <CL/sycl.hpp>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <thread>

Expand Down Expand Up @@ -44,6 +45,15 @@ void runTestForTid(queue *Q, size_t Tid) {
}

int main(int Argc, const char *Argv[]) {
// On windows stderr output becomes messed up if several thread
// output simultaneously. Hence, setting explicit line buffering here.
#ifndef __SYCL_DEVICE_ONLY__
if (setvbuf(stderr, nullptr, _IOLBF, BUFSIZ)) {
std::cerr << "Can't set line-buffering mode fo stderr\n";
return 1;
}
#endif

std::vector<std::thread> threadPool;
threadPool.reserve(NUM_THREADS);

Expand Down
4 changes: 2 additions & 2 deletions SYCL/Assert/assert_in_simultaneous_kernels_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
//
// FIXME Windows version prints '(null)' instead of '<unknown func>' once in a
// while for some insane reason.
// CHECK: {{.*}}assert_in_simultaneous_kernels.hpp:12: {{<unknown func>|(null)}}: global id: [9,7,0], local id: [0,0,0]
// CHECK: {{.*}}assert_in_simultaneous_kernels.hpp:13: {{<unknown func>|(null)}}: global id: [9,7,0], local id: [0,0,0]
// CHECK-SAME: Assertion `false && "from assert statement"` failed.
// CHECK-NOT: The test ended.
//
// CHECK-ACC-NOT: {{.*}}assert_in_simultaneous_kernels.hpp:12: {{<unknown func>|(null)}}: global id: [9,7,0], local id: [0,0,0]
// CHECK-ACC-NOT: {{.*}}assert_in_simultaneous_kernels.hpp:13: {{<unknown func>|(null)}}: global id: [9,7,0], local id: [0,0,0]
// CHECK-ACC: The test ended.

#include "assert_in_simultaneous_kernels.hpp"
10 changes: 10 additions & 0 deletions SYCL/Assert/assert_in_simultaneously_multiple_tus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "Inputs/kernels_in_file2.hpp"
#include <CL/sycl.hpp>
#include <cstdio>
#include <iostream>
#include <thread>

Expand Down Expand Up @@ -82,6 +83,15 @@ void runTestForTid(queue *Q, size_t Tid) {
}

int main(int Argc, const char *Argv[]) {
#ifndef __SYCL_DEVICE_ONLY__
// On windows stderr output becomes messed up if several thread
// output simultaneously. Hence, setting explicit line buffering here.
if (setvbuf(stderr, nullptr, _IOLBF, BUFSIZ)) {
std::cerr << "Can't set line-buffering mode fo stderr\n";
return 1;
}
#endif

std::vector<std::thread> threadPool;
threadPool.reserve(NUM_THREADS);

Expand Down