Jim Cownie | 33f7b24 | 2014-04-09 15:40:23 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.txt for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | |
| 11 | /*! \file |
| 12 | \brief The interface between compiler-generated host code and runtime library |
| 13 | */ |
| 14 | |
| 15 | #ifndef COMPILER_IF_HOST_H_INCLUDED |
| 16 | #define COMPILER_IF_HOST_H_INCLUDED |
| 17 | |
| 18 | #include "offload_host.h" |
| 19 | |
| 20 | #define OFFLOAD_TARGET_ACQUIRE OFFLOAD_PREFIX(target_acquire) |
| 21 | #define OFFLOAD_TARGET_ACQUIRE1 OFFLOAD_PREFIX(target_acquire1) |
| 22 | #define OFFLOAD_OFFLOAD OFFLOAD_PREFIX(offload) |
| 23 | #define OFFLOAD_OFFLOAD1 OFFLOAD_PREFIX(offload1) |
| 24 | #define OFFLOAD_OFFLOAD2 OFFLOAD_PREFIX(offload2) |
| 25 | #define OFFLOAD_CALL_COUNT OFFLOAD_PREFIX(offload_call_count) |
| 26 | |
| 27 | |
| 28 | /*! \fn OFFLOAD_TARGET_ACQUIRE |
| 29 | \brief Attempt to acquire the target. |
| 30 | \param target_type The type of target. |
| 31 | \param target_number The device number. |
| 32 | \param is_optional Whether CPU fall-back is allowed. |
| 33 | \param status Address of variable to hold offload status. |
| 34 | \param file Filename in which this offload occurred. |
| 35 | \param line Line number in the file where this offload occurred. |
| 36 | */ |
| 37 | extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE( |
| 38 | TARGET_TYPE target_type, |
| 39 | int target_number, |
| 40 | int is_optional, |
| 41 | _Offload_status* status, |
| 42 | const char* file, |
| 43 | uint64_t line |
| 44 | ); |
| 45 | |
| 46 | /*! \fn OFFLOAD_TARGET_ACQUIRE1 |
| 47 | \brief Acquire the target for offload (OpenMP). |
| 48 | \param device_number Device number or null if not specified. |
| 49 | \param file Filename in which this offload occurred |
| 50 | \param line Line number in the file where this offload occurred. |
| 51 | */ |
| 52 | extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1( |
| 53 | const int* device_number, |
| 54 | const char* file, |
| 55 | uint64_t line |
| 56 | ); |
| 57 | |
| 58 | /*! \fn OFFLOAD_OFFLOAD1 |
| 59 | \brief Run function on target using interface for old data persistence. |
| 60 | \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE. |
| 61 | \param name Name of offload entry point. |
| 62 | \param is_empty If no code to execute (e.g. offload_transfer) |
| 63 | \param num_vars Number of variable descriptors. |
| 64 | \param vars Pointer to VarDesc array. |
| 65 | \param vars2 Pointer to VarDesc2 array. |
| 66 | \param num_waits Number of "wait" values. |
| 67 | \param waits Pointer to array of wait values. |
| 68 | \param signal Pointer to signal value or NULL. |
| 69 | */ |
| 70 | extern "C" int OFFLOAD_OFFLOAD1( |
| 71 | OFFLOAD o, |
| 72 | const char *name, |
| 73 | int is_empty, |
| 74 | int num_vars, |
| 75 | VarDesc *vars, |
| 76 | VarDesc2 *vars2, |
| 77 | int num_waits, |
| 78 | const void** waits, |
| 79 | const void** signal |
| 80 | ); |
| 81 | |
| 82 | /*! \fn OFFLOAD_OFFLOAD2 |
| 83 | \brief Run function on target using interface for new data persistence. |
| 84 | \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE. |
| 85 | \param name Name of offload entry point. |
| 86 | \param is_empty If no code to execute (e.g. offload_transfer) |
| 87 | \param num_vars Number of variable descriptors. |
| 88 | \param vars Pointer to VarDesc array. |
| 89 | \param vars2 Pointer to VarDesc2 array. |
| 90 | \param num_waits Number of "wait" values. |
| 91 | \param waits Pointer to array of wait values. |
| 92 | \param signal Pointer to signal value or NULL. |
| 93 | \param entry_id A signature for the function doing the offload. |
| 94 | \param stack_addr The stack frame address of the function doing offload. |
| 95 | */ |
| 96 | extern "C" int OFFLOAD_OFFLOAD2( |
| 97 | OFFLOAD o, |
| 98 | const char *name, |
| 99 | int is_empty, |
| 100 | int num_vars, |
| 101 | VarDesc *vars, |
| 102 | VarDesc2 *vars2, |
| 103 | int num_waits, |
| 104 | const void** waits, |
| 105 | const void** signal, |
| 106 | int entry_id, |
| 107 | const void *stack_addr |
| 108 | ); |
| 109 | |
| 110 | // Run function on target (obsolete). |
| 111 | // @param o OFFLOAD object |
| 112 | // @param name function name |
| 113 | extern "C" int OFFLOAD_OFFLOAD( |
| 114 | OFFLOAD o, |
| 115 | const char *name, |
| 116 | int is_empty, |
| 117 | int num_vars, |
| 118 | VarDesc *vars, |
| 119 | VarDesc2 *vars2, |
| 120 | int num_waits, |
| 121 | const void** waits, |
| 122 | const void* signal, |
| 123 | int entry_id = 0, |
| 124 | const void *stack_addr = NULL |
| 125 | ); |
| 126 | |
| 127 | // Global counter on host. |
| 128 | // This variable is used if P2OPT_offload_do_data_persistence == 2. |
| 129 | // The variable used to identify offload constructs contained in one procedure. |
| 130 | // Call to OFFLOAD_CALL_COUNT() is inserted at HOST on entry of the routine. |
| 131 | extern "C" int OFFLOAD_CALL_COUNT(); |
| 132 | |
| 133 | #endif // COMPILER_IF_HOST_H_INCLUDED |