#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "acl_wrapper_basic.h"
#define ACL_WRAPPER_MEM_MALLOC_HUGE_FIRST 0
#define ACL_WRAPPER_MEM_MALLOC_HUGE_ONLY 1
#define ACL_WRAPPER_MEM_MALLOC_NORMAL_ONLY 2
#define ACL_WRAPPER_MEM_MALLOC_HUGE_FIRST_P2P 3
#define ACL_WRAPPER_MEM_MALLOC_HUGE_ONLY_P2P 4
#define ACL_WRAPPER_MEM_MALLOC_NORMAL_ONLY_P2P 5
#define ACL_WRAPPER_MEM_MALLOC_HUGE1G_ONLY 6
#define ACL_WRAPPER_MEM_MALLOC_HUGE1G_ONLY_P2P 7
int main() {
printf("Testing basic ACL wrapper layer\n");
int ret = acl_wrapper_init(NULL);
if (ret != 0) {
printf("Failed to initialize ACL, ret=%d\n", ret);
return -1;
}
printf("ACL initialized successfully\n");
uint32_t device_count = 0;
ret = acl_wrapper_get_device_count(&device_count);
if (ret != 0) {
printf("Failed to get device count, ret=%d\n", ret);
acl_wrapper_finalize();
return -1;
}
printf("Device count: %u\n", device_count);
if (device_count > 0) {
ret = acl_wrapper_set_device(0);
if (ret != 0) {
printf("Failed to set device, ret=%d\n", ret);
acl_wrapper_finalize();
return -1;
}
printf("Device set successfully\n");
void *host_buffer = acl_wrapper_rt_malloc_host(1024 * sizeof(float));
if (host_buffer == NULL) {
printf("Failed to allocate host memory\n");
} else {
printf("Successfully allocated host memory\n");
void *device_buffer = NULL;
uint64_t buffer_size = 1024 * sizeof(float);
ret = acl_wrapper_rt_malloc(&device_buffer, buffer_size, ACL_WRAPPER_MEM_MALLOC_NORMAL_ONLY);
if (ret != 0 || device_buffer == NULL) {
printf("Failed to allocate device memory, ret=%d\n", ret);
} else {
printf("Successfully allocated device memory, size=%lu bytes\n", (unsigned long)buffer_size);
ret = acl_wrapper_rt_memset(device_buffer, buffer_size, 0, buffer_size);
if (ret != 0) {
printf("Failed to memset device memory, ret=%d\n", ret);
} else {
printf("Device memory filled successfully\n");
}
acl_wrapper_rt_free(device_buffer);
}
acl_wrapper_rt_free_host(host_buffer);
}
}
acl_wrapper_finalize();
printf("ACL resources cleaned up\n");
printf("Basic ACL wrapper test completed\n");
return 0;
}