Coverage Report

Created: 2021-04-12 01:11

/home/liu/buildslave/linux-x64-runtests/build/lib/nnc/_ccv_nnc_stream.h
Line
Count
Source
1
/**********************************************************
2
 * C-based/Cached/Core Computer Vision Library
3
 * Liu Liu, 2010-02-01
4
 **********************************************************/
5
6
/**********************************************************
7
 * CCV - Neural Network Collection
8
 **********************************************************/
9
10
#ifndef GUARD_ccv_nnc_stream_internal_h
11
#define GUARD_ccv_nnc_stream_internal_h
12
13
#include "ccv_nnc.h"
14
#include "co.h"
15
#include "3rdparty/khash/khash.h"
16
17
struct ccv_nnc_stream_signal_s {
18
  int type;
19
  ccv_nnc_stream_context_t* emit_context;
20
};
21
22
typedef struct {
23
  // Empty, this will hold things such as NCCL communicator in subclass.
24
} ccv_nnc_stream_resource_container_t;
25
26
struct ccv_nnc_stream_context_s {
27
  int type;
28
  // For resource container
29
  ccv_nnc_stream_resource_container_t* _inline_container[1];
30
  ccv_nnc_stream_resource_container_t** resource_container;
31
  // For scheduler
32
  co_routine_t* main; // main task.
33
  co_scheduler_t* scheduler;
34
  // For neighbor discovery
35
  ccv_nnc_stream_context_neighbor_discovery_f neighbor_discovery;
36
  void* neighbor_discovery_context;
37
  // For hooks
38
  ccv_array_t* destructor_hooks;
39
  int reuse_destructor_hook;
40
  ccv_nnc_stream_signal_t* event;
41
  ccv_nnc_stream_signal_t* checkpoint;
42
};
43
44
// Return the scheduler from a stream (if not created, create one).
45
CCV_WARN_UNUSED(co_scheduler_t*) ccv_nnc_stream_context_get_scheduler(ccv_nnc_stream_context_t* const stream_context);
46
47
26
#define co_stream_await(_stream) do 
{ if (14
!_co_stream_await(_self_, 14
_stream12
))
{ return (co_state_t){ __LINE__, 0 }; }8
case __LINE__: ; }14
while (
014
)
48
int _co_stream_await(co_routine_t* const self, ccv_nnc_stream_context_t* const stream);
49
50
ccv_nnc_stream_signal_t* ccv_nnc_stream_context_emit_signal_new(ccv_nnc_stream_context_t* const stream);
51
52
typedef struct {
53
  ccv_nnc_callback_f fn;
54
  void* callback_context;
55
} ccv_nnc_async_callback_t;
56
57
typedef void(*ccv_nnc_async_callback_f)(ccv_nnc_async_callback_t* const async);
58
59
typedef struct {
60
  ccv_nnc_stream_context_t* stream;
61
  ccv_nnc_stream_signal_t* synced;
62
} ccv_nnc_synced_stream_t;
63
64
KHASH_MAP_INIT_INT(synced_stream, ccv_nnc_synced_stream_t);
65
66
#endif