Skip to content

Commit

Permalink
fix select testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
1837897414 committed Sep 15, 2024
1 parent b833a4f commit e25e2b7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/CL/devices/ventus/pocl_ventus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ step5 make a writefile for chisel
uint32_t kernel_entry;
#ifdef __linux__
std::string kernel_name(meta->name);
std::string kernel_entry_cmd = std::string(R"(nm -s object.riscv | grep -w 'T' | grep -w )") +kernel_name+ std::string(R"( | grep -o '^[^ ]*')");
std::string kernel_entry_cmd = std::string(R"(nm -s )") + kernel_name + std::string(R"(.riscv | grep -w 'T' | grep -w )") +kernel_name+ std::string(R"( | grep -o '^[^ ]*')");
FILE *fp0 = popen(kernel_entry_cmd.c_str(), "r");
if(fp0 == NULL) {
POCL_MSG_ERR("running compile kernel failed");
Expand Down Expand Up @@ -709,21 +709,26 @@ step5 make a writefile for chisel
assert(pocl_exists(ventus_assembler.c_str()));
}
system((std::string("chmod +x ") + assembler_path).c_str());
assembler_path += " object";
assembler_path += " ";
assembler_path += kernel_name;
system(assembler_path.c_str());
POCL_MSG_PRINT_VENTUS("Vmem file has been written to object.vmem\n");
POCL_MSG_PRINT_VENTUS("Vmem file has been written to kernel_name.vmem\n");
#elif
POCL_MSG_ERR("This operate system is not supported now by ventus, please use linux! \n");
exit(1);
#endif

//pass in vmem file
char filename[]="object.riscv";
char filename[256];
strcpy(filename, meta->name);
strcat(filename, ".riscv");
///将text段搬到ddr(not related to spike),并且起始地址必须是0x80000000(spike专用),verilator需要先解析出vmem,然后上传程序段
vt_upload_kernel_file(d->vt_device,filename,0);
#ifdef PRINT_CHISEL_TESTCODE
//this file includes all kernels of executable file, kernel actually to be executed is determined by metadata.
std::ifstream vmem_file("object.vmem");
char vmem_filename[256];
strcpy(vmem_filename, meta->name);
std::ifstream vmem_file(strcat(vmem_filename, ".vmem"));
vmem_file.seekg(0, vmem_file.end);
auto size = vmem_file.tellg();
std::string content;
Expand Down Expand Up @@ -1405,18 +1410,20 @@ int pocl_ventus_post_build_program (cl_program program, cl_uint device_i) {

char program_bc_path[POCL_FILENAME_LENGTH];


//pocl_cache_create_program_cachedir(program, device_i, program->source,
// strlen(program->source),
// program_bc_path);
//TODO: move .cl and .riscv file into program_bc_path, and let spike read file from this path.
std::ofstream outfile("object.cl");
char cl_filename[256];
strcpy(cl_filename, program->kernel_meta->name);
char *sourcefilename = strcat(cl_filename, ".cl");
std::ofstream outfile(sourcefilename);
outfile << program->source;
outfile.close();

cl_device_id device = program->devices[device_i];

ss_cmd << clang_path <<" -cl-std=CL2.0 " << "-target " << device->llvm_target_triplet << " -mcpu=" << device->llvm_cpu << " object.cl " << " -o " << "object.riscv ";
ss_cmd << clang_path <<" -cl-std=CL2.0 " << "-target " << device->llvm_target_triplet << " -mcpu=" << device->llvm_cpu << " " << sourcefilename << " " << " -o " << program->kernel_meta->name << ".riscv ";
for(int i = 0; ventus_final_ld_flags[i] != NULL; i++) {
ss_cmd << ventus_final_ld_flags[i];
}
Expand Down

0 comments on commit e25e2b7

Please sign in to comment.