Skip to content

Choosing default SYCL devices for easy switching between CPU and GPU? #1183

Closed Answered by illuhad
Kiguli asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this?

sycl::qeue get_queue(bool use_gpu) {
  if(use_gpu) {
    return sycl::queue{sycl::gpu_selector_v};
  else
    return sycl::queue{sycl::cpu_selector_v};
}

// Uses the queue somehow
void run(sycl::queue& q);

int main() {
  sycl::queue q = get_queue(/* obtain parameter of whether to use GPU from somewhere*/);
  run(q);
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Kiguli
Comment options

@illuhad
Comment options

Answer selected by Kiguli
@Kiguli
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants