Skip to content

[SYCL] Change priority of devices in default_selector #1264

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 4 commits into from
Apr 3, 2020

Conversation

jbrodman
Copy link
Contributor

@jbrodman jbrodman commented Mar 6, 2020

People are unlikely to want to accidentally stumble onto the fpga.

Signed-off-by: James Brodman james.brodman@intel.com

mkinsner
mkinsner previously approved these changes Mar 6, 2020
Copy link

@mkinsner mkinsner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also want approval by @bader

@bader
Copy link
Contributor

bader commented Mar 6, 2020

This change breaks LIT tests. We need some way to use FPGA "intentionally".

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 6, 2020

queue(accelerator_selector{});

@bader
Copy link
Contributor

bader commented Mar 6, 2020

queue(accelerator_selector{});

SGTM, if you are willing to update the tests, so we can avoid LIT placeholders.

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 6, 2020

queue(accelerator_selector{});

SGTM, if you are willing to update the tests, so we can avoid LIT placeholders.

Working on it.

@bader
Copy link
Contributor

bader commented Mar 6, 2020

So, you think we should not be able to configure default selector though environment variable. Right?

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 6, 2020

So, you think we should not be able to configure default selector though environment variable. Right?

Which would you and Mike prefer? No Accel in default (and therefore no ENV override for ACC) or Accel after GPU/CPU but before host? Hmm... if accel is after host, would the override still pick ACC? That might be the best path.

@bader, @mkinsner

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 6, 2020

So, you think we should not be able to configure default selector though environment variable. Right?

Which would you and Mike prefer? No Accel in default (and therefore no ENV override for ACC) or Accel after GPU/CPU but before host? Hmm... if accel is after host, would the override still pick ACC? That might be the best path.

@bader, @mkinsner

That seems to work quite well, actually.

@jbrodman jbrodman changed the title [SYCL] Remove accels from default selector as people aren't likely to want t… [SYCL] Change priority of devices in default_selector Mar 6, 2020
@AGindinson AGindinson requested a review from GarveyJoe March 6, 2020 16:33
bader
bader previously approved these changes Mar 6, 2020
@mkinsner
Copy link

mkinsner commented Mar 6, 2020

Accel after (lower priority than) host device makes sense to me.

mkinsner
mkinsner previously approved these changes Mar 6, 2020
GarveyJoe
GarveyJoe previously approved these changes Mar 6, 2020
@keryell
Copy link
Contributor

keryell commented Mar 7, 2020

Hey, you removed the secret backdoor used to sell more FPGA in the datacenters! ;-)

Copy link
Contributor

@KarachunIvan KarachunIvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does an accelerator have lower priority than host device? According to your changes, any accelerator device won't be available at all while using default_selector since host is always presented.
IMHO, host device should be the least desired option and this should be reflected in default_selector.
Wouldn't it be better to swap priority of cpu and accelerator instead?

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 9, 2020

Why does an accelerator have lower priority than host device? According to your changes, any accelerator device won't be available at all while using default_selector since host is always presented.
IMHO, host device should be the least desired option and this should be reflected in default_selector.
Wouldn't it be better to swap priority of cpu and accelerator instead?

B/c it's unlikely that people want to accidentally stumble on an "accel" device. Putting it after host should still allow it to appear when SYCL_DEVICE_TYPE=ACC is set, right?

@jbrodman jbrodman dismissed stale reviews from GarveyJoe, mkinsner, and bader via 61bfe30 March 9, 2020 17:40
@KarachunIvan
Copy link
Contributor

Why does an accelerator have lower priority than host device? According to your changes, any accelerator device won't be available at all while using default_selector since host is always presented.
IMHO, host device should be the least desired option and this should be reflected in default_selector.
Wouldn't it be better to swap priority of cpu and accelerator instead?

B/c it's unlikely that people want to accidentally stumble on an "accel" device. Putting it after host should still allow it to appear when SYCL_DEVICE_TYPE=ACC is set, right?

Yes, it'll appear but it'll never be chosen by select_device method which picks a device with the highest score according to the score returned by default_selector::operator()() with environment variable set or without.

What about something like this:

if (is_accelerator() && std::getenv("SYCL_DEVICE_TYPE"))
  return 400;

I've just come up with this, and it can solve several issues:

  1. a user won't stumble on an accelerator device (if he won't set the environment variable);
  2. no need to change the whole bunch of failing LIT tests (because in fact they were executed on host but not on an accelerator).

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 9, 2020

@KarachunIvan how 'bout that? Override always wins.

@jbrodman
Copy link
Contributor Author

jbrodman commented Mar 9, 2020

@KarachunIvan how 'bout that? Override always wins.

With that, it probably makes sense to just remove the if(dev.is_accelerator()) part.

@@ -54,18 +55,22 @@ int default_selector::operator()(const device &dev) const {
}
}

