Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce multiple tiers of Events #42

Open
michaelsippel opened this issue Dec 7, 2023 · 0 comments
Open

introduce multiple tiers of Events #42

michaelsippel opened this issue Dec 7, 2023 · 0 comments

Comments

@michaelsippel
Copy link
Member

michaelsippel commented Dec 7, 2023

An Event represents a node of the scheduling-graph. Each task is associated with multiple events, describing execution states before (pre_event) and after (post_event) the task execution, as well as the state of the task-result, being initialized (result_set_event) and retrieved (result_get_event).

The Scheduling-Graph is implemented as Out-List, meaning each vertex stores a list of outgoing-edges , called followers.
However this abstraction has some not insignificant special cases which we ought to optimize.

E.g. for CPU-Tasks we know, that the pre_event will never receive any followers. Thus the whole followers list and all associated follow up- checks in Event::notify() could be omitted for this kind of event.
For other kinds of events , e.g. the result_set_event & result_get_event will not be needed by any task which returns void ( this includes all cuda-tasks ).

Implementation could be done as class-inheritance hierarchy.

// only counts number of in-edges
template < typename incount_t >
struct SinkEvent { atomic< incount_t > state; };

// keeps out-edges
struct SourceEvent : SinkEvent { ChunkedList< EventPtr > followers ; };

// this event can wake up a worker 
struct WakingEvent : SinkEvent {  WakerID waker_id;  };

// signals that the task must live at least until this event is reached
// `notify()` will release the ownership of the task when the event is reached
struct TaskRefOwnEvent;

struct CPUTask {
    // pre event is only used to check if task is ready, therefore only needs to be SinkEvent
    struct PreEvent : virtual SinkEvent {};
    // post event is always source
    struct PostEvent : virtual SourceEvent , TaskRefOwnEvent {};

    struct ResultSetEvent : WakingEvent {};
    struct ResultGetEvent : TaskRefOwnEvent {};
};
struct CudaTask {
    // a cuda task must be able to notify other tasks through the pre-event.
    struct PreEvent : SourceEvent {};
    struct PostEvent : SourceEvent {};
};

evaluation:

  • (+) would save us a lot of bytes per task.
  • (-) might require v-table for Event
    • (->) maybe solve this by encoding the type into EventPtr with bitmagic
  • (?) how can the event types be known statically
    • (->) need to select a specific event-configuration for each task.
    • (->) provide possibility to enable/disable optional Task-Properties via template in emplace_task() ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant