BRIGFE fixes:

* brig-builtins.def: Treat HSAIL barrier builtins as
  setjmp/longjump style functions.

* brigfrontend/brig-to-generic.cc: Ensure per WI copies of
  private variables are aligned too.

* rt/workitems.c: Assume the host runtime allocates the work group
  memory.

From-SVN: r253160
This commit is contained in:
Pekka Jääskeläinen 2017-09-25 17:17:29 +00:00
parent 15e2333010
commit c02bffe38a
6 changed files with 36 additions and 29 deletions

View File

@ -1,3 +1,8 @@
2017-09-25 Pekka Jaaskelainen <pekka@parmance.com>
* brig-builtins.def: Treat HSAIL barrier builtins as
setjmp/longjump style functions.
2017-09-25 Richard Sandiford <richard.sandiford@linaro.org>
* target.def (constant_alignment): New hook.

View File

@ -240,7 +240,7 @@ DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FRACT_F64, BRIG_OPCODE_FRACT,
DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BARRIER, BRIG_OPCODE_BARRIER,
BRIG_TYPE_NONE, "__hsail_barrier", BT_FN_VOID_PTR,
ATTR_NOTHROW_LIST)
ATTR_RT_NOTHROW_LEAF_LIST)
DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_INITFBAR, BRIG_OPCODE_INITFBAR,
BRIG_TYPE_NONE, "__hsail_initfbar", BT_FN_VOID_UINT_PTR,
@ -252,11 +252,11 @@ DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_JOINFBAR, BRIG_OPCODE_JOINFBAR,
DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_WAITFBAR, BRIG_OPCODE_WAITFBAR,
BRIG_TYPE_NONE, "__hsail_waitfbar", BT_FN_VOID_UINT_PTR,
ATTR_NOTHROW_LIST)
ATTR_RT_NOTHROW_LEAF_LIST)
DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_ARRIVEFBAR, BRIG_OPCODE_ARRIVEFBAR,
BRIG_TYPE_NONE, "__hsail_arrivefbar", BT_FN_VOID_UINT_PTR,
ATTR_NOTHROW_LIST)
ATTR_RT_NOTHROW_LEAF_LIST)
DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_LEAVEFBAR, BRIG_OPCODE_LEAVEFBAR,
BRIG_TYPE_NONE, "__hsail_leavefbar", BT_FN_VOID_UINT_PTR,

View File

@ -1,3 +1,8 @@
2017-05-13 Pekka Jääskeläinen <pekka.jaaskelainen@parmance.com>
* brigfrontend/brig-to-generic.cc: Ensure per WI copies of
private variables are aligned too.
2017-09-17 Thomas Schwinge <thomas@codesourcery.com>
* Make-lang.in (GO_TEXI_FILES): Rename to...

View File

@ -599,18 +599,34 @@ brig_to_generic::group_segment_size () const
return m_next_group_offset;
}
/* Appends a new group variable to the current kernel's private segment. */
/* Appends a new variable to the current kernel's private segment. */
void
brig_to_generic::append_private_variable (const std::string &name,
size_t size, size_t alignment)
{
/* We need to take care of two cases of alignment with private
variables because of the layout where the same variable for
each work-item is laid out in successive addresses.
1) Ensure the first work-item's variable is in an aligned
offset: */
size_t align_padding = m_next_private_offset % alignment == 0 ?
0 : (alignment - m_next_private_offset % alignment);
/* 2) Each successive per-work-item copy should be aligned.
If the variable has wider alignment than size then we need
to add extra padding to ensure it. The padding must be
included in the size to allow per-work-item offset computation
to find their own aligned copy. */
size_t per_var_padding = size % alignment == 0 ?
0 : (alignment - size % alignment);
m_private_data_sizes[name] = size + per_var_padding;
m_next_private_offset += align_padding;
m_private_offsets[name] = m_next_private_offset;
m_next_private_offset += size;
m_private_data_sizes[name] = size + align_padding;
m_next_private_offset += size + per_var_padding;
}
size_t

View File

@ -1,3 +1,7 @@
2017-09-25 Pekka Jääskeläinen <pekka.jaaskelainen@parmance.com>
* rt/workitems.c: Assume the host runtime allocates the work group
memory.
2017-05-03 Pekka Jääskeläinen <pekka.jaaskelainen@parmance.com>
* rt/workitems.c: Removed a leftover comment.

View File

@ -318,14 +318,6 @@ phsa_spawn_work_items (PHSAKernelLaunchData *context, void *group_base_ptr)
hsa_kernel_dispatch_packet_t *dp = context->dp;
size_t x, y, z;
/* TO DO: host-side memory management of group and private segment
memory. Agents in general are less likely to support efficient dynamic mem
allocation. */
if (dp->group_segment_size > 0
&& posix_memalign (&group_base_ptr, PRIVATE_SEGMENT_ALIGN,
dp->group_segment_size) != 0)
phsa_fatal_error (3);
context->group_segment_start_addr = (size_t) group_base_ptr;
/* HSA seems to allow the WG size to be larger than the grid size. We need to
@ -371,9 +363,6 @@ phsa_spawn_work_items (PHSAKernelLaunchData *context, void *group_base_ptr)
phsa_execute_wi_gang (context, group_base_ptr, sat_wg_size_x, sat_wg_size_y,
sat_wg_size_z);
if (dp->group_segment_size > 0)
free (group_base_ptr);
}
#endif
@ -390,14 +379,6 @@ phsa_execute_work_groups (PHSAKernelLaunchData *context, void *group_base_ptr)
hsa_kernel_dispatch_packet_t *dp = context->dp;
size_t x, y, z, wg_x, wg_y, wg_z;
/* TODO: host-side memory management of group and private segment
memory. Agents in general are less likely to support efficient dynamic mem
allocation. */
if (dp->group_segment_size > 0
&& posix_memalign (&group_base_ptr, GROUP_SEGMENT_ALIGN,
dp->group_segment_size) != 0)
phsa_fatal_error (3);
context->group_segment_start_addr = (size_t) group_base_ptr;
/* HSA seems to allow the WG size to be larger than the grid size. We need
@ -509,10 +490,6 @@ phsa_execute_work_groups (PHSAKernelLaunchData *context, void *group_base_ptr)
printf ("### %lu WIs executed in %lu s (%lu WIs / s)\n", wi_total,
(uint64_t) spent_time_sec, (uint64_t) wis_per_sec);
#endif
if (dp->group_segment_size > 0)
free (group_base_ptr);
free (private_base_ptr);
private_base_ptr = NULL;
}