@@ -175,70 +175,72 @@ impl Module {
175
175
}
176
176
}
177
177
178
- /// Creates a new module by loading a fatbin (fat binary) file.
179
- ///
180
- /// Fatbinary files are files that contain multiple ptx or cubin files. The driver will choose already-built
181
- /// cubin if it is present, and otherwise JIT compile any PTX in the file to cubin.
182
- ///
183
- /// # Example
184
- ///
185
- /// ```
186
- /// # use cust::*;
187
- /// # use std::error::Error;
188
- /// # fn main() -> Result<(), Box<dyn Error>> {
189
- /// # let _ctx = quick_init()?;
190
- /// use cust::module::Module;
191
- /// let fatbin_bytes = std::fs::read("./resources/add.cubin")?;
192
- /// assert!(fatbin_bytes.contains(&0));
193
- /// let module = Module::from_cubin(&fatbin_bytes, &[])?;
194
- /// # Ok(())
195
- /// # }
196
- /// ```
197
- pub fn from_fatbin < T : AsRef < [ u8 ] > > (
198
- bytes : T ,
199
- options : & [ ModuleJitOption ] ,
200
- ) -> CudaResult < Module > {
201
- let mut bytes = bytes. as_ref ( ) . to_vec ( ) ;
202
- bytes. push ( 0 ) ;
203
- // fatbins are just ELF files like cubins, and cuModuleLoadDataEx accepts ptx, cubin, and fatbin.
204
- // We just make the distinction in case we want to do anything extra in the future. As well
205
- // as keep things explicit to anyone reading the code.
206
- Self :: from_cubin ( bytes, options)
207
- }
178
+ // TODO(RDambrosio016): figure out why the heck cuda rejects cubins literally made by nvcc and loaded by fs::read
208
179
209
- pub unsafe fn from_fatbin_unchecked < T : AsRef < [ u8 ] > > (
210
- bytes : T ,
211
- options : & [ ModuleJitOption ] ,
212
- ) -> CudaResult < Module > {
213
- Self :: from_cubin_unchecked ( bytes, options)
214
- }
180
+ // /// Creates a new module by loading a fatbin (fat binary) file.
181
+ // ///
182
+ // /// Fatbinary files are files that contain multiple ptx or cubin files. The driver will choose already-built
183
+ // /// cubin if it is present, and otherwise JIT compile any PTX in the file to cubin.
184
+ // ///
185
+ // /// # Example
186
+ // ///
187
+ // /// ```
188
+ // /// # use cust::*;
189
+ // /// # use std::error::Error;
190
+ // /// # fn main() -> Result<(), Box<dyn Error>> {
191
+ // /// # let _ctx = quick_init()?;
192
+ // /// use cust::module::Module;
193
+ // /// let fatbin_bytes = std::fs::read("./resources/add.cubin")?;
194
+ // /// assert!(fatbin_bytes.contains(&0));
195
+ // /// let module = Module::from_cubin(&fatbin_bytes, &[])?;
196
+ // /// # Ok(())
197
+ // /// # }
198
+ // /// ```
199
+ // pub fn from_fatbin<T: AsRef<[u8]>>(
200
+ // bytes: T,
201
+ // options: &[ModuleJitOption],
202
+ // ) -> CudaResult<Module> {
203
+ // let mut bytes = bytes.as_ref().to_vec();
204
+ // bytes.push(0);
205
+ // // fatbins are just ELF files like cubins, and cuModuleLoadDataEx accepts ptx, cubin, and fatbin.
206
+ // // We just make the distinction in case we want to do anything extra in the future. As well
207
+ // // as keep things explicit to anyone reading the code.
208
+ // Self::from_cubin(bytes, options)
209
+ // }
215
210
216
- pub fn from_cubin < T : AsRef < [ u8 ] > > ( bytes : T , options : & [ ModuleJitOption ] ) -> CudaResult < Module > {
217
- let bytes = bytes . as_ref ( ) ;
218
- goblin :: elf :: Elf :: parse ( bytes ) . expect ( "Cubin/Fatbin was not valid ELF!" ) ;
219
- // SAFETY: we verified the bytes were valid ELF
220
- unsafe { Self :: from_cubin_unchecked ( bytes, options) }
221
- }
211
+ // pub unsafe fn from_fatbin_unchecked <T: AsRef<[u8]>>(
212
+ // bytes: T,
213
+ // options: &[ModuleJitOption],
214
+ // ) -> CudaResult<Module> {
215
+ // Self::from_cubin_unchecked(bytes, options)
216
+ // }
222
217
223
- pub unsafe fn from_cubin_unchecked < T : AsRef < [ u8 ] > > (
224
- bytes : T ,
225
- options : & [ ModuleJitOption ] ,
226
- ) -> CudaResult < Module > {
227
- let bytes = bytes. as_ref ( ) ;
228
- let mut module = Module {
229
- inner : ptr:: null_mut ( ) ,
230
- } ;
231
- let ( mut options, mut option_values) = ModuleJitOption :: into_raw ( options) ;
232
- cuda:: cuModuleLoadDataEx (
233
- & mut module. inner as * mut cuda:: CUmodule ,
234
- bytes. as_ptr ( ) as * const c_void ,
235
- options. len ( ) as c_uint ,
236
- options. as_mut_ptr ( ) ,
237
- option_values. as_mut_ptr ( ) ,
238
- )
239
- . to_result ( ) ?;
240
- Ok ( module)
241
- }
218
+ // pub fn from_cubin<T: AsRef<[u8]>>(bytes: T, options: &[ModuleJitOption]) -> CudaResult<Module> {
219
+ // let bytes = bytes.as_ref();
220
+ // goblin::elf::Elf::parse(bytes).expect("Cubin/Fatbin was not valid ELF!");
221
+ // // SAFETY: we verified the bytes were valid ELF
222
+ // unsafe { Self::from_cubin_unchecked(bytes, options) }
223
+ // }
224
+
225
+ // pub unsafe fn from_cubin_unchecked<T: AsRef<[u8]>>(
226
+ // bytes: T,
227
+ // options: &[ModuleJitOption],
228
+ // ) -> CudaResult<Module> {
229
+ // let bytes = bytes.as_ref();
230
+ // let mut module = Module {
231
+ // inner: ptr::null_mut(),
232
+ // };
233
+ // let (mut options, mut option_values) = ModuleJitOption::into_raw(options);
234
+ // cuda::cuModuleLoadDataEx(
235
+ // &mut module.inner as *mut cuda::CUmodule,
236
+ // bytes.as_ptr() as *const c_void,
237
+ // options.len() as c_uint,
238
+ // options.as_mut_ptr(),
239
+ // option_values.as_mut_ptr(),
240
+ // )
241
+ // .to_result()?;
242
+ // Ok(module)
243
+ // }
242
244
243
245
pub fn from_ptx_cstr ( cstr : & CStr , options : & [ ModuleJitOption ] ) -> CudaResult < Module > {
244
246
unsafe {
0 commit comments