This commit is contained in:
ghostplant 2021-02-28 10:14:10 +08:00 коммит произвёл GitHub
Родитель ff7aaa3b7e
Коммит 1cba4d91ec
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 47 добавлений и 16 удалений

Просмотреть файл

@ -452,7 +452,7 @@ def main_compute(code_only=False):
if ('|plan/' not in ('|' + '|'.join(AntaresGlobal.attrs.options)) and
len(explicit_ops) >= 1 and
len(explicit_ops[-1].reduce_axis) > 0 and
backend.split('_win64')[0] in ['c-rocm', 'c-cuda', 'c-hlsl', 'c-ocl']):
backend.split('_')[0] in ['c-rocm', 'c-cuda', 'c-hlsl', 'c-ocl']):
tuner_type = 'Ansor'
else:
tuner_type = 'XGBoost'

Просмотреть файл

@ -11,7 +11,7 @@
#define NVCUDA_LIBRARY_PATH R"(C:\Windows\System32\nvcuda.dll)"
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[CUDA:DBG] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr), exit(1), 0))
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[Assertion Failed] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr), exit(1), 0))
#define LOAD_ONCE(func, ftype) static FARPROC __ ## func; if (!__ ## func) { __ ## func = GetProcAddress(hLibDll, #func); CHECK(__ ## func, "No such function symbol defined: %s()", #func); } auto func = (ftype)__ ## func;
namespace ab {
@ -101,7 +101,7 @@ namespace ab {
std::vector<void* const*> pargs(krnl_args.size());
for (int i = 0; i < pargs.size(); ++i)
pargs[i] = &krnl_args[i];
assert(0 == cuLaunchKernel(hFunc[0], (int)(size_t)hFunc[1], (int)(size_t)hFunc[2], (int)(size_t)hFunc[3], (int)(size_t)hFunc[4], (int)(size_t)hFunc[5], (int)(size_t)hFunc[6], 0, nullptr, (void**)pargs.data(), nullptr));
CHECK(0 == cuLaunchKernel(hFunc[0], (int)(size_t)hFunc[1], (int)(size_t)hFunc[2], (int)(size_t)hFunc[3], (int)(size_t)hFunc[4], (int)(size_t)hFunc[5], (int)(size_t)hFunc[6], 0, nullptr, (void**)pargs.data(), nullptr), "Failed to launch kernel.");
}
void memcpyHtoD(void *dptr, void *hptr, size_t byteSize) {

Просмотреть файл

@ -8,7 +8,7 @@
#define HLSL_LIBRARY_PATH R"(.\antares_hlsl_v0.2dev0_x64.dll)"
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[DX12:DBG] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n\n"), fflush(stderr), exit(1), 0))
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[Assertion Failed] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n\n"), fflush(stderr), exit(1), 0))
#define LOAD_ONCE(func, ftype) static FARPROC __ ## func; if (!__ ## func) { __ ## func = GetProcAddress(hLibDll, #func); CHECK(__ ## func, "No such function symbol defined: %s()", #func); } auto func = (ftype)__ ## func;
namespace ab {

Просмотреть файл

@ -39,12 +39,12 @@ namespace ab {
auto path = folder + "/module.cc";
FILE *fp = fopen(path.c_str(), "w");
assert(source.size() == fwrite(source.data(), 1, source.size(), fp));
CHECK_OK(source.size() == fwrite(source.data(), 1, source.size(), fp));
fclose(fp);
assert(0 == system(("g++ " + path + " -ldl -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
CHECK_OK(0 == system(("timeout 10s g++ " + path + " -ldl -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
void *hmod = dlopen((path + ".out").c_str(), RTLD_LAZY);
assert(0 == system(("rm -rf " + folder).c_str()));
CHECK_OK(0 == system(("rm -rf " + folder).c_str()));
return hmod;
}

Просмотреть файл

Просмотреть файл

@ -11,7 +11,7 @@
#define AMDHIP64_LIBRARY_PATH R"(C:\Windows\System32\amdhip64.dll)"
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[HIP:DBG] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr), exit(1), 0))
#define CHECK(stat, reason, ...) ((stat) ? 1 : (fprintf(stderr, "[Assertion Failed] "), fprintf(stderr, reason, ##__VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr), exit(1), 0))
#define LOAD_ONCE(func, ftype) static FARPROC __ ## func; if (!__ ## func) { __ ## func = GetProcAddress(hLibDll, #func); CHECK(__ ## func, "No such function symbol defined: %s()", #func); } auto func = (ftype)__ ## func;
namespace ab {
@ -85,7 +85,7 @@ namespace ab {
std::vector<void* const*> pargs(krnl_args.size());
for (int i = 0; i < pargs.size(); ++i)
pargs[i] = &krnl_args[i];
assert(0 == hipModuleLaunchKernel(hFunc[0], (int)(size_t)hFunc[1], (int)(size_t)hFunc[2], (int)(size_t)hFunc[3], (int)(size_t)hFunc[4], (int)(size_t)hFunc[5], (int)(size_t)hFunc[6], 0, nullptr, (void**)pargs.data(), nullptr));
CHECK(0 == hipModuleLaunchKernel(hFunc[0], (int)(size_t)hFunc[1], (int)(size_t)hFunc[2], (int)(size_t)hFunc[3], (int)(size_t)hFunc[4], (int)(size_t)hFunc[5], (int)(size_t)hFunc[6], 0, nullptr, (void**)pargs.data(), nullptr), "Failed to launch kernel.");
}
void memcpyHtoD(void *dptr, void *hptr, size_t byteSize) {

Просмотреть файл

@ -32,12 +32,12 @@ namespace ab {
auto path = folder + "/module.cc";
FILE *fp = fopen(path.c_str(), "w");
assert(source.size() == fwrite(source.data(), 1, source.size(), fp));
CHECK_OK(source.size() == fwrite(source.data(), 1, source.size(), fp));
fclose(fp);
assert(0 == system(("g++ " + path + " -ldl -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
CHECK_OK(0 == system(("timeout 10s g++ " + path + " -ldl -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
void *hmod = dlopen((path + ".out").c_str(), RTLD_LAZY);
assert(0 == system(("rm -rf " + folder).c_str()));
CHECK_OK(0 == system(("rm -rf " + folder).c_str()));
return hmod;
}

Просмотреть файл

@ -46,9 +46,9 @@ namespace ab {
auto path = folder + "/module.cc";
FILE *fp = fopen(path.c_str(), "w");
assert(source.size() == fwrite(source.data(), 1, source.size(), fp));
CHECK_OK(source.size() == fwrite(source.data(), 1, source.size(), fp));
fclose(fp);
assert(0 == system(("dpcpp " + path + " -std=c++17 -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
CHECK_OK(0 == system(("timeout 10s dpcpp " + path + " -std=c++17 -lpthread -fPIC -shared -O2 -o " + path + ".out").c_str()));
void *hmod = dlopen((path + ".out").c_str(), RTLD_LAZY | RTLD_GLOBAL);
system(("rm -rf " + folder).c_str());

Просмотреть файл

@ -0,0 +1,32 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONDONTWRITEBYTECODE 1
ENV HIP_PLATFORM hcc
ENV PATH $PATH:/opt/rocm/bin:/usr/local/nvidia/lib64/bin
ENV HSA_USERPTR_FOR_PAGED_MEM=0
ENV TF_ROCM_FUSION_ENABLE 1
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/opt/rocm/lib:$LD_LIBRARY_PATH
RUN env > /etc/environment
RUN apt-get update && apt install -y --no-install-recommends git ca-certificates \
python3-pip python3-wheel python3-setuptools python3-dev python3-pytest \
vim-tiny less netcat-openbsd inetutils-ping curl patch iproute2 \
g++ libpci3 libnuma-dev make file openssh-server kmod gdb libopenmpi-dev openmpi-bin psmisc \
autoconf automake autotools-dev libtool llvm-dev \
zlib1g-dev rename zip unzip librdmacm-dev gnupg \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN curl -sL http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \
printf "deb [arch=amd64] http://repo.radeon.com/rocm/apt/4.0.1/ xenial main" | tee /etc/apt/sources.list.d/rocm_hip.list && \
apt update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
rocm-dev rocblas hipsparse rccl rocfft rocrand miopen-hip rocthrust hip-rocclr && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN /bin/echo -e "set backspace=indent,eol,start\nset nocompatible\nset ts=4" > /etc/vim/vimrc.tiny
ADD ./engine /antares/engine
RUN /antares/engine/install_antares_host.sh && rm -rf /var/lib/apt/lists/* ~/.cache
ENV PATH $PATH:/opt/rocm-4.0.1/opencl/bin
RUN apt-get purge -y ocl-icd-libopencl1 && apt-get clean

Просмотреть файл

@ -4,7 +4,6 @@
#include <algorithm>
#include <chrono>
#include <cstdlib>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <iostream>
@ -23,7 +22,7 @@
#include <unistd.h>
#endif
#define CHECK_OK(x) ((x) ? 1 : (abort(), 0))
#define CHECK_OK(x) ((x) ? 1 : (fprintf(stderr, "[Assertion Failed] %s:%d\n", __FILE__, __LINE__), exit(1), 0))
#include "backend.hpp"