如何解决如何获取 cl::Device 的数字设备 ID?
OpenCL C++ 绑定具有包含 cl::Device
的 _cl_device_id *
类。指向类型对我们来说是不透明的。
在给定 cl::Device
的情况下,如何获得其数字 ID(在其上下文中)?基类'operator()
只给我包装的_cl_device_id *
,而不是数字。
解决方法
正如 here 所指出的,_cl_device_id
实际上不能用于获取唯一的设备 ID。相反,要为所有可用设备分配唯一 ID,请使用 this solution。
如果您还可以访问您的上下文(即您持有 import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
static class DoublyLinkedListNode {
public int data;
public DoublyLinkedListNode next;
public DoublyLinkedListNode prev;
public DoublyLinkedListNode(int nodeData) {
this.data = nodeData;
this.next = null;
this.prev = null;
}
}
static class DoublyLinkedList {
public DoublyLinkedListNode head;
public DoublyLinkedListNode tail;
public DoublyLinkedList() {
this.head = null;
this.tail = null;
}
public void insertNode(int nodeData) {
DoublyLinkedListNode node = new DoublyLinkedListNode(nodeData);
if (this.head == null) {
this.head = node;
} else {
this.tail.next = node;
node.prev = this.tail;
}
this.tail = node;
}
}
public static void printDoublyLinkedList(DoublyLinkedListNode node,String sep,BufferedWriter bufferedWriter) throws IOException {
while (node != null) {
bufferedWriter.write(String.valueOf(node.data));
node = node.next;
if (node != null) {
bufferedWriter.write(sep);
}
}
}
class Result {
/*
* Complete the 'sortedInsert' function below.
*
* The function is expected to return an INTEGER_DOUBLY_LINKED_LIST.
* The function accepts following parameters:
* 1. INTEGER_DOUBLY_LINKED_LIST llist
* 2. INTEGER data
*/
/*
* For your reference:
*
* DoublyLinkedListNode {
* int data;
* DoublyLinkedListNode next;
* DoublyLinkedListNode prev;
* }
*
*/
public static DoublyLinkedListNode sortedInsert(DoublyLinkedListNode llist,intdata) {
// Write your code here
}
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
int t = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
for (int tItr = 0; tItr < t; tItr++) {
DoublyLinkedList llist = new DoublyLinkedList();
int llistCount = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
for (int i = 0; i < llistCount; i++) {
int llistItem = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
llist.insertNode(llistItem);
}
int data = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
DoublyLinkedListNode llist1 = sortedInsert(llist.head,data);
printDoublyLinkedList(llist1," ",bufferedWriter);
bufferedWriter.newLine();
}
bufferedWriter.close();
scanner.close();
}
}
和 my_device
),这是一个丑陋且昂贵的黑客:
my_context
...但我真的宁愿避免这种情况。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。