def compile(self, options=(), log_stream=None): try: if self.name_expressions: for ker in self.name_expressions: nvrtc.addNameExpression(self.ptr, ker) nvrtc.compileProgram(self.ptr, options) mapping = None if self.name_expressions: mapping = {} for ker in self.name_expressions: mapping[ker] = nvrtc.getLoweredName(self.ptr, ker) if log_stream is not None: log_stream.write(nvrtc.getProgramLog(self.ptr)) # This is to ensure backwards compatibility with nvrtc if self.method == 'cubin': return nvrtc.getCUBIN(self.ptr), mapping elif self.method == 'ptx': return nvrtc.getPTX(self.ptr), mapping # TODO(leofang): support JIT LTO using nvrtc.getNVVM()? # need -dlto and -arch=compute_XX else: raise RuntimeError('Unknown NVRTC compile method') except nvrtc.NVRTCError: log = nvrtc.getProgramLog(self.ptr) raise CompileException(log, self.src, self.name, options, 'nvrtc' if not runtime.is_hip else 'hiprtc')
def compile(self, options=(), log_stream=None): try: if self.name_expressions: for ker in self.name_expressions: nvrtc.addAddNameExpression(self.ptr, ker) nvrtc.compileProgram(self.ptr, options) mapping = None if self.name_expressions: mapping = {} for ker in self.name_expressions: mapping[ker] = nvrtc.getLoweredName(self.ptr, ker) if log_stream is not None: log_stream.write(nvrtc.getProgramLog(self.ptr)) return nvrtc.getPTX(self.ptr), mapping except nvrtc.NVRTCError: log = nvrtc.getProgramLog(self.ptr) raise CompileException(log, self.src, self.name, options, 'nvrtc')
def compile(self, options=(), log_stream=None): try: if self.name_expressions: for ker in self.name_expressions: nvrtc.addAddNameExpression(self.ptr, ker) nvrtc.compileProgram(self.ptr, options) mapping = None if self.name_expressions: mapping = {} for ker in self.name_expressions: mapping[ker] = nvrtc.getLoweredName(self.ptr, ker) if log_stream is not None: log_stream.write(nvrtc.getProgramLog(self.ptr)) # TODO(leofang): use getCUBIN() for _cuda_version >= 11010? return nvrtc.getPTX(self.ptr), mapping except nvrtc.NVRTCError: log = nvrtc.getProgramLog(self.ptr) raise CompileException(log, self.src, self.name, options, 'nvrtc' if not runtime.is_hip else 'hiprtc')