|
| 1 | +class LinkableCode: |
| 2 | + """An object that holds code to be linked from memory. |
| 3 | +
|
| 4 | + :param data: A buffer containing the data to link. |
| 5 | + :param name: The name of the file to be referenced in any compilation or |
| 6 | + linking errors that may be produced. |
| 7 | + """ |
| 8 | + |
| 9 | + def __init__(self, data, name=None): |
| 10 | + self.data = data |
| 11 | + self._name = name |
| 12 | + |
| 13 | + @property |
| 14 | + def name(self): |
| 15 | + return self._name or self.default_name |
| 16 | + |
| 17 | + |
| 18 | +class PTXSource(LinkableCode): |
| 19 | + """PTX source code in memory.""" |
| 20 | + |
| 21 | + default_name = "<unnamed-ptx>" |
| 22 | + |
| 23 | + |
| 24 | +class CUSource(LinkableCode): |
| 25 | + """CUDA C/C++ source code in memory.""" |
| 26 | + |
| 27 | + default_name = "<unnamed-cu>" |
| 28 | + |
| 29 | + |
| 30 | +class Fatbin(LinkableCode): |
| 31 | + """An ELF Fatbin in memory.""" |
| 32 | + |
| 33 | + default_name = "<unnamed-fatbin>" |
| 34 | + |
| 35 | + |
| 36 | +class Cubin(LinkableCode): |
| 37 | + """An ELF Cubin in memory.""" |
| 38 | + |
| 39 | + default_name = "<unnamed-cubin>" |
| 40 | + |
| 41 | + |
| 42 | +class Archive(LinkableCode): |
| 43 | + """An archive of objects in memory.""" |
| 44 | + |
| 45 | + default_name = "<unnamed-archive>" |
| 46 | + |
| 47 | + |
| 48 | +class Object(LinkableCode): |
| 49 | + """An object file in memory.""" |
| 50 | + |
| 51 | + default_name = "<unnamed-object>" |
| 52 | + |
| 53 | + |
| 54 | +class LTOIR(LinkableCode): |
| 55 | + """An LTOIR file in memory.""" |
| 56 | + |
| 57 | + default_name = "<unnamed-ltoir>" |
0 commit comments