From 0fcc2cc6a269c7e6261f039b84d2ba237bd86941 Mon Sep 17 00:00:00 2001 From: CoreRasurae <luis.p.mendes@gmail.com> Date: Mon, 23 Apr 2018 22:35:46 +0100 Subject: [PATCH] Update: Enable kernel profiling and execution simultaneously on multiple devices - part1,fix2 --- src/main/java/com/aparapi/device/Device.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/aparapi/device/Device.java b/src/main/java/com/aparapi/device/Device.java index f15835e6..2e43c43c 100644 --- a/src/main/java/com/aparapi/device/Device.java +++ b/src/main/java/com/aparapi/device/Device.java @@ -18,7 +18,7 @@ package com.aparapi.device; import com.aparapi.*; import com.aparapi.internal.kernel.*; -public abstract class Device{ +public abstract class Device implements Comparable<Device> { public static enum TYPE { UNKNOWN(Integer.MAX_VALUE), @@ -179,4 +179,20 @@ public abstract class Device{ public int hashCode() { return Long.valueOf(getDeviceId()).hashCode(); } + + public int compareTo(Device other) { + if (type.rank < other.type.rank) { + return -1; + } else if (type.rank > other.type.rank) { + return 1; + } + + if (getDeviceId() < other.getDeviceId()) { + return -1; + } else if (getDeviceId() > other.getDeviceId()) { + return 1; + } + + return 0; + } } -- GitLab