Skip to content

[SYCL]Fix ESIMD_EMULATOR being picked as default device #6870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e188c01
Fix ESIMD_EMULATOR being picked up as default device
Sep 23, 2022
9fa6dc4
Revert "Fix ESIMD_EMULATOR being picked up as default device"
Sep 23, 2022
3b8fccf
Fix ESIMD_EMULATOR being picked up as default device
Sep 23, 2022
3d6df0a
Simplify the selection logic for ESIMD_EMULATOR
Sep 28, 2022
27b9f8f
Simplify the selection logic for ESIMD_EMULATOR
Sep 28, 2022
4066e4d
Merge branch 'sycl' into 39732
lbushi25 Sep 30, 2022
b67d9e1
Extend filter_selector to recognize esimd_emulator device
Sep 30, 2022
beca3e3
Fix merge conflict
Sep 30, 2022
2a05b26
Run clang-format
Oct 1, 2022
f9c0185
Do not load ESIMD_EMULATOR plugin by default
lbushi25 Oct 3, 2022
7393395
Check if esimd_emulator appears in filter before loading plugin
lbushi25 Oct 3, 2022
3e3c4b0
Check if esimd_emulator appears in filter before loading plugin
lbushi25 Oct 3, 2022
a853994
Merge branch 'intel:sycl' into 39732
lbushi25 Oct 4, 2022
53c4ee3
Update pi.cpp
lbushi25 Oct 4, 2022
53f8cfb
Merge branch '39732' of https://github.com/lbushi25/llvm into 39732
lbushi25 Oct 4, 2022
05e8e6c
Document changes
lbushi25 Oct 4, 2022
3d33e39
Fix formatting
lbushi25 Oct 4, 2022
bfb3956
Formatting updates
lbushi25 Oct 5, 2022
79efa48
Formatting
lbushi25 Oct 5, 2022
6e95993
Formatting
lbushi25 Oct 5, 2022
5d69e5a
Merge branch 'sycl' into 39732
lbushi25 Oct 6, 2022
b130427
Formatting
lbushi25 Oct 6, 2022
7271e9b
Merge branch '39732' of https://github.com/lbushi25/llvm into 39732
lbushi25 Oct 6, 2022
2bc9ba5
Update filter_selector
lbushi25 Oct 6, 2022
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
2 changes: 2 additions & 0 deletions sycl/source/detail/filter_selector_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ filter create_filter(const std::string &Input) {
Result.Backend = backend::ext_oneapi_cuda;
} else if (Token == "hip" && !Result.Backend) {
Result.Backend = backend::ext_oneapi_hip;
} else if (Token == "esimd_emulator" && !Result.Backend) {
Result.Backend = backend::ext_intel_esimd_emulator;
} else if (std::regex_match(Token, IntegerExpr) && !Result.DeviceNum) {
try {
Result.DeviceNum = std::stoi(Token);
Expand Down
5 changes: 1 addition & 4 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ std::vector<std::pair<std::string, backend>> findPlugins() {
backend::ext_oneapi_level_zero);
PluginNames.emplace_back(__SYCL_CUDA_PLUGIN_NAME, backend::ext_oneapi_cuda);
PluginNames.emplace_back(__SYCL_HIP_PLUGIN_NAME, backend::ext_oneapi_hip);
PluginNames.emplace_back(__SYCL_ESIMD_EMULATOR_PLUGIN_NAME,
backend::ext_intel_esimd_emulator);
} else {
std::vector<device_filter> Filters = FilterList->get();
bool OpenCLFound = false;
Expand All @@ -311,8 +309,7 @@ std::vector<std::pair<std::string, backend>> findPlugins() {
backend::ext_oneapi_cuda);
CudaFound = true;
}
if (!EsimdCpuFound && (Backend == backend::ext_intel_esimd_emulator ||
Backend == backend::all)) {
if (!EsimdCpuFound && Backend == backend::ext_intel_esimd_emulator) {
PluginNames.emplace_back(__SYCL_ESIMD_EMULATOR_PLUGIN_NAME,
backend::ext_intel_esimd_emulator);
EsimdCpuFound = true;
Expand Down
14 changes: 13 additions & 1 deletion sycl/source/device_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,22 @@ static void traceDeviceSelector(const std::string &DeviceType) {
bool ShouldTrace = false;
ShouldTrace = detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_BASIC);
if (ShouldTrace) {
std::cout << "SYCL_PI_TRACE[all]: Requested device_type: " << DeviceType << std::endl;
std::cout << "SYCL_PI_TRACE[all]: Requested device_type: " << DeviceType
<< std::endl;
}
}

__SYCL_EXPORT int default_selector_v(const device &dev) {
// The default selector doesn't reject any devices.
int Score = 0;

// we give the esimd_emulator device a score of zero to prevent it from being
// chosen among other devices. The same thing is done for gpu_selector_v
// below.
if (dev.get_backend() == backend::ext_intel_esimd_emulator) {
return 0;
}

traceDeviceSelector("info::device_type::automatic");
if (dev.get_info<info::device::device_type>() == detail::get_forced_type())
Score += 2000;
Expand All @@ -197,6 +205,10 @@ __SYCL_EXPORT int default_selector_v(const device &dev) {
__SYCL_EXPORT int gpu_selector_v(const device &dev) {
int Score = detail::REJECT_DEVICE_SCORE;

if (dev.get_backend() == backend::ext_intel_esimd_emulator) {
return 0;
}

traceDeviceSelector("info::device_type::gpu");
if (dev.is_gpu()) {
Score = 1000;
Expand Down