<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/offload/plugins-nextgen/common/src/PluginInterface.cpp, branch users/MaskRay/spr/main.elf-orphan-placement-remove-hasinputsections-condition</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[Libomptarget] Rework device initialization and image registration (#93844)</title>
<updated>2024-06-06T13:10:56+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-06-06T13:10:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=435aa7663d56e7216ad148ede3a422675b5f2be1'/>
<id>435aa7663d56e7216ad148ede3a422675b5f2be1</id>
<content type='text'>
Summary:
Currently, we register images into a linear table according to the
logical OpenMP device identifier. We then initialize all of these images
as one block. This logic requires that images are compatible with *all*
devices instead of just the one that it can run on. This prevents us
from running on systems with heterogeneous devices (i.e. image 1 runs on
device 0 image 0 runs on device 1).

This patch reworks the logic by instead making the compatibility check a
per-device query. We then scan every device to see if it's compatible
and do it as they come.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
Currently, we register images into a linear table according to the
logical OpenMP device identifier. We then initialize all of these images
as one block. This logic requires that images are compatible with *all*
devices instead of just the one that it can run on. This prevents us
from running on systems with heterogeneous devices (i.e. image 1 runs on
device 0 image 0 runs on device 1).

This patch reworks the logic by instead making the compatibility check a
per-device query. We then scan every device to see if it's compatible
and do it as they come.</pre>
</div>
</content>
</entry>
<entry>
<title>[Offload] Only initialize a plugin if it is needed (#92765)</title>
<updated>2024-05-23T14:36:47+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-23T14:36:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=21f3a6091f71f6651f604733bba65cdc97b0b6b4'/>
<id>21f3a6091f71f6651f604733bba65cdc97b0b6b4</id>
<content type='text'>
Summary:
Initializing the plugins requires initializing the runtime like CUDA or
HSA. This has a considerable overhead on most platforms, so we should
only actually initialize a plugin if it is needed by any image that is
loaded.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
Initializing the plugins requires initializing the runtime like CUDA or
HSA. This has a considerable overhead on most platforms, so we should
only actually initialize a plugin if it is needed by any image that is
loaded.</pre>
</div>
</content>
</entry>
<entry>
<title>[Libomptarget] Rework Record &amp; Replay to be a plugin member (#88928) (#89097)</title>
<updated>2024-05-16T19:58:46+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-16T19:58:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f42f57b52dd279e6ae19270d063aeb8d59e3f11c'/>
<id>f42f57b52dd279e6ae19270d063aeb8d59e3f11c</id>
<content type='text'>
Summary:
Previously, the R&amp;R support was global state initialized by a global
constructor. This is bad because it prevents us from adequately
constraining the lifetime of the library. Additionally, we want to
minimize the amount of global state floating around.

This patch moves the R&amp;R support into a plugin member like everything
else. This means there will be multiple copies of the R&amp;R implementation
floating around, but this was already the case given the fact that we
currently handle everything with dynamic libraries.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
Previously, the R&amp;R support was global state initialized by a global
constructor. This is bad because it prevents us from adequately
constraining the lifetime of the library. Additionally, we want to
minimize the amount of global state floating around.

This patch moves the R&amp;R support into a plugin member like everything
else. This means there will be multiple copies of the R&amp;R implementation
floating around, but this was already the case given the fact that we
currently handle everything with dynamic libraries.</pre>
</div>
</content>
</entry>
<entry>
<title>[Libomptarget] Remove requires information from plugin (#80345)</title>
<updated>2024-05-16T16:13:50+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-16T16:13:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3abd3d6e597cba5161f37fa0478382fc93a8c9fd'/>
<id>3abd3d6e597cba5161f37fa0478382fc93a8c9fd</id>
<content type='text'>
Summary:
Currently this is only used for the zero-copy handling. However, this
can easily be moved into `libomptarget` so that we do not need to bother
setting the requires flags in the plugin. The advantage here is that we
no longer need to do this for every device redundently. Additionally,
these requires flags are specifically OpenMP related, so they should
live in `libomptarget`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
Currently this is only used for the zero-copy handling. However, this
can easily be moved into `libomptarget` so that we do not need to bother
setting the requires flags in the plugin. The advantage here is that we
no longer need to do this for every device redundently. Additionally,
these requires flags are specifically OpenMP related, so they should
live in `libomptarget`.</pre>
</div>
</content>
</entry>
<entry>
<title>[Offload][NFC] Fix warning messages in runtime</title>
<updated>2024-05-15T20:30:38+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-15T20:30:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=81d20d861e48f5202c9f79b47dee244674fb9121'/>
<id>81d20d861e48f5202c9f79b47dee244674fb9121</id>
<content type='text'>
Summary:
These are lots of random warnings due to inconsistent initialization or
signedness.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
These are lots of random warnings due to inconsistent initialization or
signedness.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Offload] Remove old references to `isCtor` (#91766)</title>
<updated>2024-05-14T11:00:34+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-14T11:00:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=363258a3ccbb752ec23f681d19b6a874c4db99ab'/>
<id>363258a3ccbb752ec23f681d19b6a874c4db99ab</id>
<content type='text'>
Summary:
These have long since been removed, support for ctors / dtors now
happens through special kernels the backend creates.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
These have long since been removed, support for ctors / dtors now
happens through special kernels the backend creates.</pre>
</div>
</content>
</entry>
<entry>
<title>[Reland][Libomptarget] Statically link all plugin runtimes (#87009)</title>
<updated>2024-05-09T14:38:22+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-09T11:35:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fa9e90f5d23312587b3a17920941334e0d1a58a1'/>
<id>fa9e90f5d23312587b3a17920941334e0d1a58a1</id>
<content type='text'>
This patch overhauls the `libomptarget` and plugin interface. Currently,
we define a C API and compile each plugin as a separate shared library.
Then, `libomptarget` loads these API functions and forwards its internal
calls to them. This was originally designed to allow multiple
implementations of a library to be live. However, since then no one has
used this functionality and it prevents us from using much nicer
interfaces. If the old behavior is desired it should instead be
implemented as a separate plugin.

This patch replaces the `PluginAdaptorTy` interface with the
`GenericPluginTy` that is used by the plugins. Each plugin exports a
`createPlugin_&lt;name&gt;` function that is used to get the specific
implementation. This code is now shared with `libomptarget`.

There are some notable improvements to this.
1. Massively improved lifetimes of life runtime objects
2. The plugins can use a C++ interface
3. Global state does not need to be duplicated for each plugin +
   libomptarget
4. Easier to use and add features and improve error handling
5. Less function call overhead / Improved LTO performance.

Additional changes in this plugin are related to contending with the
fact that state is now shared. Initialization and deinitialization is
now handled correctly and in phase with the underlying runtime, allowing
us to actually know when something is getting deallocated.

Depends on https://github.com/llvm/llvm-project/pull/86971
https://github.com/llvm/llvm-project/pull/86875
https://github.com/llvm/llvm-project/pull/86868
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch overhauls the `libomptarget` and plugin interface. Currently,
we define a C API and compile each plugin as a separate shared library.
Then, `libomptarget` loads these API functions and forwards its internal
calls to them. This was originally designed to allow multiple
implementations of a library to be live. However, since then no one has
used this functionality and it prevents us from using much nicer
interfaces. If the old behavior is desired it should instead be
implemented as a separate plugin.

This patch replaces the `PluginAdaptorTy` interface with the
`GenericPluginTy` that is used by the plugins. Each plugin exports a
`createPlugin_&lt;name&gt;` function that is used to get the specific
implementation. This code is now shared with `libomptarget`.

There are some notable improvements to this.
1. Massively improved lifetimes of life runtime objects
2. The plugins can use a C++ interface
3. Global state does not need to be duplicated for each plugin +
   libomptarget
4. Easier to use and add features and improve error handling
5. Less function call overhead / Improved LTO performance.

Additional changes in this plugin are related to contending with the
fact that state is now shared. Initialization and deinitialization is
now handled correctly and in phase with the underlying runtime, allowing
us to actually know when something is getting deallocated.

Depends on https://github.com/llvm/llvm-project/pull/86971
https://github.com/llvm/llvm-project/pull/86875
https://github.com/llvm/llvm-project/pull/86868
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[Libomptarget] Statically link all plugin runtimes (#87009)"</title>
<updated>2024-05-09T12:05:23+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-09T12:04:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e5e66073c3d404f4dedf1b0be160b7815ccf8903'/>
<id>e5e66073c3d404f4dedf1b0be160b7815ccf8903</id>
<content type='text'>
Caused failures on build-bots, reverting to investigate.

This reverts commit 80f9e814ec896fdc57ee84afad8ac4cb1f8e4627.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Caused failures on build-bots, reverting to investigate.

This reverts commit 80f9e814ec896fdc57ee84afad8ac4cb1f8e4627.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Libomptarget] Statically link all plugin runtimes (#87009)</title>
<updated>2024-05-09T11:35:54+00:00</updated>
<author>
<name>Joseph Huber</name>
<email>huberjn@outlook.com</email>
</author>
<published>2024-05-09T11:35:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=80f9e814ec896fdc57ee84afad8ac4cb1f8e4627'/>
<id>80f9e814ec896fdc57ee84afad8ac4cb1f8e4627</id>
<content type='text'>
This patch overhauls the `libomptarget` and plugin interface. Currently,
we define a C API and compile each plugin as a separate shared library.
Then, `libomptarget` loads these API functions and forwards its internal
calls to them. This was originally designed to allow multiple
implementations of a library to be live. However, since then no one has
used this functionality and it prevents us from using much nicer
interfaces. If the old behavior is desired it should instead be
implemented as a separate plugin.

This patch replaces the `PluginAdaptorTy` interface with the
`GenericPluginTy` that is used by the plugins. Each plugin exports a
`createPlugin_&lt;name&gt;` function that is used to get the specific
implementation. This code is now shared with `libomptarget`.

There are some notable improvements to this.
1. Massively improved lifetimes of life runtime objects
2. The plugins can use a C++ interface
3. Global state does not need to be duplicated for each plugin +
   libomptarget
4. Easier to use and add features and improve error handling
5. Less function call overhead / Improved LTO performance.

Additional changes in this plugin are related to contending with the
fact that state is now shared. Initialization and deinitialization is
now handled correctly and in phase with the underlying runtime, allowing
us to actually know when something is getting deallocated.

Depends on https://github.com/llvm/llvm-project/pull/86971
https://github.com/llvm/llvm-project/pull/86875
https://github.com/llvm/llvm-project/pull/86868</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch overhauls the `libomptarget` and plugin interface. Currently,
we define a C API and compile each plugin as a separate shared library.
Then, `libomptarget` loads these API functions and forwards its internal
calls to them. This was originally designed to allow multiple
implementations of a library to be live. However, since then no one has
used this functionality and it prevents us from using much nicer
interfaces. If the old behavior is desired it should instead be
implemented as a separate plugin.

This patch replaces the `PluginAdaptorTy` interface with the
`GenericPluginTy` that is used by the plugins. Each plugin exports a
`createPlugin_&lt;name&gt;` function that is used to get the specific
implementation. This code is now shared with `libomptarget`.

There are some notable improvements to this.
1. Massively improved lifetimes of life runtime objects
2. The plugins can use a C++ interface
3. Global state does not need to be duplicated for each plugin +
   libomptarget
4. Easier to use and add features and improve error handling
5. Less function call overhead / Improved LTO performance.

Additional changes in this plugin are related to contending with the
fact that state is now shared. Initialization and deinitialization is
now handled correctly and in phase with the underlying runtime, allowing
us to actually know when something is getting deallocated.

Depends on https://github.com/llvm/llvm-project/pull/86971
https://github.com/llvm/llvm-project/pull/86875
https://github.com/llvm/llvm-project/pull/86868</pre>
</div>
</content>
</entry>
<entry>
<title>[Offload] Fix dataDelete op for TARGET_ALLOC_HOST memory type (#91134)</title>
<updated>2024-05-08T03:21:32+00:00</updated>
<author>
<name>Jhonatan Cléto</name>
<email>52751492+cl3to@users.noreply.github.com</email>
</author>
<published>2024-05-08T03:21:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b438a817bd863699715116ee7d85b454f3289c08'/>
<id>b438a817bd863699715116ee7d85b454f3289c08</id>
<content type='text'>
Summary:
The `GenericDeviceTy::dataDelete` method doesn't verify the
`TargetAllocTy` of the of the device pointer. Because of this, it can
use the `MemoryManager` to free the ptr. However, the
`TARGET_ALLOC_HOST` and `TARGET_ALLOC_SHARED` types are not allocated
using the `MemoryManager` in the `GenericDeviceTy::dataAlloc` method.
Since the `MemoryManager` uses the `DeviceAllocatorTy::free` operation
without specifying the type of the ptr, some plugins may use incorrect
operations to free ptrs of certain types. In particular, this bug causes
the CUDA plugin to use the `cuMemFree` operation on ptrs of type
`TARGET_ALLOC_HOST`, resulting in an unchecked error, as shown in the
output snippet of the test
`offload/test/api/omp_host_pinned_memory_alloc.c`:

```
omptarget --&gt; Notifying about an unmapping: HstPtr=0x00007c6114200000
omptarget --&gt; Call to llvm_omp_target_free_host for device 0 and address 0x00007c6114200000
omptarget --&gt; Call to omp_get_num_devices returning 1
omptarget --&gt; Call to omp_get_initial_device returning 1
PluginInterface --&gt; MemoryManagerTy::free: target memory 0x00007c6114200000.
PluginInterface --&gt; Cannot find its node. Delete it on device directly.
TARGET CUDA RTL --&gt; Failure to free memory: Error in cuMemFree[Host]: invalid argument
omptarget --&gt; omp_target_free deallocated device ptr
```

This patch fixes this by adding the check of the device pointer type
before calling the appropriate operation for each type.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
The `GenericDeviceTy::dataDelete` method doesn't verify the
`TargetAllocTy` of the of the device pointer. Because of this, it can
use the `MemoryManager` to free the ptr. However, the
`TARGET_ALLOC_HOST` and `TARGET_ALLOC_SHARED` types are not allocated
using the `MemoryManager` in the `GenericDeviceTy::dataAlloc` method.
Since the `MemoryManager` uses the `DeviceAllocatorTy::free` operation
without specifying the type of the ptr, some plugins may use incorrect
operations to free ptrs of certain types. In particular, this bug causes
the CUDA plugin to use the `cuMemFree` operation on ptrs of type
`TARGET_ALLOC_HOST`, resulting in an unchecked error, as shown in the
output snippet of the test
`offload/test/api/omp_host_pinned_memory_alloc.c`:

```
omptarget --&gt; Notifying about an unmapping: HstPtr=0x00007c6114200000
omptarget --&gt; Call to llvm_omp_target_free_host for device 0 and address 0x00007c6114200000
omptarget --&gt; Call to omp_get_num_devices returning 1
omptarget --&gt; Call to omp_get_initial_device returning 1
PluginInterface --&gt; MemoryManagerTy::free: target memory 0x00007c6114200000.
PluginInterface --&gt; Cannot find its node. Delete it on device directly.
TARGET CUDA RTL --&gt; Failure to free memory: Error in cuMemFree[Host]: invalid argument
omptarget --&gt; omp_target_free deallocated device ptr
```

This patch fixes this by adding the check of the device pointer type
before calling the appropriate operation for each type.</pre>
</div>
</content>
</entry>
</feed>
