update ChangeLogs for previous commit
[official-gcc.git] / liboffloadmic / runtime / coi / coi_client.h
blob54b83a9d96507c34487f95566bff4512f066e9c9
1 /*
2 Copyright (c) 2014 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 // The interface betwen offload library and the COI API on the host
33 #ifndef COI_CLIENT_H_INCLUDED
34 #define COI_CLIENT_H_INCLUDED
36 #include <common/COIPerf_common.h>
37 #include <source/COIEngine_source.h>
38 #include <source/COIProcess_source.h>
39 #include <source/COIPipeline_source.h>
40 #include <source/COIBuffer_source.h>
41 #include <source/COIEvent_source.h>
43 #include <string.h>
45 #include "../liboffload_error_codes.h"
46 #include "../offload_util.h"
48 #define MIC_ENGINES_MAX 128
50 #if MIC_ENGINES_MAX < COI_MAX_ISA_MIC_DEVICES
51 #error MIC_ENGINES_MAX need to be increased
52 #endif
54 // COI library interface
55 namespace COI {
57 extern bool init(void);
58 extern void fini(void);
60 extern bool is_available;
62 // pointers to functions from COI library
63 extern COIRESULT (*EngineGetCount)(COI_ISA_TYPE, uint32_t*);
64 extern COIRESULT (*EngineGetHandle)(COI_ISA_TYPE, uint32_t, COIENGINE*);
66 extern COIRESULT (*ProcessCreateFromMemory)(COIENGINE, const char*,
67 const void*, uint64_t, int,
68 const char**, uint8_t,
69 const char**, uint8_t,
70 const char*, uint64_t,
71 const char*,
72 const char*, uint64_t,
73 COIPROCESS*);
74 extern COIRESULT (*ProcessDestroy)(COIPROCESS, int32_t, uint8_t,
75 int8_t*, uint32_t*);
76 extern COIRESULT (*ProcessGetFunctionHandles)(COIPROCESS, uint32_t,
77 const char**,
78 COIFUNCTION*);
79 extern COIRESULT (*ProcessLoadLibraryFromMemory)(COIPROCESS,
80 const void*,
81 uint64_t,
82 const char*,
83 const char*,
84 const char*,
85 uint64_t,
86 uint32_t,
87 COILIBRARY*);
88 extern COIRESULT (*ProcessRegisterLibraries)(uint32_t,
89 const void**,
90 const uint64_t*,
91 const char**,
92 const uint64_t*);
94 extern COIRESULT (*PipelineCreate)(COIPROCESS, COI_CPU_MASK, uint32_t,
95 COIPIPELINE*);
96 extern COIRESULT (*PipelineDestroy)(COIPIPELINE);
97 extern COIRESULT (*PipelineRunFunction)(COIPIPELINE, COIFUNCTION,
98 uint32_t, const COIBUFFER*,
99 const COI_ACCESS_FLAGS*,
100 uint32_t, const COIEVENT*,
101 const void*, uint16_t, void*,
102 uint16_t, COIEVENT*);
104 extern COIRESULT (*BufferCreate)(uint64_t, COI_BUFFER_TYPE, uint32_t,
105 const void*, uint32_t,
106 const COIPROCESS*, COIBUFFER*);
107 extern COIRESULT (*BufferCreateFromMemory)(uint64_t, COI_BUFFER_TYPE,
108 uint32_t, void*,
109 uint32_t, const COIPROCESS*,
110 COIBUFFER*);
111 extern COIRESULT (*BufferDestroy)(COIBUFFER);
112 extern COIRESULT (*BufferMap)(COIBUFFER, uint64_t, uint64_t,
113 COI_MAP_TYPE, uint32_t, const COIEVENT*,
114 COIEVENT*, COIMAPINSTANCE*, void**);
115 extern COIRESULT (*BufferUnmap)(COIMAPINSTANCE, uint32_t,
116 const COIEVENT*, COIEVENT*);
117 extern COIRESULT (*BufferWrite)(COIBUFFER, uint64_t, const void*,
118 uint64_t, COI_COPY_TYPE, uint32_t,
119 const COIEVENT*, COIEVENT*);
120 extern COIRESULT (*BufferRead)(COIBUFFER, uint64_t, void*, uint64_t,
121 COI_COPY_TYPE, uint32_t,
122 const COIEVENT*, COIEVENT*);
123 extern COIRESULT (*BufferCopy)(COIBUFFER, COIBUFFER, uint64_t, uint64_t,
124 uint64_t, COI_COPY_TYPE, uint32_t,
125 const COIEVENT*, COIEVENT*);
126 extern COIRESULT (*BufferGetSinkAddress)(COIBUFFER, uint64_t*);
127 extern COIRESULT (*BufferSetState)(COIBUFFER, COIPROCESS, COI_BUFFER_STATE,
128 COI_BUFFER_MOVE_FLAG, uint32_t,
129 const COIEVENT*, COIEVENT*);
131 extern COIRESULT (*EventWait)(uint16_t, const COIEVENT*, int32_t,
132 uint8_t, uint32_t*, uint32_t*);
134 extern uint64_t (*PerfGetCycleFrequency)(void);
136 } // namespace COI
138 #endif // COI_CLIENT_H_INCLUDED