[hsa 2/10] Modifications to libgomp proper
Martin Jambor
mjambor@suse.cz
Tue Jan 12 18:51:00 GMT 2016
Hi,
On Tue, Jan 12, 2016 at 02:38:15PM +0100, Jakub Jelinek wrote:
> On Tue, Jan 12, 2016 at 02:29:06PM +0100, Martin Jambor wrote:
> > GOMP_kernel_launch_attributes should not be there (it is a
> > reminiscence from before the device-specific target arguments) and
> > should be moved just to the HSA plugin. I'll prepare a patch today.
> >
> > While we do not have to share GOMP_hsa_kernel_dispatch, we actually do
> > use them in both the plugin and the compiler, where we only use it in
> > an offsetof, so that we only have the structure defined once.
>
> But, even using it in offsetof might be wrong, the compiler could be a
> cross-compiler, and you'd use offsetof on the host, while you want it for
> the target, and that would be different.
> So, IMHO you need (unless you already have) built the structure as a tree
> type, lay it out, and then you can use at TYPE_SIZE_UNIT or
> DECL_FIELD_OFFSET and the like.
>
I see. For now I have just put a FIXME there but have talked to Martin
about laying out the type properly. This is what I have committed to
the branch.
Thanks,
Martin
2016-01-12 Martin Jambor <mjambor@suse.cz>
include/
* gomp-constants.h (GOMP_kernel_launch_attributes): Removed.
(GOMP_hsa_kernel_dispatch): Likewise.
libgomp/
* plugin/plugin-hsa.c (GOMP_kernel_launch_attributes): Moved here.
(GOMP_hsa_kernel_dispatch): Likewise.
gcc/
* hsa-gen.c (GOMP_hsa_kernel_dispatch): Moved here.
---
gcc/hsa-gen.c | 35 +++++++++++++++++++++++++++++++++
include/gomp-constants.h | 44 ------------------------------------------
libgomp/plugin/plugin-hsa.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 44 deletions(-)
diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index 1715b57..f633dfd 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -3747,6 +3747,41 @@ gen_set_num_threads (tree value, hsa_bb *hbb)
hbb->append_insn (basic);
}
+/* Collection of information needed for a dispatch of a kernel from a
+ kernel. Keep in sync with libgomp's plugin-hsa.c.
+
+ FIXME: In order to support cross-compilations, we need to lay ot the type as
+ a tree and then use field_decl positions.
+ */
+
+struct GOMP_hsa_kernel_dispatch
+{
+ /* Pointer to a command queue associated with a kernel dispatch agent. */
+ void *queue;
+ /* Pointer to reserved memory for OMP data struct copying. */
+ void *omp_data_memory;
+ /* Pointer to a memory space used for kernel arguments passing. */
+ void *kernarg_address;
+ /* Kernel object. */
+ uint64_t object;
+ /* Synchronization signal used for dispatch synchronization. */
+ uint64_t signal;
+ /* Private segment size. */
+ uint32_t private_segment_size;
+ /* Group segment size. */
+ uint32_t group_segment_size;
+ /* Number of children kernel dispatches. */
+ uint64_t kernel_dispatch_count;
+ /* Number of threads. */
+ uint32_t omp_num_threads;
+ /* Debug purpose argument. */
+ uint64_t debug;
+ /* Levels-var ICV. */
+ uint64_t omp_level;
+ /* Kernel dispatch structures created for children kernel dispatches. */
+ struct GOMP_hsa_kernel_dispatch **children_dispatches;
+};
+
/* Return an HSA register that will contain number of threads for
a future dispatched kernel. Instructions are added to HBB. */
diff --git a/include/gomp-constants.h b/include/gomp-constants.h
index 1dae474..a8e7723 100644
--- a/include/gomp-constants.h
+++ b/include/gomp-constants.h
@@ -256,48 +256,4 @@ enum gomp_map_kind
/* Identifiers of device-specific target arguments. */
#define GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES (1 << 8)
-/* Structure describing the run-time and grid properties of an HSA kernel
- lauch. */
-
-struct GOMP_kernel_launch_attributes
-{
- /* Number of dimensions the workload has. Maximum number is 3. */
- uint32_t ndim;
- /* Size of the grid in the three respective dimensions. */
- uint32_t gdims[3];
- /* Size of work-groups in the respective dimensions. */
- uint32_t wdims[3];
-};
-
-/* Collection of information needed for a dispatch of a kernel from a
- kernel. */
-
-struct GOMP_hsa_kernel_dispatch
-{
- /* Pointer to a command queue associated with a kernel dispatch agent. */
- void *queue;
- /* Pointer to reserved memory for OMP data struct copying. */
- void *omp_data_memory;
- /* Pointer to a memory space used for kernel arguments passing. */
- void *kernarg_address;
- /* Kernel object. */
- uint64_t object;
- /* Synchronization signal used for dispatch synchronization. */
- uint64_t signal;
- /* Private segment size. */
- uint32_t private_segment_size;
- /* Group segment size. */
- uint32_t group_segment_size;
- /* Number of children kernel dispatches. */
- uint64_t kernel_dispatch_count;
- /* Number of threads. */
- uint32_t omp_num_threads;
- /* Debug purpose argument. */
- uint64_t debug;
- /* Levels-var ICV. */
- uint64_t omp_level;
- /* Kernel dispatch structures created for children kernel dispatches. */
- struct GOMP_hsa_kernel_dispatch **children_dispatches;
-};
-
#endif
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index 169fabb..e64dbec 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -37,6 +37,53 @@
#include "libgomp-plugin.h"
#include "gomp-constants.h"
+/* Keep the following GOMP prefixed structures in sync with respective parts of
+ the compiler. */
+
+/* Structure describing the run-time and grid properties of an HSA kernel
+ lauch. */
+
+struct GOMP_kernel_launch_attributes
+{
+ /* Number of dimensions the workload has. Maximum number is 3. */
+ uint32_t ndim;
+ /* Size of the grid in the three respective dimensions. */
+ uint32_t gdims[3];
+ /* Size of work-groups in the respective dimensions. */
+ uint32_t wdims[3];
+};
+
+/* Collection of information needed for a dispatch of a kernel from a
+ kernel. */
+
+struct GOMP_hsa_kernel_dispatch
+{
+ /* Pointer to a command queue associated with a kernel dispatch agent. */
+ void *queue;
+ /* Pointer to reserved memory for OMP data struct copying. */
+ void *omp_data_memory;
+ /* Pointer to a memory space used for kernel arguments passing. */
+ void *kernarg_address;
+ /* Kernel object. */
+ uint64_t object;
+ /* Synchronization signal used for dispatch synchronization. */
+ uint64_t signal;
+ /* Private segment size. */
+ uint32_t private_segment_size;
+ /* Group segment size. */
+ uint32_t group_segment_size;
+ /* Number of children kernel dispatches. */
+ uint64_t kernel_dispatch_count;
+ /* Number of threads. */
+ uint32_t omp_num_threads;
+ /* Debug purpose argument. */
+ uint64_t debug;
+ /* Levels-var ICV. */
+ uint64_t omp_level;
+ /* Kernel dispatch structures created for children kernel dispatches. */
+ struct GOMP_hsa_kernel_dispatch **children_dispatches;
+};
+
/* Part of the libgomp plugin interface. Return the name of the accelerator,
which is "hsa". */
--
2.6.4
More information about the Gcc-patches
mailing list