[BUILD] Remove compilation warnings

This commit is contained in:
Philippe Tillet
2021-03-24 01:24:50 -04:00
committed by Philippe Tillet
parent b352bc79e3
commit 5ba5a77561
6 changed files with 26 additions and 59 deletions

View File

@@ -28,7 +28,7 @@ using namespace llvm;
#define f16_ty builder_->getHalfTy()
#define f32_ty builder_->getFloatTy()
#define i32_ty builder_->getInt32Ty()
#define vec_ty(...) VectorType::get(__VA_ARGS__)
#define vec_ty(type, num_el) VectorType::get(type, num_el, false)
#define ptr_ty(...) PointerType::get(__VA_ARGS__)
// constants
#define i32(...) builder_->getInt32(__VA_ARGS__)

View File

@@ -212,44 +212,23 @@ void kernel::operator()(const std::string& args, driver::stream *stream, const s
stream->enqueue(&*ker_, grid, {(size_t)opt.num_warps * 32, 1, 1}, (void*)args.data(), args.size(), shared_mem_);
}
std::string kernel::get_asm(asm_mode_t mode) {
switch(mode){
case ASM_LLIR:{
return ((driver::cu_module*)mod_.get())->llir();
}
case ASM_NV_PTX:
case ASM_NV_SASS:{
std::string ptx = ((driver::cu_module*)mod_.get())->ptx();
// SASS
std::string input = std::tmpnam(nullptr);
std::string output = std::tmpnam(nullptr);
std::ofstream ofs(input);
ofs << ptx;
ofs.close();
if(mode == ASM_NV_PTX)
return ptx;
std::string cmd;
int err;
// compile ptx
driver::cu_device* cu_device = (driver::cu_device*)dev_;
cmd = "ptxas --gpu-name=sm_" + std::to_string(cu_device->compute_capability()) + " " + input + " -o " + input + ".o";
err = system(cmd.c_str());
// disassemble
cmd = "cuobjdump --dump-sass " + input + ".o >> " + output;
err = system(cmd.c_str());
std::regex comment(" *\\/\\* 0x[0-9a-f]+ \\*\\/");
std::string to_delete = " /*";
std::ifstream ifs(output);
std::string line;
std::string sass;
while(std::getline(ifs, line))
if(!std::regex_match(line, comment))
sass += line + "\n";
return sass;
}
default:
return "";
std::string kernel::get_asm(const std::string& mode) {
std::vector<std::string> modes = {"llir", "ptx"};
if(std::find(modes.begin(), modes.end(), mode) == modes.end()){
std::string err = "Unrecognized mode. Supported values are: ";
for(std::string m: modes){
if(m != modes[0])
err += ", ";
err += m;
}
throw std::runtime_error(err);
}
if(mode == "llir")
return ((driver::cu_module*)mod_.get())->llir();
if(mode == "ptx")
return ((driver::cu_module*)mod_.get())->ptx();
assert(false);
return "";
}
/* --------------------------------- */
/* --------------------------------- */