[Beignet] [PATCH] Fix bugs about 2.0 pipe.
From: Junyan He Fix somes bugs of compiler and runtime, make 2.0's pipe work. Signed-off-by: Junyan He --- backend/src/backend/context.cpp | 3 +- backend/src/backend/gen_program_elf.cpp | 8 - src/cl_api.c| 51 src/cl_api_mem.c| 59 + src/cl_kernel.c | 16 +++-- src/cl_kernel.h | 1 + src/cl_mem.h| 4 +++ src/gen/cl_command_queue_gen.c | 4 +-- 8 files changed, 88 insertions(+), 58 deletions(-) diff --git a/backend/src/backend/context.cpp b/backend/src/backend/context.cpp index 51ef3a7..bdb1909 100644 --- a/backend/src/backend/context.cpp +++ b/backend/src/backend/context.cpp @@ -510,7 +510,8 @@ namespace gbe kernel->args[argID].size = sizeof(void*); break; case ir::FunctionArgument::PIPE: - kernel->args[argID].type = GBE_ARG_TYPE_SAMPLER; + kernel->args[argID].type = GBE_ARG_TYPE_PIPE; + kernel->args[argID].arg_space_type = GBE_ADDRESS_SPACE_GLOBAL; kernel->args[argID].size = sizeof(void*); kernel->args[argID].bti = arg.bti; break; diff --git a/backend/src/backend/gen_program_elf.cpp b/backend/src/backend/gen_program_elf.cpp index 0c78964..4e7842e 100644 --- a/backend/src/backend/gen_program_elf.cpp +++ b/backend/src/backend/gen_program_elf.cpp @@ -529,7 +529,13 @@ void GenProgramElfContext::emitOneKernel(GenKernel &kernel) argi->addr_space = kernel.getArgAddressSpace(i); argi->align = kernel.getArgAlign(i); -if (argi->type == GBE_ARG_TYPE_POINTER && argi->addr_space == GBE_ADDRESS_SPACE_GLOBAL) { +if (argi->type == GBE_ARG_TYPE_POINTER) { + if (argi->addr_space == GBE_ADDRESS_SPACE_GLOBAL || + (argi->addr_space == GBE_ADDRESS_SPACE_CONSTANT && kernel.getOclVersion() >= 200)) { +argi->extra = kernel.getArgBTI(i); + } +} else if (argi->type == GBE_ARG_TYPE_PIPE) { + assert(kernel.getOclVersion() >= 200); argi->extra = kernel.getArgBTI(i); } else if (argi->type == GBE_ARG_TYPE_IMAGE) { assert(image_data_sz > 0); diff --git a/src/cl_api.c b/src/cl_api.c index 397b941..6c5f4da 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -779,57 +779,6 @@ error: return err; } -cl_mem clCreatePipe (cl_context context, - cl_mem_flags flags, - cl_uint pipe_packet_size, - cl_uint pipe_max_packets, - const cl_pipe_properties *properties, - cl_int *errcode_ret) -{ - cl_mem mem = NULL; - cl_int err = CL_SUCCESS; - cl_uint device_max_size = 0; - - CHECK_CONTEXT (context); - - if(UNLIKELY((flags & ~(CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS)) != 0)) { -err = CL_INVALID_VALUE; -goto error; - } - - if(UNLIKELY(properties != NULL)) { -err = CL_INVALID_VALUE; -goto error; - } - - if(UNLIKELY(pipe_packet_size == 0 || pipe_max_packets == 0)) { -err = CL_INVALID_PIPE_SIZE; -goto error; - } - if ((err = cl_device_get_info(context->devices[0], -CL_DEVICE_PIPE_MAX_PACKET_SIZE, -sizeof(device_max_size), -&device_max_size, -NULL)) != CL_SUCCESS) { -goto error; - } - - if(UNLIKELY(pipe_packet_size > device_max_size)) { -err = CL_INVALID_PIPE_SIZE; -goto error; - } - - if(flags == 0) -flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS; - - mem = cl_mem_new_pipe(context, flags, pipe_packet_size, pipe_max_packets, &err); - -error: - if (errcode_ret) -*errcode_ret = err; - return mem; -} - cl_int clGetPipeInfo (cl_mem pipe, cl_pipe_info param_name, size_t param_value_size, diff --git a/src/cl_api_mem.c b/src/cl_api_mem.c index d842349..3836fff 100644 --- a/src/cl_api_mem.c +++ b/src/cl_api_mem.c @@ -2436,3 +2436,62 @@ clReleaseMemObject(cl_mem memobj) cl_mem_delete(memobj); return CL_SUCCESS; } + +cl_mem +clCreatePipe(cl_context context, + cl_mem_flags flags, + cl_uint pipe_packet_size, + cl_uint pipe_max_packets, + const cl_pipe_properties *properties, + cl_int *errcode_ret) +{ + cl_mem mem = NULL; + cl_int err = CL_SUCCESS; + cl_uint device_max_size = 0; + cl_int i; + + do { +if (!CL_OBJECT_IS_CONTEXT(context)) { + err = CL_INVALID_CONTEXT; + break; +} + +if ((flags & ~(CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS)) != 0) { + err = CL_INVALID_VALUE; + break; +} + +if (properties != NULL) { + err = CL_INVALID_VALUE; + break; +} + +if (pipe_packet_size == 0 || pipe_max_packets == 0) { + err = CL_INVALID_PIPE_SIZE; + break; +} + +for (i = 0; i < context->device_num; i++) { + if
Re: [Beignet] Random error with very low prabability in Haswell platform
Do you mean the ECC (Error Correcting Codes) on Intel GPU by “hardware mistakes”? Intel GPU adds one bit ECC support to L3 Cache since Broadwell. For details, you can look at: https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-bdw-vol07-3d_media_gpgpu_3.pdf I am not sure whether you problem is caused by the lack of ECC for L3 cache on Haswell. But I think it may help you if you can find a Broadwell machine to do some testing. Thanks! Ruiling From: Beignet [mailto:beignet-boun...@lists.freedesktop.org] On Behalf Of Gao, Sanshan Sent: Friday, April 7, 2017 4:47 PM To: beignet@lists.freedesktop.org Subject: [Beignet] Random error with very low prabability in Haswell platform Hi, all, I'm using Intel Iris Pro Graphics 5200 for general purpose computing, RSA decryption with OpenCL. However, I found that the calculated result would be wrong with very low probability in benchmark. In my experiments, this prabbility is bout "1%". And when I write out this cipher message to a file, which is not decrypted rightly in benchmark, and decrypt it individually, the result becomes right. Did someone else meet similar situation? I guess there would be some problems with this integrated GPGPU (i.e. there are some mistakes with hardware platform, but not software implementation). I remembered that I heared of such deduction before, but I ignored it, because I had not met such error. -- Platform: Intel Iris Pro Graphics 5200, OpenCL, Beignet Grandtruth: computed reuslt by OpenSSL library -- Thanks, Sanshan ___ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet
Re: [Beignet] issue with cl
Sorry - I posted that suggestion in a hurry, and forgot that Haswell was broken in Linux <=4.2. I'll investigate, as this probably means Debian 9/Ubuntu 17.04's beignet is totally broken... On 10/04/17 08:40, Michal B wrote: Hi Rebecca, i submitted my bug to: https://bugs.freedesktop.org/show_bug.cgi?id=100639 i compiled myself kernel because i needed specific hardware support - kernel 3.16 is too old for my hardware, something is completely wrong, clinfo is not working ... results: root@debianNUC:~/# clinfo Beignet: self-test failed: (3, 7, 5) + (5, 7, 3) returned (3, 7, 5) This can usually be fixed by upgrading Linux to >= 4.2, see /usr/share/doc/beignet-dev/Beignet.html or https://www.freedesktop.org/wiki/Software/Beignet/ Beignet: disabling non-working device Beignet: self-test failed: (3, 7, 5) + (5, 7, 3) returned (3, 7, 5) See README.md or http://www.freedesktop.org/wiki/Software/Beignet/ Beignet: disabling non-working device Number of platforms: 2 Platform Profile: FULL_PROFILE Platform Version: OpenCL 1.2 beignet 1.3 Platform Name: Intel Gen OCL Driver Platform Vendor: Intel Platform Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short Platform Profile: FULL_PROFILE Platform Version: OpenCL 1.2 beignet 1.3 Platform Name: Intel Gen OCL Driver Platform Vendor: Intel Platform Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short cl_khr_gl_sharing Platform Name: Intel Gen OCL Driver Number of devices: 0 Platform Name: Intel Gen OCL Driver Number of devices: 0 root@debianNUC:~/# uname -na Linux debianNUC 3.18.48 #1 SMP Sat Feb 18 12:56:22 CET 2017 x86_64 GNU/Linux 2017-04-10 9:21 GMT+02:00 Rebecca N. Palmer : If you can, revert to the jessie (not -backports) kernel: that fixes this issue for me (on Ivybridge). ___ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet
[Beignet] [PATCH newRT] Add relocation table for ELF file to support 2.0
From: Junyan He 2.0 Spec require a global memory and the global pointer can point to any global variable. We add a rela.rodata section in ELF file to support the relocation. The global memory just available for 2.0 later. Signed-off-by: Junyan He --- CMakeLists.txt | 2 +- backend/src/backend/gen_program_elf.cpp | 54 -- backend/src/ir/reloc.cpp| 2 +- backend/src/ir/reloc.hpp| 22 +++- backend/src/llvm/llvm_gen_backend.cpp | 3 +- src/cl_gen7_device.h| 2 +- src/gen/cl_command_queue_gen.c | 52 +- src/gen/cl_gen.h| 25 + src/gen/cl_gen75_device.h | 2 +- src/gen/cl_gen7_device.h| 2 +- src/gen/cl_gen8_device.h| 2 +- src/gen/cl_gen9_device.h| 5 +- src/gen/cl_gen_device_common.h | 4 - src/gen/cl_kernel_gen.c | 8 +- src/gen/cl_program_gen.c| 178 ++-- src/gen/intel_driver.c | 11 +- src/gen/intel_driver.h | 2 + 17 files changed, 327 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe895d0..e6babe4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,7 +239,7 @@ IF (EXPERIMENTAL_DOUBLE) ADD_DEFINITIONS(-DENABLE_FP64) ENDIF(EXPERIMENTAL_DOUBLE) -SET(CAN_OPENCL_20 OFF) +SET(CAN_OPENCL_20 ON) IF (CMAKE_SIZEOF_VOID_P EQUAL 4) SET(CAN_OPENCL_20 OFF) ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4) diff --git a/backend/src/backend/gen_program_elf.cpp b/backend/src/backend/gen_program_elf.cpp index feea392..0c78964 100644 --- a/backend/src/backend/gen_program_elf.cpp +++ b/backend/src/backend/gen_program_elf.cpp @@ -262,10 +262,12 @@ public: section *ker_info_sec; section *cl_info_sec; section *rodata_sec; + section *reloc_rodata_sec; symbol_section_accessor *syma; string_section_accessor *stra; note_section_accessor *note_writer; note_section_accessor *cl_note_writer; + relocation_section_accessor *rela; Elf32_Word sym_num; uint64_t bitcode_offset; @@ -280,8 +282,8 @@ public: GenProgramElfContext::GenProgramElfContext(GenProgram &prog) : genProg(prog), text_sec(NULL), sym_sec(NULL), strtab_sec(NULL), ker_info_sec(NULL), -cl_info_sec(NULL), rodata_sec(NULL), syma(NULL), stra(NULL), note_writer(NULL), -cl_note_writer(NULL), sym_num(0), bitcode_offset(0) +cl_info_sec(NULL), rodata_sec(NULL), reloc_rodata_sec(NULL), syma(NULL), stra(NULL), +note_writer(NULL), cl_note_writer(NULL), rela(NULL), sym_num(0), bitcode_offset(0) { writer.create(ELFCLASS64, ELFDATA2LSB); writer.set_os_abi(ELFOSABI_LINUX); @@ -339,6 +341,8 @@ GenProgramElfContext::~GenProgramElfContext(void) GBE_DELETE(note_writer); if (cl_note_writer) GBE_DELETE(cl_note_writer); + if (rela) +GBE_DELETE(rela); } /*Store the special vitrual register map */ @@ -653,6 +657,41 @@ GenProgram::toBinaryFormat(size_t &ret_size) getGlobalConstantData(const_data); elf_ctx->rodata_sec->set_data(const_data, getGlobalConstantSize()); GBE_FREE(const_data); + +if (getGlobalRelocCount() > 0) { + elf_ctx->reloc_rodata_sec = elf_ctx->writer.sections.add(".rel.rodata"); + elf_ctx->reloc_rodata_sec->set_type(SHT_RELA); + elf_ctx->reloc_rodata_sec->set_info(elf_ctx->rodata_sec->get_index()); + elf_ctx->reloc_rodata_sec->set_addr_align(0x4); + elf_ctx->reloc_rodata_sec->set_entry_size(elf_ctx->writer.get_default_entry_size(SHT_RELA)); + elf_ctx->reloc_rodata_sec->set_link(elf_ctx->sym_sec->get_index()); + elf_ctx->rela = GBE_NEW(relocation_section_accessor, elf_ctx->writer, elf_ctx->reloc_rodata_sec); + + char *reloc_data = static_cast(GBE_MALLOC(getGlobalRelocCount() * sizeof(ir::RelocEntry))); + getGlobalRelocTable(reloc_data); + ir::RelocEntry *rel_entry = reinterpret_cast(reloc_data); + std::sort(rel_entry, rel_entry + getGlobalRelocCount(), +[](ir::RelocEntry &a, ir::RelocEntry &b) { return a.defOffset < b.defOffset; }); + + std::string last_name; + unsigned int var_defOffset; + Elf_Word var_symbol; + for (uint32_t e = 0; e < getGlobalRelocCount(); e++) { +if (last_name != relocTable->getEntryName(rel_entry[e])) { + // Add a global symbol + var_defOffset = rel_entry[e].defOffset; + last_name = relocTable->getEntryName(rel_entry[e]); + assert(last_name != ""); // Must have a name + var_symbol = elf_ctx->syma->add_symbol(*elf_ctx->stra, last_name.c_str(), var_defOffset, + this->constantSet->getConstant(last_name).getSize(), + STB_GLOBAL, STT_OBJECT, 0, elf_ctx->rodata_sec->get_index()); +} +elf_ctx->rela->add_entry(rel_entry[e].refOffset, var_symbol, (uns
Re: [Beignet] issue with cl
Hi Rebecca, i submitted my bug to: https://bugs.freedesktop.org/show_bug.cgi?id=100639 i compiled myself kernel because i needed specific hardware support - kernel 3.16 is too old for my hardware, something is completely wrong, clinfo is not working ... results: root@debianNUC:~/# clinfo Beignet: self-test failed: (3, 7, 5) + (5, 7, 3) returned (3, 7, 5) This can usually be fixed by upgrading Linux to >= 4.2, see /usr/share/doc/beignet-dev/Beignet.html or https://www.freedesktop.org/wiki/Software/Beignet/ Beignet: disabling non-working device Beignet: self-test failed: (3, 7, 5) + (5, 7, 3) returned (3, 7, 5) See README.md or http://www.freedesktop.org/wiki/Software/Beignet/ Beignet: disabling non-working device Number of platforms: 2 Platform Profile: FULL_PROFILE Platform Version: OpenCL 1.2 beignet 1.3 Platform Name: Intel Gen OCL Driver Platform Vendor: Intel Platform Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short Platform Profile: FULL_PROFILE Platform Version: OpenCL 1.2 beignet 1.3 Platform Name: Intel Gen OCL Driver Platform Vendor: Intel Platform Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short cl_khr_gl_sharing Platform Name: Intel Gen OCL Driver Number of devices: 0 Platform Name: Intel Gen OCL Driver Number of devices: 0 root@debianNUC:~/# uname -na Linux debianNUC 3.18.48 #1 SMP Sat Feb 18 12:56:22 CET 2017 x86_64 GNU/Linux 2017-04-10 9:21 GMT+02:00 Rebecca N. Palmer : > If you can, revert to the jessie (not -backports) kernel: that fixes this > issue for me (on Ivybridge). > ___ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet
Re: [Beignet] issue with cl
If you can, revert to the jessie (not -backports) kernel: that fixes this issue for me (on Ivybridge). ___ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet