Coverage Report

Created: 2022-08-03 23:52

/home/liu/buildslave/linux-x64-runtests/build/lib/nnc/_ccv_nnc_stream.h
Line
Count
Source (jump to first uncovered line)
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/sfmt/SFMT.h"
16
#include "3rdparty/khash/khash.h"
17
18
struct ccv_nnc_stream_signal_s {
19
  int type;
20
  ccv_nnc_stream_context_t* emit_context;
21
};
22
23
typedef struct {
24
  // Empty, this will hold things such as NCCL communicator in subclass.
25
} ccv_nnc_stream_resource_container_t;
26
27
struct ccv_nnc_stream_context_s {
28
  int type;
29
  // For resource container
30
  ccv_nnc_stream_resource_container_t* _inline_container[1];
31
  ccv_nnc_stream_resource_container_t** resource_container;
32
  // For scheduler
33
  co_routine_t* main; // main task.
34
  co_scheduler_t* scheduler;
35
  // For neighbor discovery
36
  ccv_nnc_stream_context_neighbor_discovery_f neighbor_discovery;
37
  void* neighbor_discovery_context;
38
  // For hooks
39
  ccv_array_t* destructor_hooks;
40
  int reuse_destructor_hook;
41
  ccv_nnc_stream_signal_t* event;
42
  // For random number generator.
43
  sfmt_t* sfmt;
44
};
45
46
// Return the scheduler from a stream (if not created, create one).
47
CCV_WARN_UNUSED(co_scheduler_t*) ccv_nnc_stream_context_get_scheduler(ccv_nnc_stream_context_t* const stream_context);
48
49
0
#define co_stream_await(_stream) do { if (!_co_stream_await(_self_, _stream)) { return (co_state_t){ __LINE__, 0 }; } case __LINE__: ; } while (0)
50
int _co_stream_await(co_routine_t* const self, 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
KHASH_MAP_INIT_INT(stream_map, ccv_nnc_stream_context_t*);
60
61
#endif