[feat] cosmetics in output and fix number of workgroups from domainTree
@@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import uk.ac.manchester.tornado.api.WorkerGrid;
import uk.ac.manchester.tornado.api.common.Access;
import uk.ac.manchester.tornado.api.common.TornadoEvents;
import uk.ac.manchester.tornado.runtime.EventSet;
@@ -330,6 +331,16 @@ public class TaskMetaData extends AbstractMetaData {
return enableParallelization() && hasDomain() && domain.getDepth() > 0;
}
+ private long[] calculateNumberOfWorkgroupsFromDomain(DomainTree domain) {
+ long[] numOfWorkgroups = new long[domain.getDepth()];
+ if (globalWork != null && localWork != null) {
+ for (int i = 0; i < numOfWorkgroups.length; i++) {
+ numOfWorkgroups[i] = globalWork[i] / localWork[i];
+ }
+ }
+ return numOfWorkgroups;
+ }
+
public void printThreadDims() {
StringBuilder deviceDebug = new StringBuilder();
boolean deviceBelongsToPTX = isDevicePTX(getDevice());
@@ -346,9 +357,12 @@ public class TaskMetaData extends AbstractMetaData {
deviceDebug.append("\tthread dimensions : " + formatWorkDimensionArray(gw, "1") + "\n");
long[] lw = this.isWorkerGridAvailable() ? getWorkerGrid(getId()).getLocalWork() : localWork;
deviceDebug.append("\tblocks dimensions : " + (lw == null ? "null" : formatWorkDimensionArray(lw, "1")) + "\n");
- long[] nw = this.isWorkerGridAvailable() ? getWorkerGrid(getId()).getNumberOfWorkgroups() : new long[] {globalWork[0]/localWork[0], globalWork[1]/localWork[1], 0}; //TODO Fix dimensions
+ long[] nw = this.isWorkerGridAvailable() ? getWorkerGrid(getId()).getNumberOfWorkgroups() : calculateNumberOfWorkgroupsFromDomain(domain);
+ // dimensions
deviceDebug.append("\tgrids dimensions : " + (nw == null ? "null" : formatWorkDimensionArray(nw, "1")) + "\n");
- } else {
+ } else
+
+ {
long[] gw = this.isWorkerGridAvailable() ? getWorkerGrid(getId()).getGlobalWork() : globalWork;
deviceDebug.append("\tglobal work size : " + formatWorkDimensionArray(gw, "1") + "\n");
long[] lw = this.isWorkerGridAvailable() ? getWorkerGrid(getId()).getLocalWork() : localWork;
