/*
 * oclh_clapi_callbacks.c
 *      Author: havock
 */
#include <stdio.h>
#include <oclh_h_settings.h>
#include <oclh_h_ws_base.h>
#include <oclh_h_ws_base_log.h>
#include <oclh_h_clapi_callbacks.h>

void CL_CALLBACK _ghf_CtxEvent(const char*  pcErrInfo,
                               const void*  pvPrivInfo,
                                     size_t szPrivInfo,
                                     void*  pvUserData) {
    char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
    _GHT_WRKSET* pwSet=(_GHT_WRKSET*)pvUserData;
    snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
             "Ctx callback | err: %s",
             pcErrInfo?pcErrInfo:"Undefined");
    _ghf_logWS_Msg(*pwSet, pcLogMsg);
    snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
             "Ctx callback | priv_inf_addr:0x%lx "
             "priv_inf_sz: %f MiB/%f KiB/%lu B user_data_addr:0x%lx",
             (uint64_t)pvPrivInfo,
             ((float)szPrivInfo)/1024e0f/1024e0f, ((float)szPrivInfo)/1024e0f,
             (uint64_t)szPrivInfo, (uint64_t)pvUserData);
    _ghf_logWS_Msg(*pwSet, pcLogMsg);
    return;
}

void CL_CALLBACK _ghf_LinkEvent(cl_program Program, void*  pvUserData) {
    char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
    _GHT_WRKSET* pwSet=(_GHT_WRKSET*)pvUserData;
    snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
             "Linker callback| program: 0x%lx user_data_addr:0x%lx",
             (uint64_t)Program, (uint64_t)pvUserData);
    _ghf_logWS_Msg(*pwSet, pcLogMsg);
    return;
}
