coi_server.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 target.
  27. #ifndef COI_SERVER_H_INCLUDED
  28. #define COI_SERVER_H_INCLUDED
  29. #include <common/COIEngine_common.h>
  30. #include <common/COIPerf_common.h>
  31. #include <sink/COIProcess_sink.h>
  32. #include <sink/COIPipeline_sink.h>
  33. #include <sink/COIBuffer_sink.h>
  34. #include <list>
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <unistd.h>
  38. #include "../liboffload_error_codes.h"
  39. // wrappers for COI API
  40. #define PipelineStartExecutingRunFunctions() \
  41. { \
  42. COIRESULT res = COIPipelineStartExecutingRunFunctions(); \
  43. if (res != COI_SUCCESS) { \
  44. LIBOFFLOAD_ERROR(c_pipeline_start_run_funcs, mic_index, res); \
  45. exit(1); \
  46. } \
  47. }
  48. #define ProcessWaitForShutdown() \
  49. { \
  50. COIRESULT res = COIProcessWaitForShutdown(); \
  51. if (res != COI_SUCCESS) { \
  52. LIBOFFLOAD_ERROR(c_process_wait_shutdown, mic_index, res); \
  53. exit(1); \
  54. } \
  55. }
  56. #define BufferAddRef(buf) \
  57. { \
  58. COIRESULT res = COIBufferAddRef(buf); \
  59. if (res != COI_SUCCESS) { \
  60. LIBOFFLOAD_ERROR(c_buf_add_ref, mic_index, res); \
  61. exit(1); \
  62. } \
  63. }
  64. #define BufferReleaseRef(buf) \
  65. { \
  66. COIRESULT res = COIBufferReleaseRef(buf); \
  67. if (res != COI_SUCCESS) { \
  68. LIBOFFLOAD_ERROR(c_buf_release_ref, mic_index, res); \
  69. exit(1); \
  70. } \
  71. }
  72. #define EngineGetIndex(index) \
  73. { \
  74. COI_ISA_TYPE isa_type; \
  75. COIRESULT res = COIEngineGetIndex(&isa_type, index); \
  76. if (res != COI_SUCCESS) { \
  77. LIBOFFLOAD_ERROR(c_get_engine_index, mic_index, res); \
  78. exit(1); \
  79. } \
  80. }
  81. #endif // COI_SERVER_H_INCLUDED