@@ -3785,15 +3785,26 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
3785
3785
const pi_program *InputPrograms,
3786
3786
void (*PFnNotify)(pi_program Program, void *UserData),
3787
3787
void *UserData, pi_program *RetProgram) {
3788
- (void )Options;
3789
-
3790
3788
// We only support one device with Level Zero currently.
3791
3789
pi_device Device = Context->Devices [0 ];
3792
3790
if (NumDevices != 1 ) {
3793
3791
zePrint (" piProgramLink: level_zero supports only one device." );
3794
3792
return PI_INVALID_VALUE;
3795
3793
}
3796
3794
3795
+ // We do not support any link flags at this time because the Level Zero API
3796
+ // does not have any way to pass flags that are specific to linking.
3797
+ if (Options && *Options != ' \0 ' ) {
3798
+ std::string ErrorMessage (
3799
+ " Level Zero does not support kernel link flags: \" " );
3800
+ ErrorMessage.append (Options);
3801
+ ErrorMessage.push_back (' \" ' );
3802
+ pi_program Program =
3803
+ new _pi_program (_pi_program::Invalid, Context, ErrorMessage);
3804
+ *RetProgram = Program;
3805
+ return PI_LINK_PROGRAM_FAILURE;
3806
+ }
3807
+
3797
3808
// Validate input parameters.
3798
3809
PI_ASSERT (DeviceList && DeviceList[0 ] == Device, PI_INVALID_DEVICE);
3799
3810
PI_ASSERT (!PFnNotify && !UserData, PI_INVALID_VALUE);
@@ -4051,16 +4062,26 @@ pi_result piProgramGetBuildInfo(pi_program Program, pi_device Device,
4051
4062
// with piProgramRegister?
4052
4063
return ReturnValue (" " );
4053
4064
} else if (ParamName == CL_PROGRAM_BUILD_LOG) {
4054
- // The OpenCL spec says an empty string is returned if there was no
4055
- // previous Compile, Build, or Link.
4056
- if (!Program->ZeBuildLog )
4057
- return ReturnValue (" " );
4058
- size_t LogSize = ParamValueSize;
4059
- ZE_CALL (zeModuleBuildLogGetString,
4060
- (Program->ZeBuildLog , &LogSize, pi_cast<char *>(ParamValue)));
4061
- if (ParamValueSizeRet) {
4062
- *ParamValueSizeRet = LogSize;
4065
+ // Check first to see if the plugin code recorded an error message.
4066
+ if (!Program->ErrorMessage .empty ()) {
4067
+ return ReturnValue (Program->ErrorMessage .c_str ());
4063
4068
}
4069
+
4070
+ // Next check if there is a Level Zero build log.
4071
+ if (Program->ZeBuildLog ) {
4072
+ size_t LogSize = ParamValueSize;
4073
+ ZE_CALL (zeModuleBuildLogGetString,
4074
+ (Program->ZeBuildLog , &LogSize, pi_cast<char *>(ParamValue)));
4075
+ if (ParamValueSizeRet) {
4076
+ *ParamValueSizeRet = LogSize;
4077
+ }
4078
+ return PI_SUCCESS;
4079
+ }
4080
+
4081
+ // Otherwise, there is no error. The OpenCL spec says to return an empty
4082
+ // string if there ws no previous attempt to compile, build, or link the
4083
+ // program.
4084
+ return ReturnValue (" " );
4064
4085
} else {
4065
4086
zePrint (" piProgramGetBuildInfo: unsupported ParamName\n " );
4066
4087
return PI_INVALID_VALUE;
0 commit comments