use of org.apache.sysml.runtime.instructions.cp.IntObject in project incubator-systemml by apache.
the class Task method parseCompactString.
public static Task parseCompactString(String stask) {
StringTokenizer st = new StringTokenizer(stask.trim(), ".");
TaskType type = TaskType.valueOf(st.nextToken());
String meta = st.nextToken();
Task newTask = new Task(meta, type);
// iteration data
String sdata = st.nextToken();
// remove brackets
sdata = sdata.substring(1, sdata.length() - 1);
StringTokenizer st2 = new StringTokenizer(sdata, ",");
while (st2.hasMoreTokens()) {
// create new iteration
String lsdata = st2.nextToken();
IntObject ldata = new IntObject(Integer.parseInt(lsdata));
newTask.addIteration(ldata);
}
return newTask;
}
use of org.apache.sysml.runtime.instructions.cp.IntObject in project incubator-systemml by apache.
the class Task method toCompactString.
public String toCompactString() {
StringBuilder sb = new StringBuilder();
sb.append(_type);
if (size() > 0) {
sb.append(".");
sb.append(_iterVar);
sb.append(".{");
int count = 0;
for (IntObject dat : _iterations) {
if (count != 0)
sb.append(",");
sb.append(dat.getLongValue());
count++;
}
sb.append("}");
}
return sb.toString();
}
use of org.apache.sysml.runtime.instructions.cp.IntObject in project incubator-systemml by apache.
the class TaskPartitionerFactoring method createTasks.
@Override
public long createTasks(LocalTaskQueue<Task> queue) {
long numCreatedTasks = 0;
long lFrom = _fromVal.getLongValue();
long lTo = _toVal.getLongValue();
long lIncr = _incrVal.getLongValue();
// number of parallel workers
int P = _numThreads;
// total number of iterations
long N = _numIter;
// remaining number of iterations
long R = N;
// next _numThreads task sizes
long K = -1;
// type of iterations: range tasks (similar to run-length encoding) make only sense if taskSize>3
TaskType type = null;
try {
for (long i = lFrom; i <= lTo; ) {
K = determineNextBatchSize(R, P);
R -= (K * P);
type = (ParForProgramBlock.USE_RANGE_TASKS_IF_USEFUL && K > 3) ? TaskType.RANGE : TaskType.SET;
// for each logical processor
for (int j = 0; j < P; j++) {
if (// no more iterations
i > lTo)
break;
// create new task and add to list of tasks
Task lTask = new Task(_iterVarName, type);
// add iterations to task
if (type == TaskType.SET) {
// value based tasks
for (long k = 0; k < K && i <= lTo; k++, i += lIncr) lTask.addIteration(new IntObject(i));
} else {
// determine end of task
long to = Math.min(i + (K - 1) * lIncr, lTo);
// range based tasks
// from
lTask.addIteration(new IntObject(i));
// to
lTask.addIteration(new IntObject(to));
// increment
lTask.addIteration(new IntObject(lIncr));
i = to + lIncr;
}
// add task to queue (after all iteration added for preventing raise conditions)
queue.enqueueTask(lTask);
numCreatedTasks++;
}
}
// mark end of task input stream
queue.closeInput();
} catch (Exception ex) {
throw new DMLRuntimeException(ex);
}
return numCreatedTasks;
}
use of org.apache.sysml.runtime.instructions.cp.IntObject in project incubator-systemml by apache.
the class TaskPartitionerFactoring method createTasks.
@Override
public List<Task> createTasks() {
LinkedList<Task> tasks = new LinkedList<>();
long lFrom = _fromVal.getLongValue();
long lTo = _toVal.getLongValue();
long lIncr = _incrVal.getLongValue();
// number of parallel workers
int P = _numThreads;
// total number of iterations
long N = _numIter;
// remaining number of iterations
long R = N;
// next _numThreads task sizes
long K = -1;
// type of iterations: range tasks (similar to run-length encoding) make only sense if taskSize>3
TaskType type = null;
for (long i = lFrom; i <= lTo; ) {
K = determineNextBatchSize(R, P);
R -= (K * P);
type = (ParForProgramBlock.USE_RANGE_TASKS_IF_USEFUL && K > 3) ? TaskType.RANGE : TaskType.SET;
// for each logical processor
for (int j = 0; j < P; j++) {
if (// no more iterations
i > lTo)
break;
// create new task and add to list of tasks
Task lTask = new Task(_iterVarName, type);
tasks.addLast(lTask);
// add iterations to task
if (type == TaskType.SET) {
// value based tasks
for (long k = 0; k < K && i <= lTo; k++, i += lIncr) lTask.addIteration(new IntObject(i));
} else {
// determine end of task
long to = Math.min(i + (K - 1) * lIncr, lTo);
// range based tasks
// from
lTask.addIteration(new IntObject(i));
// to
lTask.addIteration(new IntObject(to));
// increment
lTask.addIteration(new IntObject(lIncr));
i = to + lIncr;
}
}
}
return tasks;
}
use of org.apache.sysml.runtime.instructions.cp.IntObject in project incubator-systemml by apache.
the class TaskPartitionerFixedsize method createTasks.
@Override
public List<Task> createTasks() {
LinkedList<Task> tasks = new LinkedList<>();
// range tasks (similar to run-length encoding) make only sense if taskSize>3
TaskType type = (ParForProgramBlock.USE_RANGE_TASKS_IF_USEFUL && _taskSize > 3) ? TaskType.RANGE : TaskType.SET;
long lFrom = _fromVal.getLongValue();
long lTo = _toVal.getLongValue();
long lIncr = _incrVal.getLongValue();
long lfnp1 = _firstnPlus1;
for (long i = lFrom; i <= lTo; ) {
// create new task and add to list of tasks
Task lTask = new Task(_iterVarName, type);
tasks.addLast(lTask);
// correction for static partitioner
int corr = (lfnp1-- > 0) ? 1 : 0;
// (last task might have less)
if (type == TaskType.SET) {
// value based tasks
for (long j = 0; j < _taskSize + corr && i <= lTo; j++, i += lIncr) lTask.addIteration(new IntObject(i));
} else {
// determine end of task
long to = Math.min(i + (_taskSize - 1 + corr) * lIncr, lTo);
// range based tasks
// from
lTask.addIteration(new IntObject(i));
// to
lTask.addIteration(new IntObject(to));
// increment
lTask.addIteration(new IntObject(lIncr));
i = to + lIncr;
}
}
return tasks;
}
Aggregations