2 Copyright (c) 2014-2016 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
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 parts of the offload library used only on the target
33 #ifndef OFFLOAD_TARGET_H_INCLUDED
34 #define OFFLOAD_TARGET_H_INCLUDED
36 #include "offload_common.h"
37 #include "coi/coi_server.h"
39 // The offload descriptor.
40 class OffloadDescriptor
43 ~OffloadDescriptor() {
50 // Entry point for COI. Synchronously execute offloaded region given
51 // the provided buffers, misc and return data.
53 uint32_t buffer_count
,
56 uint16_t misc_data_len
,
58 uint16_t return_data_len
61 // scatters input data from in buffer to target variables
62 void scatter_copyin_data();
64 // gathers output data to the buffer
65 void gather_copyout_data();
67 // merges local variable descriptors with the descriptors received from
69 void merge_var_descs(VarDesc
*vars
, VarDesc2
*vars2
, int vars_total
);
71 int get_offload_number() const {
72 return m_offload_number
;
75 void set_offload_number(int number
) {
76 m_offload_number
= number
;
81 OffloadDescriptor() : m_vars(0)
85 typedef std::list
<void*> BufferList
;
87 // The Marshaller for the inputs of the offloaded region.
90 // The Marshaller for the outputs of the offloaded region.
93 // List of buffers that are passed to dispatch call
96 // Variable descriptors received from host
101 // extra data associated with each variable descriptor
107 VarExtra
* m_vars_extra
;
110 // one time target initialization in main
111 DLL_LOCAL
extern void __offload_target_init(void);
113 // logical device index
114 DLL_LOCAL
extern int mic_index
;
116 // total number of available logical devices
117 DLL_LOCAL
extern int mic_engines_total
;
119 // device frequency (from COI)
120 DLL_LOCAL
extern uint64_t mic_frequency
;
123 RefInfo(bool is_add
, long amount
):is_added(is_add
),count(amount
)
129 #endif // OFFLOAD_TARGET_H_INCLUDED