coi_client.h 6.4 KB

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