Skip to content

Commit 407124b

Browse files
committed
Roll-back use of semi-random ID.
Signed-off-by: Julian Oppermann <[email protected]>
1 parent c2eb448 commit 407124b

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

sycl/source/detail/kernel_compiler/kernel_compiler_sycl.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,6 @@
99
#include "kernel_compiler_sycl.hpp"
1010
#include <sycl/exception.hpp> // make_error_code
1111

12-
#include <iomanip>
13-
#include <random>
14-
#include <sstream>
15-
16-
static std::string generateSemiUniqueId() {
17-
auto Now = std::chrono::high_resolution_clock::now();
18-
auto Milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
19-
Now.time_since_epoch());
20-
21-
// Generate random number between 10'000 and 99'900.
22-
std::random_device RD;
23-
std::mt19937 Gen(RD());
24-
std::uniform_int_distribution<int> Distrib(10'000, 99'999);
25-
int RandomNumber = Distrib(Gen);
26-
27-
// Combine time and random number into a string.
28-
std::stringstream Ss;
29-
Ss << Milliseconds.count() << "_" << std::setfill('0') << std::setw(5)
30-
<< RandomNumber;
31-
32-
return Ss.str();
33-
}
34-
3512
#if __GNUC__ && __GNUC__ < 8
3613

3714
// std::filesystem is not availalbe for GCC < 8
@@ -71,14 +48,35 @@ SYCL_to_SPIRV(const std::string &SYCLSource, include_pairs_t IncludePairs,
7148
#include <ctime>
7249
#include <filesystem>
7350
#include <fstream>
51+
#include <random>
7452
#include <regex>
53+
#include <sstream>
7554
#include <stdio.h>
7655

7756
namespace sycl {
7857
inline namespace _V1 {
7958
namespace ext::oneapi::experimental {
8059
namespace detail {
8160

61+
std::string generateSemiUniqueId() {
62+
auto Now = std::chrono::high_resolution_clock::now();
63+
auto Milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
64+
Now.time_since_epoch());
65+
66+
// Generate random number between 10'000 and 99'900.
67+
std::random_device RD;
68+
std::mt19937 Gen(RD());
69+
std::uniform_int_distribution<int> Distrib(10'000, 99'999);
70+
int RandomNumber = Distrib(Gen);
71+
72+
// Combine time and random number into a string.
73+
std::stringstream Ss;
74+
Ss << Milliseconds.count() << "_" << std::setfill('0') << std::setw(5)
75+
<< RandomNumber;
76+
77+
return Ss.str();
78+
}
79+
8280
std::filesystem::path prepareWS(const std::string &Id) {
8381
namespace fs = std::filesystem;
8482
const fs::path TmpDirectoryPath = fs::temp_directory_path();
@@ -343,8 +341,7 @@ spirv_vec_t SYCL_JIT_to_SPIRV(
343341
[[maybe_unused]] const std::vector<std::string> &RegisteredKernelNames) {
344342
#if SYCL_EXT_JIT_ENABLE
345343
return sycl::detail::jit_compiler::get_instance().compileSYCL(
346-
generateSemiUniqueId(), SYCLSource, IncludePairs, UserArgs, LogPtr,
347-
RegisteredKernelNames);
344+
"rtc", SYCLSource, IncludePairs, UserArgs, LogPtr, RegisteredKernelNames);
348345
#else
349346
throw sycl::exception(sycl::errc::build,
350347
"kernel_compiler via sycl-jit is not available");

0 commit comments

Comments
 (0)