driver_mic_common.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012 INRIA
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __DRIVER_MIC_COMMON_H__
  17. #define __DRIVER_MIC_COMMON_H__
  18. #include <common/config.h>
  19. #ifdef STARPU_USE_MIC
  20. #include <source/COIProcess_source.h>
  21. #define STARPU_TO_MIC_ID(id) ((id) + 1)
  22. /* TODO: rather allocate ports on the host and pass them as parameters to the device process */
  23. // We use the last SCIF reserved port and add 1000 to be safe
  24. #define STARPU_MIC_PORTS_BEGIN SCIF_PORT_RSVD+1000
  25. #define STARPU_MIC_SOURCE_PORT_NUMBER STARPU_MIC_PORTS_BEGIN
  26. #define STARPU_MIC_SINK_PORT_NUMBER(id) ((id) + STARPU_MIC_PORTS_BEGIN)
  27. #define STARPU_MIC_SOURCE_DT_PORT_NUMBER (STARPU_MAXMICDEVS + STARPU_MIC_PORTS_BEGIN)
  28. #define STARPU_MIC_SINK_DT_PORT_NUMBER(id) ((id) + STARPU_MAXMICDEVS + STARPU_MIC_PORTS_BEGIN + 1)
  29. #define STARPU_MIC_SINK_SINK_DT_PORT_NUMBER(me, peer_id) \
  30. ((me) * STARPU_MAXMICDEVS + (peer_id) + 2 * STARPU_MAXMICDEVS + STARPU_MIC_PORTS_BEGIN + 1)
  31. #define STARPU_MIC_PAGE_SIZE 0x1000
  32. #define STARPU_MIC_GET_PAGE_SIZE_MULTIPLE(size) \
  33. (((size) % STARPU_MIC_PAGE_SIZE == 0) ? (size) : (((size) / STARPU_MIC_PAGE_SIZE + 1) * STARPU_MIC_PAGE_SIZE))
  34. #define STARPU_MIC_COMMON_REPORT_SCIF_ERROR(status) \
  35. _starpu_mic_common_report_scif_error(__starpu_func__, __FILE__, __LINE__, status)
  36. struct _starpu_mic_free_command
  37. {
  38. void *addr;
  39. size_t size;
  40. };
  41. void _starpu_mic_common_report_scif_error(const char *func, const char *file, int line, const int status);
  42. int _starpu_mic_common_recv_is_ready(const struct _starpu_mp_node *mp_node);
  43. void _starpu_mic_common_send(const struct _starpu_mp_node *node, void *msg, int len, void * event);
  44. void _starpu_mic_common_recv(const struct _starpu_mp_node *node, void *msg, int len, void * event);
  45. void _starpu_mic_common_dt_send(const struct _starpu_mp_node *node, void *msg, int len, void * event);
  46. void _starpu_mic_common_dt_recv(const struct _starpu_mp_node *node, void *msg, int len, void * event);
  47. void _starpu_mic_common_connect(scif_epd_t *endpoint, uint16_t remote_node, COIPROCESS process,
  48. uint16_t local_port_number, uint16_t remote_port_number);
  49. void _starpu_mic_common_accept(scif_epd_t *endpoint, uint16_t port_number);
  50. #endif /* STARPU_USE_MIC */
  51. #endif /* __DRIVER_MIC_COMMON_H__ */