代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#if HAVE_MLU_RUNTIME
#include "cnrt.h"
#include "mlu_op.h"
#include "cn_api.h" // CNresult
#include <unistd.h> // getpid()
#endif
#if HAVE_ROCM_RUNTIME
#include <hsa.h>
#include <hip/hip_runtime.h>
// hipError_t hipSuccess
#include <hsa_ext_amd.h>
#endif
/* Error Macro*/
#define rdma_error(msg, args...) do {\
fprintf(stderr, "%s : %d : ERROR : " msg "\n", __FILE__, __LINE__, ## args);\
}while(0);
/* Info Macro*/
#define rdma_info(msg, args...) do {\
fprintf(stderr, "%s : %d : INFO : " msg "\n", __FILE__, __LINE__ , ## args);\
}while(0);
static int gpu_initialized = 0;
typedef struct mem_s {
void *ptr;
#if HAVE_MLU_RUNTIME
CNaddr addr;
#endif
int size;
} mem_t;
void mem_alloc(mem_t *buf);
void mem_free(mem_t *buf);
#if HAVE_HOST_RUNTIME
void host_buffer_malloc(mem_t *buf);
void host_buffer_free(mem_t *buf);
#endif
#if HAVE_MLU_RUNTIME
static inline const char *getErrorName(CNresult error)
{
const char *str;
cnGetErrorName(error, &str);
return str;
}
static inline const char *getErrorString(CNresult error)
{
const char *str;
cnGetErrorString(error, &str);
return str;
}
#define ERROR_CHECK(ret) \
do { \
CNresult r__ = (ret); \
if (r__ != CN_SUCCESS) { \
printf( \
"error occur, func: %s, line: %d, ret:%d, cn_error_code:%s, cn_error_string:%s\n", \
__func__, __LINE__, r__, getErrorName(r__), getErrorString(r__)); \
return; \
} \
} while (0)
static CNdev cnDevice;
static CNcontext cnContext;
void mlu_init();
void mlu_buffer_malloc(mem_t *buf);
void mlu_buffer_free(mem_t *buf);
#endif
#if HAVE_ROCM_RUNTIME
#define MAX_AGENTS 127
static struct agents {
int num;
hsa_agent_t agents[MAX_AGENTS];
int num_gpu;
hsa_agent_t gpu_agents[MAX_AGENTS];
} rocm_agents;
void rocm_init();
void rocm_buffer_malloc(mem_t *buf);
void rocm_buffer_free(mem_t *buf);
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。