OpenMP Runtime
tomp_qmss.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013, Texas Instruments Incorporated - http://www.ti.com/
00003  *   All rights reserved.
00004  *
00005  *  Redistribution and use in source and binary forms, with or without
00006  *  modification, are permitted provided that the following conditions are met:
00007  *      * Redistributions of source code must retain the above copyright
00008  *        notice, this list of conditions and the following disclaimer.
00009  *      * Redistributions in binary form must reproduce the above copyright
00010  *        notice, this list of conditions and the following disclaimer in the
00011  *        documentation and/or other materials provided with the distribution.
00012  *      * Neither the name of Texas Instruments Incorporated nor the
00013  *        names of its contributors may be used to endorse or promote products
00014  *        derived from this software without specific prior written permission.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00033 #ifndef _TOMP_QMSS_H_
00034 #define _TOMP_QMSS_H_
00035 
00036 #include <stdbool.h>
00037 #include <stdint.h>
00038 
00039 // QMSS LLD includes
00040 #include <ti/drv/qmss/qmss_drv.h>
00041 
00042 #include "tomp_defs.h"
00043 #include "tomp_log.h"
00044 
00045 typedef Qmss_QueueHnd tomp_queue_t;
00046 typedef void*         tomp_event_t;
00047 
00049 typedef struct
00050 {
00051     tomp_queue_t implicitTaskQ;
00052     tomp_queue_t exitQ;
00053     tomp_queue_t freeDescriptorQ;
00054     uint32_t     numExplicitTaskQ;
00055     tomp_queue_t explicitTaskQ[TOMP_DEVICE_NUM_CORES];
00056 } tomp_Queues;
00057 
00058 
00059 extern tomp_Queues     tomp_queues;
00060 extern Qmss_MemRegInfo tomp_qmssMemRegInfo;
00061 
00062 
00063 bool tomp_initGlobalNRT (bool memRegionInitialized);
00064 void tomp_exitGlobalNRT (void);
00065 bool tomp_initLocalNRT  (void);
00066 
00067 tomp_queue_t tomp_queueOpen   (int32_t qid);
00068 
00069 
00076 static inline tomp_event_t tomp_eventAlloc(void)
00077 {
00078     // The popped descriptor may have its size encoded in lower 4 bits.
00079     // QMSS_DESC_PTR clears these bits out.
00080     return (tomp_event_t)QMSS_DESC_PTR(
00081                                   Qmss_queuePop(tomp_queues.freeDescriptorQ));
00082 }
00083 
00084 
00094 static inline tomp_event_t tomp_eventAllocChecked(size_t size, 
00095                                                   const char *file, int line)
00096 {
00097     #if defined (TOMP_CHECK_LEVEL) && (TOMP_CHECK_LEVEL > 0)
00098     if (size > TOMP_EVENT_BUF_SIZE)
00099         tomp_logError(tomp_ErrorKind_EM_ALLOC_SIZE, file, line);
00100     #endif
00101 
00102     tomp_event_t event = tomp_eventAlloc();
00103     if (!event)
00104         tomp_logError(tomp_ErrorKind_NULL_PTR, file, line);
00105 
00106     return event;
00107 }
00108 
00109 
00115 static inline void tomp_eventFree(tomp_event_t event)
00116 {
00117     Qmss_queuePushDesc (tomp_queues.freeDescriptorQ, event);
00118     return;
00119 }
00120 
00121 
00128 static inline void tomp_eventPush(tomp_queue_t qHnd, tomp_event_t event)
00129 {
00130     Qmss_queuePushDesc (qHnd, event);
00131 }
00132 
00133 
00140 static inline void tomp_eventPushToHead(tomp_queue_t qHnd, tomp_event_t event)
00141 {
00142     Qmss_queuePush(qHnd, event, 0, TOMP_EVENT_BUF_SIZE, Qmss_Location_HEAD);
00143     return;
00144 }
00145 
00146 
00153 static inline tomp_event_t tomp_eventPop(tomp_queue_t qHnd)
00154 {
00155     // The popped descriptor may have its size encoded in lower 4 bits.
00156     // QMSS_DESC_PTR clears these bits out.
00157     return (tomp_event_t)QMSS_DESC_PTR(Qmss_queuePop(qHnd));
00158 }
00159 
00160 
00166 static inline void* tomp_event_pointer(tomp_event_t event)
00167 {
00168     return event;
00169 }
00170 
00171 #endif /*  _TOMP_QMSS_H_ */
 All Classes Files Functions Variables Typedefs Enumerations Defines