TTK
Loading...
Searching...
No Matches
FTRTasks.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include "FTRDataTypes.h"
15#include <Debug.h>
16
17#include <tuple>
18#ifndef TTK_ENABLE_KAMIKAZE
19#include <iostream>
20#endif
21
22namespace ttk {
23 namespace ftr {
24
25 // At least one of nbTasks or grainSize need to be given
26 // to use this structure
27 struct TaskChunk {
31
32 explicit TaskChunk(const idVertex nbel) : nbElemt{nbel} {
33 }
34 };
35
36 // Stateless class, toolbox
37 class Tasks {
38 public:
44 static std::tuple<idVertex, idPropagation>
45 getChunk(const TaskChunk &params) {
46#ifndef TTK_ENABLE_KAMIKAZE
47 Debug dbg{};
48 dbg.setDebugMsgPrefix("Task");
49 if(!params.nbElemt) {
50 dbg.printErr("getChunk called with nbElemnt null");
51 }
52 if(!params.nbTasks and !params.grainSize) {
53 dbg.printErr("getChunk called with neither nbtasks nor grainSize");
54 }
55 if(params.nbTasks and params.grainSize) {
56 dbg.printErr("getChunk called with both nbtasks and grainSize");
57 }
58#endif
59 const idVertex grainSize = (params.grainSize)
60 ? params.grainSize
61 : params.nbElemt / params.nbTasks;
62 const idPropagation nbTasks
63 = params.nbElemt / grainSize + (params.nbElemt % grainSize != 0);
64
65 return std::make_tuple(grainSize, nbTasks);
66 }
67
68 static idVertex getBegin(const idPropagation chunkId,
69 const idVertex grainSize,
70 const idVertex offset = 0) {
71 return offset + grainSize * chunkId;
72 }
73
74 static idVertex getEnd(const idPropagation chunkId,
75 const idVertex grainSize,
76 const idVertex maxEnd = nullVertex) {
77 const idVertex computedEnd = grainSize * (chunkId + 1);
78 return std::min(maxEnd, computedEnd);
79 }
80 };
81
82 // Explain priority explicitly
84 } // namespace ftr
85} // namespace ttk
Minimalist debugging class.
Definition Debug.h:88
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
TTK FTRGraph tasks management tools.
Definition FTRTasks.h:37
static std::tuple< idVertex, idPropagation > getChunk(const TaskChunk &params)
Definition FTRTasks.h:45
static idVertex getBegin(const idPropagation chunkId, const idVertex grainSize, const idVertex offset=0)
Definition FTRTasks.h:68
static idVertex getEnd(const idPropagation chunkId, const idVertex grainSize, const idVertex maxEnd=nullVertex)
Definition FTRTasks.h:74
PriorityLevel
Definition FTRTasks.h:83
@ Average
Definition FTRTasks.h:83
idNode idPropagation
for task identifiers
SimplexId idVertex
Vertex index in scalars_.
The Topology ToolKit.
idPropagation nbTasks
Definition FTRTasks.h:29
idVertex grainSize
Definition FTRTasks.h:30
TaskChunk(const idVertex nbel)
Definition FTRTasks.h:32