// override always wins
if (dev.get_info<info::device::device_type>() == detail::get_forced_type())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when the device type is forced we only return devices of the forced type. Thus, this is redundant. Can someone who knows the device internals better confirm that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually do that apparently. We will limit the devices enumerated to that type plus the host device since the host device must always be available. In that case, the fact that the host device is available with higher priority means it gets selected.

@bso-intel
Copy link
Contributor

bso-intel commented Mar 10, 2020

@KarachunIvan how 'bout that? Override always wins.

With that, it probably makes sense to just remove the if(dev.is_accelerator()) part.

I agree with removing that part.
If host is ALWAYS available, the if (dev.is_accelerator()) is an unreachable code. Makes sense to remove it.
This practically means that ACC(FPGA) is never be chosen by default, and the only way is to set the env var SYCL_DEVICE_TYPE=ACC.

Comment on lines 71 to 73
if (dev.is_accelerator())
return 50;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this unreachable code

@romanovvlad
Copy link
Contributor

@jbrodman @KarachunIvan ping

@KarachunIvan
Copy link
Contributor

@jbrodman ping

jbrodman added 4 commits April 3, 2020 10:31
…o accidentally stumble upon a fpga.

Signed-off-by: James Brodman <james.brodman@intel.com>
Signed-off-by: James Brodman <james.brodman@intel.com>
Signed-off-by: James Brodman <james.brodman@intel.com>
Signed-off-by: James Brodman <james.brodman@intel.com>
@jbrodman
Copy link
Contributor Author

jbrodman commented Apr 3, 2020

Sorry, fixed.

Copy link
Contributor

@KarachunIvan KarachunIvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bader bader merged commit b217bc5 into intel:sycl Apr 3, 2020
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Apr 6, 2020
…_private_api

* origin/sycl: (614 commits)
  [SYCL][Doc] Update prerequisites in GetStartedGuide (intel#1466)
  [SYCL][USM] Remove vestigial dead code (intel#1474)
  [SYCL-PTX] Fix __spirv_GroupAsyncCopy stride computation (intel#1451)
  [Driver][SYCL] Emit an error if c compilation is forced (intel#1438)
  [SYCL] Fix sycl-post-link when no split and symbols are requested. (intel#1454)
  [SYCL] Change priority of devices in default_selector (intel#1264)
  [CI] Update CODEOWNERS matching rules order (intel#1468)
  [SYCL] Share PFWG lambda object through shared memory (intel#1455)
  [CI] Fix CODEOWNERS file syntax (intel#1464)
  [SYCL][CUDA] Fix active context when creating base event (intel#1447)
  [SYCL] Diagnose implicit declaration of kernel function type (intel#1450)
  [BuildBot] Modify configure script (intel#1421)
  [SYCL] Resolve min/max conflict (intel#1339)
  [CI][BuildBot] Fix configure parameter to turn on/off assertions (intel#1449)
  [SYCL] XFAIL LIT test due to duplicate diagnostic
  [SYCL] Remove explicit sycl_device attribute requirement
  Apply more suggestions
  Apply suggestions
  Translate new set of Intel FPGA Loop Controls
  Translate Intel FPGA force_pow2_depth memory attribute
  ...
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Apr 15, 2020
…c_abi_checks

* origin/sycl: (625 commits)
  [SYCL][Test] Disable spec_const_redefine.cpp on all devices but HOST (intel#1488)
  [SYCL] Only export public API (intel#1456)
  [SYCL][CUDA] Fix selected_binary argument in piextDeviceSelectBinary (intel#1475)
  [SYCL] Enable LIT testing with CUDA BE (intel#1458)
  [SYCL] Fix float to half-type conversion (intel#1395)
  [NFC] Cleanup unneded macro from builtins implementation (intel#1445)
  Enable cfg-printer LLVM lit tests only if LLVM linked statically (intel#1479)
  [SYCL][NFC] Reflect the "allowlist" renaming in the code (intel#1480)
  [SYCL][Doc] Update prerequisites in GetStartedGuide (intel#1466)
  [SYCL][USM] Remove vestigial dead code (intel#1474)
  [SYCL-PTX] Fix __spirv_GroupAsyncCopy stride computation (intel#1451)
  [Driver][SYCL] Emit an error if c compilation is forced (intel#1438)
  [SYCL] Fix sycl-post-link when no split and symbols are requested. (intel#1454)
  [SYCL] Change priority of devices in default_selector (intel#1264)
  [CI] Update CODEOWNERS matching rules order (intel#1468)
  [SYCL] Share PFWG lambda object through shared memory (intel#1455)
  [CI] Fix CODEOWNERS file syntax (intel#1464)
  [SYCL][CUDA] Fix active context when creating base event (intel#1447)
  [SYCL] Diagnose implicit declaration of kernel function type (intel#1450)
  [BuildBot] Modify configure script (intel#1421)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants