Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Util MP - Profile Sample.h
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_UTIL_MP_PROFILE_SAMPLE_H)
#define TGS_COMMON_UTIL_MP_PROFILE_SAMPLE_H
#pragma once


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
#if TgCOMPILE_64BIT_ATOMIC

/* WARNING: Keep in mind that there is no guarantee (and in fact is unlikely) that the execution of a large amount of code will not be stalled by other thread processing */
/* taking the CPU context.  Therefore, the timing reported by this process is more of a rough guide or framework since it only considers the time between the two markers */
/* (start, stop) and not the actual amount of time spent processing on the hardware. */
/* We use 16 bits to record the max depth (recursion) into the profile marker, and 48 bits (of a possible 64 bits) to record the the CPU cycle count | timer.  Note that */
/* the system returns the relative count from process start. */
TgTYPE_STRUCT(STg2_Profile_Record,)
{
#if TgCOMPILE_CACHE_LINE_SIZE > 8
    volatile TgATOMIC_SINT64                    m_iRecord_DepthAndStart;
    TgUINT08                                    m_uiPad0[TgCOMPILE_CACHE_LINE_SIZE - 8];
    TgATOMIC_SINT64                             m_iRecord_Idle_Total;
    TgUINT08                                    m_uiPad1[TgCOMPILE_CACHE_LINE_SIZE - 8];
    TgATOMIC_SINT64                             m_iRecord_Sample_Total;
    TgUINT08                                    m_uiPad2[TgCOMPILE_CACHE_LINE_SIZE - 8];
#else
    volatile TgATOMIC_SINT64                    m_iRecord_DepthAndStart;
    TgATOMIC_SINT64                             m_iRecord_Idle_Total;
    TgATOMIC_SINT64                             m_iRecord_Sample_Total;
#endif
    TgFLOAT32                                   m_fReport_Sample;
    TgFLOAT32                                   m_fReport_Idle;
    TgFLOAT32                                   m_fReport_Total;
    TgUINT08                                    m_uiPad3[4];
};

TgINLINE TgVOID                             tgProfile_Sample_Reset( PCU_STg2_Profile_Record );
TgINLINE TgSINT64                           tgProfile_Sample_Start( PCU_STg2_Profile_Record );
TgINLINE TgSINT64                           tgProfile_Sample_Stop( PCU_STg2_Profile_Record  );
TgINLINE TgVOID                             tgProfile_Sample_Report( PCU_STg2_Profile_Record );

/*# TgCOMPILE_64BIT_ATOMIC */
#endif


/* ====================================================================================================================================================================== */
#endif