/*========================== begin_copyright_notice ============================
Copyright (C) 2024-2026 Intel Corporation

SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/

/*!
 * @file SIMD operation counting tool definitions
 */
#ifndef SIMDPROF_HLIF_H_
#define SIMDPROF_HLIF_H_

#include "hlif_basic_defs.h"

#if defined(__cplusplus)
#include "gtpin_api.h"
using namespace gtpin;
#endif

#pragma pack(push, 8)

/* ============================================================================================= */
// Struct SimdProfCountArgs
/* ============================================================================================= */
/// Common arguments of HLI function that counts active channels
typedef struct SimdProfCountArgs
{
    struct
    {
        uint32_t channelCounts[32]; ///< Counter of active channels
    } out;

    #if defined(__cplusplus)
    /// Constructor
    SimdProfCountArgs() { for (uint32_t i = 0; i < 32; out.channelCounts[i++] = 0); }
    #endif
} SimdProfCountArgs;

/* ============================================================================================= */
// Function CountEnableChannels
/* ============================================================================================= */
/*!
 * @brief HLI function that counts enabled channels
 * @param[in]       accessMask     Per-channel mask of memory accesses
 * @param[out]      counter        Per channel counters
 */
IGC_STACK_CALL void CountEnableChannels(uint32_t accessMask,
                                        __global SimdProfCountArgs* counter);

#if defined(__cplusplus)
using CountEnableChannelsFunc = GtHliFunction<void, uint32_t, SimdProfCountArgs*>;
#endif

/*!
 * @brief HLI function that counts enabled channels for SEND instruction
 * @param[in]       accessMask     Per-channel mask of memory accesses
 * @param[out]      counter        Per channel counters
 */
IGC_STACK_CALL void CountEnableChannelsForSend(uint32_t accessMask,
                                               __global SimdProfCountArgs* counter);

#if defined(__cplusplus)
using CountEnableChannelsForSendFunc = GtHliFunction<void, uint32_t, SimdProfCountArgs*>;
#endif

#pragma pack(pop)

#endif
