+2022-10-25 Abid Qadeer <abidh@codesourcery.com>
+
+ * omp-low.cc (usm_transform): Handle operator new with alignment.
+
2022-10-25 Marcel Vollweiler <marcel@codesourcery.com>
* omp-offload.cc (oacc_loop_auto_partitions): Removed OLF reduction
{
gcall *gs = as_a <gcall *> (stmt);
tree fndecl = gimple_call_fndecl (gs);
+ unsigned int args = gimple_call_num_args (gs);
if (fndecl)
{
tree allocator = build_int_cst (pointer_sized_int_node,
if ((strcmp (name, "malloc") == 0)
|| (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MALLOC)
- || DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
+ || (DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
+ && args == 1)
|| strcmp (name, "omp_target_alloc") == 0)
{
tree omp_alloc_type
gimple_set_location (g, gimple_location (stmt));
gsi_replace (gsi_p, g, true);
}
- else if (strcmp (name, "aligned_alloc") == 0)
+ else if ((strcmp (name, "aligned_alloc") == 0)
+ || (DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
+ && args == 2))
{
/* May be we can also use this for new operator with
std::align_val_t parameter. */
NULL_TREE);
tree repl = build_fn_decl ("omp_aligned_alloc",
omp_alloc_type);
- tree align = gimple_call_arg (gs, 0);
- tree size = gimple_call_arg (gs, 1);
+ int align_arg
+ = DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl) ? 1: 0;
+ int size_arg
+ = DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl) ? 0: 1;
+ tree align = gimple_call_arg (gs, align_arg);
+ tree size = gimple_call_arg (gs, size_arg);
gimple *g = gimple_build_call (repl, 3, align, size,
allocator);
gimple_call_set_lhs (g, gimple_call_lhs (gs));
+2022-10-25 Abid Qadeer <abidh@codesourcery.com>
+
+ * g++.dg/gomp/usm-4.C: New test.
+ * g++.dg/gomp/usm-5.C: New test.
+
2022-10-24 Tobias Burnus <tobias@codesourcery.com>
* g++.dg/ext/unroll-1.C: Change 'cunrolli' to 'cunrolli1' in
--- /dev/null
+// { dg-do compile { target c++17 } }
+// { dg-options "-fopenmp -fdump-tree-usm_transform" }
+
+#pragma omp requires unified_shared_memory
+
+struct t1
+{
+ int a;
+ int b;
+};
+
+typedef unsigned char uint8_t;
+
+void
+foo (__SIZE_TYPE__ x, __SIZE_TYPE__ y)
+{
+ uint8_t *p1 = new (std::align_val_t(128)) uint8_t;
+ uint8_t *p2 = new (std::align_val_t(128)) uint8_t[40];
+ t1 *p3 = new (std::align_val_t(128)) t1;
+ t1 *p4 = new (std::align_val_t(128)) t1[y];
+ delete p1;
+ delete p3;
+ delete [] p2;
+ delete [] p4;
+}
+
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(128, 1, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(128, 40, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc" 4 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_free" 4 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not "operator new" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not "operator delete" "usm_transform" } } */
--- /dev/null
+// { dg-do compile { target c++17 } }
+// { dg-options "-fopenmp -foffload-memory=unified -fdump-tree-usm_transform" }
+
+struct t1
+{
+ int a;
+ int b;
+};
+
+typedef unsigned char uint8_t;
+
+void
+foo (__SIZE_TYPE__ x, __SIZE_TYPE__ y)
+{
+ uint8_t *p1 = new (std::align_val_t(128)) uint8_t;
+ uint8_t *p2 = new (std::align_val_t(128)) uint8_t[40];
+ t1 *p3 = new (std::align_val_t(128)) t1;
+ t1 *p4 = new (std::align_val_t(128)) t1[y];
+ delete p1;
+ delete p3;
+ delete [] p2;
+ delete [] p4;
+}
+
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(128, 1, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(128, 40, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_aligned_alloc" 4 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_free" 4 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not "operator new" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not "operator delete" "usm_transform" } } */
+2022-10-25 Abid Qadeer <abidh@codesourcery.com>
+
+ * testsuite/libgomp.c++/usm-2.C: New test.
+
2022-10-24 Tobias Burnus <tobias@codesourcery.com>
Backport from mainline:
--- /dev/null
+/* { dg-do run } */
+/* { dg-additional-options "-std=c++17" } */
+/* { dg-require-effective-target omp_usm } */
+#include <stdint.h>
+
+#pragma omp requires unified_shared_memory
+
+struct s1
+{
+ int a;
+};
+
+int
+main ()
+{
+ s1 *p1 = new s1;
+ s1 *p2 = new s1[10];
+
+ if (!p1 || !p2)
+ __builtin_abort ();
+
+ uintptr_t pp1 = (uintptr_t)p1;
+ uintptr_t pp2 = (uintptr_t)p2;
+ if (pp1 & 0x7f != 0)
+ __builtin_abort ();
+
+ if (pp2 & 0x7f != 0)
+ __builtin_abort ();
+
+ delete [] p2;
+ delete p1;
+ return 0;
+}