6666Add PTX code to a pending link operation.
6767"""
6868function add_data! (link:: CuLink , name:: String , code:: String )
69- data = unsafe_wrap (Vector{UInt8}, code)
70-
71- # there shouldn't be any embedded NULLs
72- checked_data = Base. unsafe_convert (Cstring, data)
73-
74- res = unsafe_cuLinkAddData_v2 (link, JIT_INPUT_PTX, pointer (checked_data), length (data),
75- name, 0 , C_NULL , C_NULL )
76- if res == ERROR_NO_BINARY_FOR_GPU ||
77- res == ERROR_INVALID_IMAGE ||
78- res == ERROR_INVALID_PTX
79- throw (CuError (res, unsafe_string (pointer (link. options[JIT_ERROR_LOG_BUFFER]))))
80- elseif res != SUCCESS
81- throw_api_error (res)
69+ GC. @preserve code begin
70+ # cuLinkAddData takes a Ptr{Cvoid} instead of a Cstring, because it accepts both
71+ # source and binary, so do the conversion (ensuring no embedded NULLs) ourselves
72+ data = Base. unsafe_convert (Cstring, code)
73+
74+ res = unsafe_cuLinkAddData_v2 (link, JIT_INPUT_PTX, pointer (data), length (code),
75+ name, 0 , C_NULL , C_NULL )
76+ if res == ERROR_NO_BINARY_FOR_GPU ||
77+ res == ERROR_INVALID_IMAGE ||
78+ res == ERROR_INVALID_PTX
79+ throw (CuError (res, unsafe_string (pointer (link. options[JIT_ERROR_LOG_BUFFER]))))
80+ elseif res != SUCCESS
81+ throw_api_error (res)
82+ end
8283 end
8384end
8485
8586"""
86- add_data!(link::CuLink, name::String, data::Vector{UInt8}, type::CUjitInputType )
87+ add_data!(link::CuLink, name::String, data::Vector{UInt8})
8788
8889Add object code to a pending link operation.
8990"""
9091function add_data! (link:: CuLink , name:: String , data:: Vector{UInt8} )
91- res = unsafe_cuLinkAddData_v2 (link, JIT_INPUT_OBJECT, pointer ( data) , length (data),
92+ res = unsafe_cuLinkAddData_v2 (link, JIT_INPUT_OBJECT, data, length (data),
9293 name, 0 , C_NULL , C_NULL )
9394 if res == ERROR_NO_BINARY_FOR_GPU ||
9495 res == ERROR_INVALID_IMAGE ||
@@ -97,8 +98,6 @@ function add_data!(link::CuLink, name::String, data::Vector{UInt8})
9798 elseif res != SUCCESS
9899 throw_api_error (res)
99100 end
100-
101- return
102101end
103102
104103"""
0 commit comments