@@ -42,6 +42,10 @@ from dpctl._backend cimport ( # noqa: E211, E402;
4242 DPCTLKernel_GetPreferredWorkGroupSizeMultiple,
4343 DPCTLKernel_GetPrivateMemSize,
4444 DPCTLKernel_GetWorkGroupSize,
45+ DPCTLKernelBuildLog_Create,
46+ DPCTLKernelBuildLog_Delete,
47+ DPCTLKernelBuildLog_Get,
48+ DPCTLKernelBuildLogRef,
4549 DPCTLKernelBundle_Copy,
4650 DPCTLKernelBundle_CreateFromOCLSource,
4751 DPCTLKernelBundle_CreateFromSpirv,
@@ -383,7 +387,8 @@ cpdef create_program_from_sycl_source(SyclQueue q, unicode source,
383387
384388 Raises:
385389 SyclProgramCompilationError
386- If a SYCL kernel bundle could not be created.
390+ If a SYCL kernel bundle could not be created. The exception
391+ message contains the build log for more details.
387392 """
388393 cdef DPCTLSyclKernelBundleRef KBref
389394 cdef DPCTLSyclContextRef CRef = q.get_sycl_context().get_context_ref()
@@ -397,6 +402,7 @@ cpdef create_program_from_sycl_source(SyclQueue q, unicode source,
397402 cdef const char * sName
398403 cdef bytes bContent
399404 cdef const char * sContent
405+ cdef const char * buildLogContent
400406 for opt in copts:
401407 if not isinstance (opt, unicode ):
402408 DPCTLBuildOptionList_Delete(BuildOpts)
@@ -430,19 +436,26 @@ cpdef create_program_from_sycl_source(SyclQueue q, unicode source,
430436 sContent = < const char * > bContent
431437 DPCTLVirtualHeaderList_Append(VirtualHeaders, sName, sContent)
432438
439+ cdef DPCTLKernelBuildLogRef BuildLog
440+ BuildLog = DPCTLKernelBuildLog_Create()
441+
433442 KBref = DPCTLKernelBundle_CreateFromSYCLSource(CRef, DRef, Src,
434443 VirtualHeaders, KernelNames,
435- BuildOpts)
444+ BuildOpts, BuildLog )
436445
437446 if KBref is NULL :
447+ buildLogContent = DPCTLKernelBuildLog_Get(BuildLog)
448+ buildLogStr = str (buildLogContent, " utf-8" )
438449 DPCTLBuildOptionList_Delete(BuildOpts)
439450 DPCTLKernelNameList_Delete(KernelNames)
440451 DPCTLVirtualHeaderList_Delete(VirtualHeaders)
441- raise SyclProgramCompilationError()
452+ DPCTLKernelBuildLog_Delete(BuildLog)
453+ raise SyclProgramCompilationError(buildLogStr)
442454
443455 DPCTLBuildOptionList_Delete(BuildOpts)
444456 DPCTLKernelNameList_Delete(KernelNames)
445457 DPCTLVirtualHeaderList_Delete(VirtualHeaders)
458+ DPCTLKernelBuildLog_Delete(BuildLog)
446459
447460 return SyclProgram._create(KBref, True )
448461
0 commit comments