some more cleaning

This commit is contained in:
Philippe Tillet
2019-08-23 19:22:38 -07:00
parent 732156b942
commit cb04ec0b3b
3 changed files with 27 additions and 28 deletions

View File

@@ -11,7 +11,7 @@ option(BUILD_PYTHON_MODULE "Build Python Triton bindings" OFF)
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
#llvm_map_components_to_libnames(llvm_libs all)
llvm_map_components_to_libnames(llvm_libs all)
# Default build type
if(NOT CMAKE_BUILD_TYPE)
@@ -51,7 +51,7 @@ endif()
# Triton
file(GLOB_RECURSE LIBTRITON_SRC lib/*.cpp lib/*.cc)
add_library(triton SHARED ${LIBTRITON_SRC} ${EIGHTCC_SRC} ${PYTHON_SRC})
add_library(triton SHARED ${LIBTRITON_SRC} ${PYTHON_SRC})
target_link_libraries(triton LLVM)
# Warning level

View File

@@ -185,29 +185,30 @@ host_module::host_module(driver::context * context, llvm::Module* src): module(c
/* ------------------------ */
ocl_module::ocl_module(driver::context * context, llvm::Module* src): module(context, cl_program(), true) {
init_llvm();
llvm::SmallVector<char, 0> buffer;
module::compile_llvm_module(src, "amdgcn-amd-amdhsa-amdgizcl", "gfx902", "", buffer, "code-object-v3", Object);
std::ofstream output("/tmp/tmp.o", std::ios::binary);
std::copy(buffer.begin(), buffer.end(), std::ostreambuf_iterator<char>(output));
system("ld.lld-8 /tmp/tmp.o -shared -o /tmp/tmp.o");
std::ifstream input("/tmp/tmp.o", std::ios::in | std::ios::binary );
std::vector<unsigned char> in_buffer(std::istreambuf_iterator<char>(input), {});
size_t sizes[] = {in_buffer.size()};
const unsigned char* data[] = {(unsigned char*)in_buffer.data()};
cl_int status;
cl_int err;
*cl_ = dispatch::clCreateProgramWithBinary(*context->cl(), 1, &*context->device()->cl(), sizes, data, &status, &err);
check(status);
check(err);
try{
dispatch::clBuildProgram(*cl_, 1, &*context->device()->cl(), NULL, NULL, NULL);
}
catch(...){
char log[2048];
dispatch::clGetProgramBuildInfo(*cl_, *context->device()->cl(), CL_PROGRAM_BUILD_LOG, 1024, log, NULL);
throw;
}
throw std::runtime_error("not supported");
// init_llvm();
// llvm::SmallVector<char, 0> buffer;
// module::compile_llvm_module(src, "amdgcn-amd-amdhsa-amdgizcl", "gfx902", "", buffer, "code-object-v3", Object);
// std::ofstream output("/tmp/tmp.o", std::ios::binary);
// std::copy(buffer.begin(), buffer.end(), std::ostreambuf_iterator<char>(output));
// system("ld.lld-8 /tmp/tmp.o -shared -o /tmp/tmp.o");
// std::ifstream input("/tmp/tmp.o", std::ios::in | std::ios::binary );
// std::vector<unsigned char> in_buffer(std::istreambuf_iterator<char>(input), {});
// size_t sizes[] = {in_buffer.size()};
// const unsigned char* data[] = {(unsigned char*)in_buffer.data()};
// cl_int status;
// cl_int err;
// *cl_ = dispatch::clCreateProgramWithBinary(*context->cl(), 1, &*context->device()->cl(), sizes, data, &status, &err);
// check(status);
// check(err);
// try{
// dispatch::clBuildProgram(*cl_, 1, &*context->device()->cl(), NULL, NULL, NULL);
// }
// catch(...){
// char log[2048];
// dispatch::clGetProgramBuildInfo(*cl_, *context->device()->cl(), CL_PROGRAM_BUILD_LOG, 1024, log, NULL);
// throw;
// }
}

View File

@@ -333,10 +333,8 @@ void Generator::VisitLabelStmt(LabelStmt* labelStmt) {
}
void Generator::VisitCompoundStmt(CompoundStmt* compoundStmt) {
if (compoundStmt->scope_){
// AllocObjects(compoundStmt->scope_);
if (compoundStmt->scope_)
pushScope();
}
for (auto stmt: compoundStmt->stmts_)
Visit(stmt);
if(compoundStmt->scope_)