public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc
@ 2021-09-30  7:45 Jakub Jelinek
  2021-09-30 11:14 ` [Patch] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc) Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2021-09-30  7:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Tobias Burnus

Hi!

This patch adds new OpenMP 5.1 allocator entrypoints and in addition to that
fixes an omp_alloc bug which is hard to test for - if the first allocator
fails but has a larger alignment trait and has a fallback allocator, either
the default behavior or a user fallback, then the extra alignment will be used
even in the fallback allocation, rather than just starting with whatever
alignment has been requested (in GOMP_alloc or the minimum one in omp_alloc).

Jonathan's comment on IRC this morning made me realize that I should add
alloc_align attributes to 2 of the prototypes and I still need to add testsuite
coverage for omp_realloc, will do that in a follow-up.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2021-09-30  Jakub Jelinek  <jakub@redhat.com>

	* omp.h.in (omp_aligned_alloc, omp_calloc, omp_aligned_calloc,
	omp_realloc): New prototypes.
	(omp_alloc): Move after omp_free prototype, add __malloc__ (omp_free)
	attribute.
	* allocator.c: Include string.h.
	(omp_aligned_alloc): No longer static, add ialias.  Add new_alignment
	variable and use it instead of alignment so that when retrying the old
	alignment is used again.  Don't retry if new alignment is the same
	as old alignment, unless allocator had pool size.
	(omp_alloc, GOMP_alloc, GOMP_free): Use ialias_call.
	(omp_aligned_calloc, omp_calloc, omp_realloc): New functions.
	* libgomp.map (OMP_5.0.2): Export omp_aligned_alloc, omp_calloc,
	omp_aligned_calloc and omp_realloc.
	* testsuite/libgomp.c-c++-common/alloc-4.c (main): Add
	omp_aligned_alloc, omp_calloc and omp_aligned_calloc tests.
	* testsuite/libgomp.c-c++-common/alloc-5.c: New test.
	* testsuite/libgomp.c-c++-common/alloc-6.c: New test.
	* testsuite/libgomp.c-c++-common/alloc-7.c: New test.
	* testsuite/libgomp.c-c++-common/alloc-8.c: New test.

--- libgomp/omp.h.in.jj	2021-08-12 22:36:53.281885443 +0200
+++ libgomp/omp.h.in	2021-09-29 19:50:48.642110522 +0200
@@ -295,12 +295,31 @@ extern omp_allocator_handle_t omp_init_a
 extern void omp_destroy_allocator (omp_allocator_handle_t) __GOMP_NOTHROW;
 extern void omp_set_default_allocator (omp_allocator_handle_t) __GOMP_NOTHROW;
 extern omp_allocator_handle_t omp_get_default_allocator (void) __GOMP_NOTHROW;
-extern void *omp_alloc (__SIZE_TYPE__,
-			omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
-  __GOMP_NOTHROW __attribute__((__malloc__, __alloc_size__ (1)));
 extern void omp_free (void *,
 		      omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
   __GOMP_NOTHROW;
+extern void *omp_alloc (__SIZE_TYPE__,
+			omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+  __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+				__alloc_size__ (1)));
+extern void *omp_aligned_alloc (__SIZE_TYPE__, __SIZE_TYPE__,
+				omp_allocator_handle_t
+				__GOMP_DEFAULT_NULL_ALLOCATOR)
+  __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+				__alloc_size__ (2)));
+extern void *omp_calloc (__SIZE_TYPE__, __SIZE_TYPE__,
+			 omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+  __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+				__alloc_size__ (1, 2)));
+extern void *omp_aligned_calloc (__SIZE_TYPE__, __SIZE_TYPE__, __SIZE_TYPE__,
+				 omp_allocator_handle_t
+				 __GOMP_DEFAULT_NULL_ALLOCATOR)
+  __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+				__alloc_size__ (2, 3)));
+extern void *omp_realloc (void *, __SIZE_TYPE__,
+			  omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR,
+			  omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+  __GOMP_NOTHROW __attribute__((__malloc__ (omp_free), __alloc_size__ (2)));
 
 extern void omp_display_env (int) __GOMP_NOTHROW;
 
--- libgomp/allocator.c.jj	2021-08-12 18:14:29.731846863 +0200
+++ libgomp/allocator.c	2021-09-29 15:28:08.121095372 +0200
@@ -30,6 +30,7 @@
 #define _GNU_SOURCE
 #include "libgomp.h"
 #include <stdlib.h>
+#include <string.h>
 
 #define omp_max_predefined_alloc omp_thread_mem_alloc
 
@@ -205,18 +206,19 @@ omp_destroy_allocator (omp_allocator_han
 ialias (omp_init_allocator)
 ialias (omp_destroy_allocator)
 
-static void *
+void *
 omp_aligned_alloc (size_t alignment, size_t size,
 		   omp_allocator_handle_t allocator)
 {
   struct omp_allocator_data *allocator_data;
-  size_t new_size;
+  size_t new_size, new_alignment;
   void *ptr, *ret;
 
   if (__builtin_expect (size == 0, 0))
     return NULL;
 
 retry:
+  new_alignment = alignment;
   if (allocator == omp_null_allocator)
     {
       struct gomp_thread *thr = gomp_thread ();
@@ -228,19 +230,19 @@ retry:
   if (allocator > omp_max_predefined_alloc)
     {
       allocator_data = (struct omp_allocator_data *) allocator;
-      if (alignment < allocator_data->alignment)
-	alignment = allocator_data->alignment;
+      if (new_alignment < allocator_data->alignment)
+	new_alignment = allocator_data->alignment;
     }
   else
     {
       allocator_data = NULL;
-      if (alignment < sizeof (void *))
-	alignment = sizeof (void *);
+      if (new_alignment < sizeof (void *))
+	new_alignment = sizeof (void *);
     }
 
   new_size = sizeof (struct omp_mem_header);
-  if (alignment > sizeof (void *))
-    new_size += alignment - sizeof (void *);
+  if (new_alignment > sizeof (void *))
+    new_size += new_alignment - sizeof (void *);
   if (__builtin_add_overflow (size, new_size, &new_size))
     goto fail;
 
@@ -300,10 +302,11 @@ retry:
 	goto fail;
     }
 
-  if (alignment > sizeof (void *))
+  if (new_alignment > sizeof (void *))
     ret = (void *) (((uintptr_t) ptr
 		     + sizeof (struct omp_mem_header)
-		     + alignment - sizeof (void *)) & ~(alignment - 1));
+		     + new_alignment - sizeof (void *))
+		    & ~(new_alignment - 1));
   else
     ret = (char *) ptr + sizeof (struct omp_mem_header);
   ((struct omp_mem_header *) ret)[-1].ptr = ptr;
@@ -317,7 +320,7 @@ fail:
       switch (allocator_data->fallback)
 	{
 	case omp_atv_default_mem_fb:
-	  if (alignment > sizeof (void *)
+	  if ((new_alignment > sizeof (void *) && new_alignment > alignment)
 	      || (allocator_data
 		  && allocator_data->pool_size < ~(uintptr_t) 0))
 	    {
@@ -326,7 +329,7 @@ fail:
 	    }
 	  /* Otherwise, we've already performed default mem allocation
 	     and if that failed, it won't succeed again (unless it was
-	     intermitent.  Return NULL then, as that is the fallback.  */
+	     intermittent.  Return NULL then, as that is the fallback.  */
 	  break;
 	case omp_atv_null_fb:
 	  break;
@@ -342,10 +345,12 @@ fail:
   return NULL;
 }
 
+ialias (omp_aligned_alloc)
+
 void *
 omp_alloc (size_t size, omp_allocator_handle_t allocator)
 {
-  return omp_aligned_alloc (1, size, allocator);
+  return ialias_call (omp_aligned_alloc) (1, size, allocator);
 }
 
 /* Like omp_aligned_alloc, but apply on top of that:
@@ -355,8 +360,9 @@ omp_alloc (size_t size, omp_allocator_ha
 void *
 GOMP_alloc (size_t alignment, size_t size, uintptr_t allocator)
 {
-  void *ret = omp_aligned_alloc (alignment, size,
-				 (omp_allocator_handle_t) allocator);
+  void *ret
+    = ialias_call (omp_aligned_alloc) (alignment, size,
+				       (omp_allocator_handle_t) allocator);
   if (__builtin_expect (ret == NULL, 0) && size)
     gomp_fatal ("Out of memory allocating %lu bytes",
 		(unsigned long) size);
@@ -396,5 +402,365 @@ ialias (omp_free)
 void
 GOMP_free (void *ptr, uintptr_t allocator)
 {
-  return omp_free (ptr, (omp_allocator_handle_t) allocator);
+  return ialias_call (omp_free) (ptr, (omp_allocator_handle_t) allocator);
+}
+
+void *
+omp_aligned_calloc (size_t alignment, size_t nmemb, size_t size,
+		    omp_allocator_handle_t allocator)
+{
+  struct omp_allocator_data *allocator_data;
+  size_t new_size, size_temp, new_alignment;
+  void *ptr, *ret;
+
+  if (__builtin_expect (size == 0 || nmemb == 0, 0))
+    return NULL;
+
+retry:
+  new_alignment = alignment;
+  if (allocator == omp_null_allocator)
+    {
+      struct gomp_thread *thr = gomp_thread ();
+      if (thr->ts.def_allocator == omp_null_allocator)
+	thr->ts.def_allocator = gomp_def_allocator;
+      allocator = (omp_allocator_handle_t) thr->ts.def_allocator;
+    }
+
+  if (allocator > omp_max_predefined_alloc)
+    {
+      allocator_data = (struct omp_allocator_data *) allocator;
+      if (new_alignment < allocator_data->alignment)
+	new_alignment = allocator_data->alignment;
+    }
+  else
+    {
+      allocator_data = NULL;
+      if (new_alignment < sizeof (void *))
+	new_alignment = sizeof (void *);
+    }
+
+  new_size = sizeof (struct omp_mem_header);
+  if (new_alignment > sizeof (void *))
+    new_size += new_alignment - sizeof (void *);
+  if (__builtin_mul_overflow (size, nmemb, &size_temp))
+    goto fail;
+  if (__builtin_add_overflow (size_temp, new_size, &new_size))
+    goto fail;
+
+  if (__builtin_expect (allocator_data
+			&& allocator_data->pool_size < ~(uintptr_t) 0, 0))
+    {
+      uintptr_t used_pool_size;
+      if (new_size > allocator_data->pool_size)
+	goto fail;
+#ifdef HAVE_SYNC_BUILTINS
+      used_pool_size = __atomic_load_n (&allocator_data->used_pool_size,
+					MEMMODEL_RELAXED);
+      do
+	{
+	  uintptr_t new_pool_size;
+	  if (__builtin_add_overflow (used_pool_size, new_size,
+				      &new_pool_size)
+	      || new_pool_size > allocator_data->pool_size)
+	    goto fail;
+	  if (__atomic_compare_exchange_n (&allocator_data->used_pool_size,
+					   &used_pool_size, new_pool_size,
+					   true, MEMMODEL_RELAXED,
+					   MEMMODEL_RELAXED))
+	    break;
+	}
+      while (1);
+#else
+      gomp_mutex_lock (&allocator_data->lock);
+      if (__builtin_add_overflow (allocator_data->used_pool_size, new_size,
+				  &used_pool_size)
+	  || used_pool_size > allocator_data->pool_size)
+	{
+	  gomp_mutex_unlock (&allocator_data->lock);
+	  goto fail;
+	}
+      allocator_data->used_pool_size = used_pool_size;
+      gomp_mutex_unlock (&allocator_data->lock);
+#endif
+      ptr = calloc (1, new_size);
+      if (ptr == NULL)
+	{
+#ifdef HAVE_SYNC_BUILTINS
+	  __atomic_add_fetch (&allocator_data->used_pool_size, -new_size,
+			      MEMMODEL_RELAXED);
+#else
+	  gomp_mutex_lock (&allocator_data->lock);
+	  allocator_data->used_pool_size -= new_size;
+	  gomp_mutex_unlock (&allocator_data->lock);
+#endif
+	  goto fail;
+	}
+    }
+  else
+    {
+      ptr = calloc (1, new_size);
+      if (ptr == NULL)
+	goto fail;
+    }
+
+  if (new_alignment > sizeof (void *))
+    ret = (void *) (((uintptr_t) ptr
+		     + sizeof (struct omp_mem_header)
+		     + new_alignment - sizeof (void *))
+		    & ~(new_alignment - 1));
+  else
+    ret = (char *) ptr + sizeof (struct omp_mem_header);
+  ((struct omp_mem_header *) ret)[-1].ptr = ptr;
+  ((struct omp_mem_header *) ret)[-1].size = new_size;
+  ((struct omp_mem_header *) ret)[-1].allocator = allocator;
+  return ret;
+
+fail:
+  if (allocator_data)
+    {
+      switch (allocator_data->fallback)
+	{
+	case omp_atv_default_mem_fb:
+	  if ((new_alignment > sizeof (void *) && new_alignment > alignment)
+	      || (allocator_data
+		  && allocator_data->pool_size < ~(uintptr_t) 0))
+	    {
+	      allocator = omp_default_mem_alloc;
+	      goto retry;
+	    }
+	  /* Otherwise, we've already performed default mem allocation
+	     and if that failed, it won't succeed again (unless it was
+	     intermittent.  Return NULL then, as that is the fallback.  */
+	  break;
+	case omp_atv_null_fb:
+	  break;
+	default:
+	case omp_atv_abort_fb:
+	  gomp_fatal ("Out of memory allocating %lu bytes",
+		      (unsigned long) (size * nmemb));
+	case omp_atv_allocator_fb:
+	  allocator = allocator_data->fb_data;
+	  goto retry;
+	}
+    }
+  return NULL;
+}
+
+ialias (omp_aligned_calloc)
+
+void *
+omp_calloc (size_t nmemb, size_t size, omp_allocator_handle_t allocator)
+{
+  return ialias_call (omp_aligned_calloc) (1, nmemb, size, allocator);
+}
+
+void *
+omp_realloc (void *ptr, size_t size, omp_allocator_handle_t allocator,
+	     omp_allocator_handle_t free_allocator)
+{
+  struct omp_allocator_data *allocator_data, *free_allocator_data;
+  size_t new_size, old_size, new_alignment, old_alignment;
+  void *new_ptr, *ret;
+  struct omp_mem_header *data;
+
+  if (__builtin_expect (ptr == NULL, 0))
+    return ialias_call (omp_aligned_alloc) (1, size, allocator);
+
+  if (__builtin_expect (size == 0, 0))
+    {
+      ialias_call (omp_free) (ptr, free_allocator);
+      return NULL;
+    }
+
+  data = &((struct omp_mem_header *) ptr)[-1];
+  free_allocator = data->allocator;
+
+retry:
+  new_alignment = sizeof (void *);
+  if (allocator == omp_null_allocator)
+    allocator = free_allocator;
+
+  if (allocator > omp_max_predefined_alloc)
+    {
+      allocator_data = (struct omp_allocator_data *) allocator;
+      if (new_alignment < allocator_data->alignment)
+	new_alignment = allocator_data->alignment;
+    }
+  else
+    allocator_data = NULL;
+  if (free_allocator > omp_max_predefined_alloc)
+    free_allocator_data = (struct omp_allocator_data *) free_allocator;
+  else
+    free_allocator_data = NULL;
+  old_alignment = (uintptr_t) ptr - (uintptr_t) (data->ptr);
+
+  new_size = sizeof (struct omp_mem_header);
+  if (new_alignment > sizeof (void *))
+    new_size += new_alignment - sizeof (void *);
+  if (__builtin_add_overflow (size, new_size, &new_size))
+    goto fail;
+  old_size = data->size;
+
+  if (__builtin_expect (allocator_data
+			&& allocator_data->pool_size < ~(uintptr_t) 0, 0))
+    {
+      uintptr_t used_pool_size;
+      size_t prev_size = 0;
+      /* Check if we can use realloc.  Don't use it if extra alignment
+	 was used previously or newly, because realloc might return a pointer
+	 with different alignment and then we'd need to memmove the data
+	 again.  */
+      if (free_allocator_data
+	  && free_allocator_data == allocator_data
+	  && new_alignment == sizeof (void *)
+	  && old_alignment == sizeof (struct omp_mem_header))
+	prev_size = old_size;
+      if (new_size > prev_size
+	  && new_size - prev_size > allocator_data->pool_size)
+	goto fail;
+#ifdef HAVE_SYNC_BUILTINS
+      used_pool_size = __atomic_load_n (&allocator_data->used_pool_size,
+					MEMMODEL_RELAXED);
+      do
+	{
+	  uintptr_t new_pool_size;
+	  if (new_size > prev_size)
+	    {
+	      if (__builtin_add_overflow (used_pool_size, new_size - prev_size,
+					  &new_pool_size)
+		  || new_pool_size > allocator_data->pool_size)
+		goto fail;
+	    }
+	  else
+	    new_pool_size = used_pool_size + new_size - prev_size;
+	  if (__atomic_compare_exchange_n (&allocator_data->used_pool_size,
+					   &used_pool_size, new_pool_size,
+					   true, MEMMODEL_RELAXED,
+					   MEMMODEL_RELAXED))
+	    break;
+	}
+      while (1);
+#else
+      gomp_mutex_lock (&allocator_data->lock);
+      if (new_size > prev_size)
+	{
+	  if (__builtin_add_overflow (allocator_data->used_pool_size,
+				      new_size - prev_size,
+				      &used_pool_size)
+	      || used_pool_size > allocator_data->pool_size)
+	    {
+	      gomp_mutex_unlock (&allocator_data->lock);
+	      goto fail;
+	    }
+	}
+      else
+	used_pool_size = (allocator_data->used_pool_size
+			  + new_size - prev_size);
+      allocator_data->used_pool_size = used_pool_size;
+      gomp_mutex_unlock (&allocator_data->lock);
+#endif
+      if (prev_size)
+	new_ptr = realloc (data->ptr, new_size);
+      else
+	new_ptr = malloc (new_size);
+      if (new_ptr == NULL)
+	{
+#ifdef HAVE_SYNC_BUILTINS
+	  __atomic_add_fetch (&allocator_data->used_pool_size,
+			      prev_size - new_size,
+			      MEMMODEL_RELAXED);
+#else
+	  gomp_mutex_lock (&allocator_data->lock);
+	  allocator_data->used_pool_size -= new_size - prev_size;
+	  gomp_mutex_unlock (&allocator_data->lock);
+#endif
+	  goto fail;
+	}
+      else if (prev_size)
+	{
+	  ret = (char *) new_ptr + sizeof (struct omp_mem_header);
+	  ((struct omp_mem_header *) ret)[-1].ptr = new_ptr;
+	  ((struct omp_mem_header *) ret)[-1].size = new_size;
+	  ((struct omp_mem_header *) ret)[-1].allocator = allocator;
+	  return ret;
+	}
+    }
+  else if (new_alignment == sizeof (void *)
+	   && old_alignment == sizeof (struct omp_mem_header)
+	   && (free_allocator_data == NULL
+	       || free_allocator_data->pool_size == ~(uintptr_t) 0))
+    {
+      new_ptr = realloc (data->ptr, new_size);
+      if (new_ptr == NULL)
+	goto fail;
+      ret = (char *) new_ptr + sizeof (struct omp_mem_header);
+      ((struct omp_mem_header *) ret)[-1].ptr = new_ptr;
+      ((struct omp_mem_header *) ret)[-1].size = new_size;
+      ((struct omp_mem_header *) ret)[-1].allocator = allocator;
+      return ret;
+    }
+  else
+    {
+      new_ptr = malloc (new_size);
+      if (new_ptr == NULL)
+	goto fail;
+    }
+
+  if (new_alignment > sizeof (void *))
+    ret = (void *) (((uintptr_t) new_ptr
+		     + sizeof (struct omp_mem_header)
+		     + new_alignment - sizeof (void *))
+		    & ~(new_alignment - 1));
+  else
+    ret = (char *) new_ptr + sizeof (struct omp_mem_header);
+  ((struct omp_mem_header *) ret)[-1].ptr = new_ptr;
+  ((struct omp_mem_header *) ret)[-1].size = new_size;
+  ((struct omp_mem_header *) ret)[-1].allocator = allocator;
+  if (old_size - old_alignment < size)
+    size = old_size - old_alignment;
+  memcpy (ret, ptr, size);
+  if (__builtin_expect (free_allocator_data
+			&& free_allocator_data->pool_size < ~(uintptr_t) 0, 0))
+    {
+#ifdef HAVE_SYNC_BUILTINS
+      __atomic_add_fetch (&free_allocator_data->used_pool_size, -data->size,
+			  MEMMODEL_RELAXED);
+#else
+      gomp_mutex_lock (&free_allocator_data->lock);
+      free_allocator_data->used_pool_size -= data->size;
+      gomp_mutex_unlock (&free_allocator_data->lock);
+#endif
+    }
+  free (data->ptr);
+  return ret;
+
+fail:
+  if (allocator_data)
+    {
+      switch (allocator_data->fallback)
+	{
+	case omp_atv_default_mem_fb:
+	  if (new_alignment > sizeof (void *)
+	      || (allocator_data
+		  && allocator_data->pool_size < ~(uintptr_t) 0))
+	    {
+	      allocator = omp_default_mem_alloc;
+	      goto retry;
+	    }
+	  /* Otherwise, we've already performed default mem allocation
+	     and if that failed, it won't succeed again (unless it was
+	     intermittent.  Return NULL then, as that is the fallback.  */
+	  break;
+	case omp_atv_null_fb:
+	  break;
+	default:
+	case omp_atv_abort_fb:
+	  gomp_fatal ("Out of memory allocating %lu bytes",
+		      (unsigned long) size);
+	case omp_atv_allocator_fb:
+	  allocator = allocator_data->fb_data;
+	  goto retry;
+	}
+    }
+  return NULL;
 }
--- libgomp/libgomp.map.jj	2021-08-20 11:36:30.970244532 +0200
+++ libgomp/libgomp.map	2021-09-29 15:28:08.121095372 +0200
@@ -203,6 +203,10 @@ OMP_5.0.2 {
   global:
 	omp_get_device_num;
 	omp_get_device_num_;
+	omp_aligned_alloc;
+	omp_calloc;
+	omp_aligned_calloc;
+	omp_realloc;
 } OMP_5.0.1;
 
 OMP_5.1 {
--- libgomp/testsuite/libgomp.c-c++-common/alloc-4.c.jj	2020-07-28 15:39:10.150754275 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/alloc-4.c	2021-09-29 16:10:39.534447504 +0200
@@ -12,12 +12,30 @@ main ()
 
   if (omp_alloc (0, omp_null_allocator) != NULL)
     abort ();
+  if (omp_aligned_alloc (64, 0, omp_null_allocator) != NULL)
+    abort ();
+  if (omp_calloc (0, 0, omp_null_allocator) != NULL
+      || omp_calloc (32, 0, omp_null_allocator) != NULL
+      || omp_calloc (0, 64, omp_null_allocator) != NULL)
+    abort ();
+  if (omp_aligned_calloc (32, 0, 0, omp_null_allocator) != NULL
+      || omp_aligned_calloc (64, 32, 0, omp_null_allocator) != NULL
+      || omp_aligned_calloc (16, 0, 64, omp_null_allocator) != NULL)
+    abort ();
   a = omp_init_allocator (omp_default_mem_space, 2, traits);
   if (a != omp_null_allocator)
     {
       if (omp_alloc (0, a) != NULL
 	  || omp_alloc (0, a) != NULL
-	  || omp_alloc (0, a) != NULL)
+	  || omp_alloc (0, a) != NULL
+	  || omp_aligned_alloc (16, 0, a) != NULL
+	  || omp_aligned_alloc (128, 0, a) != NULL
+	  || omp_calloc (0, 0, a) != NULL
+	  || omp_calloc (32, 0, a) != NULL
+	  || omp_calloc (0, 64, a) != NULL
+	  || omp_aligned_calloc (32, 0, 0, a) != NULL
+	  || omp_aligned_calloc (64, 32, 0, a) != NULL
+	  || omp_aligned_calloc (16, 0, 64, a) != NULL)
 	abort ();
       omp_destroy_allocator (a);
     }
--- libgomp/testsuite/libgomp.c-c++-common/alloc-5.c.jj	2021-09-29 13:56:09.333676629 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/alloc-5.c	2021-09-29 16:04:58.970200800 +0200
@@ -0,0 +1,159 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits2[]
+= { { omp_atk_alignment, 16 },
+    { omp_atk_sync_hint, omp_atv_default },
+    { omp_atk_access, omp_atv_default },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_default_mem_fb },
+    { omp_atk_partition, omp_atv_environment } };
+omp_alloctrait_t traits3[]
+= { { omp_atk_sync_hint, omp_atv_uncontended },
+    { omp_atk_alignment, 32 },
+    { omp_atk_access, omp_atv_all },
+    { omp_atk_pool_size, 512 },
+    { omp_atk_fallback, omp_atv_allocator_fb },
+    { omp_atk_fb_data, 0 },
+    { omp_atk_partition, omp_atv_default } };
+const omp_alloctrait_t traits4[]
+= { { omp_atk_alignment, 128 },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_null_fb } };
+
+int
+main ()
+{
+  int *volatile p = (int *) omp_aligned_alloc (sizeof (int), 3 * sizeof (int), omp_default_mem_alloc);
+  int *volatile q;
+  int *volatile r;
+  omp_alloctrait_t traits[3]
+    = { { omp_atk_alignment, 64 },
+	{ omp_atk_fallback, omp_atv_null_fb },
+	{ omp_atk_pool_size, 4096 } };
+  omp_allocator_handle_t a, a2;
+
+  if ((((uintptr_t) p) % __alignof (int)) != 0)
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  p[2] = 3;
+  omp_free (p, omp_default_mem_alloc);
+  p = (int *) omp_aligned_alloc (2 * sizeof (int), 2 * sizeof (int), omp_default_mem_alloc);
+  if ((((uintptr_t) p) % (2 * sizeof (int))) != 0)
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (omp_default_mem_alloc);
+  p = (int *) omp_aligned_alloc (1, sizeof (int), omp_null_allocator);
+  if ((((uintptr_t) p) % __alignof (int)) != 0)
+    abort ();
+  p[0] = 3;
+  omp_free (p, omp_get_default_allocator ());
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = (int *) omp_aligned_alloc (32, 3072, a);
+  if ((((uintptr_t) p) % 64) != 0)
+    abort ();
+  p[0] = 1;
+  p[3071 / sizeof (int)] = 2;
+  if (omp_aligned_alloc (8, 3072, a) != NULL)
+    abort ();
+  omp_free (p, a);
+  p = (int *) omp_aligned_alloc (128, 3072, a);
+  if ((((uintptr_t) p) % 128) != 0)
+    abort ();
+  p[0] = 3;
+  p[3071 / sizeof (int)] = 4;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (a);
+  if (omp_get_default_allocator () != a)
+    abort ();
+  p = (int *) omp_aligned_alloc (64, 3072, omp_null_allocator);
+  if (omp_aligned_alloc (8, 3072, omp_null_allocator) != NULL)
+    abort ();
+  omp_free (p, a);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits2) / sizeof (traits2[0]),
+			  traits2);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  p = (int *) omp_aligned_alloc (4, 420, a2);
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_aligned_alloc (8, 768, a2);
+  if ((((uintptr_t) q) % 16) != 0)
+    abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  r = (int *) omp_aligned_alloc (8, 512, a2);
+  if ((((uintptr_t) r) % 8) != 0)
+    abort ();
+  r[0] = 9;
+  r[511 / sizeof (int)] = 10;
+  omp_free (p, omp_null_allocator);
+  omp_free (q, a2);
+  omp_free (r, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits4) / sizeof (traits4[0]),
+			  traits4);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  omp_set_default_allocator (a2);
+#ifdef __cplusplus
+  p = static_cast <int *> (omp_aligned_alloc (4, 420));
+#else
+  p = (int *) omp_aligned_alloc (4, 420, omp_null_allocator);
+#endif
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_aligned_alloc (64, 768, omp_null_allocator);
+  if ((((uintptr_t) q) % 128) != 0)
+    abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  if (omp_aligned_alloc (8, 768, omp_null_allocator) != NULL)
+    abort ();
+#ifdef __cplusplus
+  omp_free (p);
+  omp_free (q);
+  omp_free (NULL);
+#else
+  omp_free (p, omp_null_allocator);
+  omp_free (q, omp_null_allocator);
+  omp_free (NULL, omp_null_allocator);
+#endif
+  omp_free (NULL, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+  return 0;
+}
--- libgomp/testsuite/libgomp.c-c++-common/alloc-6.c.jj	2021-09-29 15:24:10.717419581 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/alloc-6.c	2021-09-29 16:17:15.597919597 +0200
@@ -0,0 +1,58 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits[]
+= { { omp_atk_alignment, 16 },
+    { omp_atk_sync_hint, omp_atv_default },
+    { omp_atk_access, omp_atv_default },
+    { omp_atk_fallback, omp_atv_default_mem_fb },
+    { omp_atk_partition, omp_atv_environment } };
+
+int
+main ()
+{
+  omp_allocator_handle_t a;
+  void *p, *q;
+  volatile size_t large_sz;
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits) / sizeof (traits[0]),
+			  traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = omp_alloc (2048, a);
+  if ((((uintptr_t) p) % 16) != 0)
+    abort ();
+  large_sz = ~(size_t) 1023;
+  q = omp_alloc (large_sz, a);
+  if (q != NULL)
+    abort ();
+  q = omp_aligned_alloc (32, large_sz, a);
+  if (q != NULL)
+    abort ();
+  q = omp_calloc (large_sz / 4, 4, a);
+  if (q != NULL)
+    abort ();
+  q = omp_aligned_calloc (1, 2, large_sz / 2, a);
+  if (q != NULL)
+    abort ();
+  omp_free (p, a);
+  large_sz = ~(size_t) 0;
+  large_sz >>= 1;
+  large_sz += 1;
+  if (omp_calloc (2, large_sz, a) != NULL)
+    abort ();
+  if (omp_calloc (large_sz, 1024, a) != NULL)
+    abort ();
+  if (omp_calloc (large_sz, large_sz, a) != NULL)
+    abort ();
+  if (omp_aligned_calloc (16, 2, large_sz, a) != NULL)
+    abort ();
+  if (omp_aligned_calloc (32, large_sz, 1024, a) != NULL)
+    abort ();
+  if (omp_aligned_calloc (64, large_sz, large_sz, a) != NULL)
+    abort ();
+  omp_destroy_allocator (a);
+  return 0;
+}
--- libgomp/testsuite/libgomp.c-c++-common/alloc-7.c.jj	2021-09-29 15:43:21.198327449 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/alloc-7.c	2021-09-29 16:01:31.907091730 +0200
@@ -0,0 +1,182 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits2[]
+= { { omp_atk_alignment, 16 },
+    { omp_atk_sync_hint, omp_atv_default },
+    { omp_atk_access, omp_atv_default },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_default_mem_fb },
+    { omp_atk_partition, omp_atv_environment } };
+omp_alloctrait_t traits3[]
+= { { omp_atk_sync_hint, omp_atv_uncontended },
+    { omp_atk_alignment, 32 },
+    { omp_atk_access, omp_atv_all },
+    { omp_atk_pool_size, 512 },
+    { omp_atk_fallback, omp_atv_allocator_fb },
+    { omp_atk_fb_data, 0 },
+    { omp_atk_partition, omp_atv_default } };
+const omp_alloctrait_t traits4[]
+= { { omp_atk_alignment, 128 },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_null_fb } };
+
+int
+main ()
+{
+  int *volatile p = (int *) omp_calloc (3, sizeof (int), omp_default_mem_alloc);
+  int *volatile q;
+  int *volatile r;
+  int i;
+  omp_alloctrait_t traits[3]
+    = { { omp_atk_alignment, 64 },
+	{ omp_atk_fallback, omp_atv_null_fb },
+	{ omp_atk_pool_size, 4096 } };
+  omp_allocator_handle_t a, a2;
+
+  if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] || p[1] || p[2])
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  p[2] = 3;
+  omp_free (p, omp_default_mem_alloc);
+  p = (int *) omp_calloc (2, sizeof (int), omp_default_mem_alloc);
+  if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] || p[1])
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (omp_default_mem_alloc);
+  p = (int *) omp_calloc (1, sizeof (int), omp_null_allocator);
+  if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0])
+    abort ();
+  p[0] = 3;
+  omp_free (p, omp_get_default_allocator ());
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = (int *) omp_calloc (3, 1024, a);
+  if ((((uintptr_t) p) % 64) != 0)
+    abort ();
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 1;
+  p[3071 / sizeof (int)] = 2;
+  if (omp_calloc (1024, 3, a) != NULL)
+    abort ();
+  omp_free (p, a);
+  p = (int *) omp_calloc (512, 6, a);
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 3;
+  p[3071 / sizeof (int)] = 4;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (a);
+  if (omp_get_default_allocator () != a)
+    abort ();
+  p = (int *) omp_calloc (12, 256, omp_null_allocator);
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  if (omp_calloc (128, 24, omp_null_allocator) != NULL)
+    abort ();
+  omp_free (p, a);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits2) / sizeof (traits2[0]),
+			  traits2);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  p = (int *) omp_calloc (10, 42, a2);
+  for (i = 0; i < 420 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_calloc (24, 32, a2);
+  if ((((uintptr_t) q) % 16) != 0)
+    abort ();
+  for (i = 0; i < 768 / sizeof (int); i++)
+    if (q[i])
+      abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  r = (int *) omp_calloc (128, 4, a2);
+  if ((((uintptr_t) r) % __alignof (int)) != 0)
+    abort ();
+  for (i = 0; i < 512 / sizeof (int); i++)
+    if (r[i])
+      abort ();
+  r[0] = 9;
+  r[511 / sizeof (int)] = 10;
+  omp_free (p, omp_null_allocator);
+  omp_free (q, a2);
+  omp_free (r, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits4) / sizeof (traits4[0]),
+			  traits4);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  omp_set_default_allocator (a2);
+#ifdef __cplusplus
+  p = static_cast <int *> (omp_calloc (42, 10));
+#else
+  p = (int *) omp_calloc (42, 10, omp_null_allocator);
+#endif
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  for (i = 0; i < 420 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_calloc (32, 24, omp_null_allocator);
+  if ((((uintptr_t) q) % 128) != 0)
+    abort ();
+  for (i = 0; i < 768 / sizeof (int); i++)
+    if (q[i])
+      abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  if (omp_calloc (24, 32, omp_null_allocator) != NULL)
+    abort ();
+#ifdef __cplusplus
+  omp_free (p);
+  omp_free (q);
+  omp_free (NULL);
+#else
+  omp_free (p, omp_null_allocator);
+  omp_free (q, omp_null_allocator);
+  omp_free (NULL, omp_null_allocator);
+#endif
+  omp_free (NULL, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+  return 0;
+}
--- libgomp/testsuite/libgomp.c-c++-common/alloc-8.c.jj	2021-09-29 16:23:55.364337820 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/alloc-8.c	2021-09-29 16:32:13.480380282 +0200
@@ -0,0 +1,184 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits2[]
+= { { omp_atk_alignment, 16 },
+    { omp_atk_sync_hint, omp_atv_default },
+    { omp_atk_access, omp_atv_default },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_default_mem_fb },
+    { omp_atk_partition, omp_atv_environment } };
+omp_alloctrait_t traits3[]
+= { { omp_atk_sync_hint, omp_atv_uncontended },
+    { omp_atk_alignment, 32 },
+    { omp_atk_access, omp_atv_all },
+    { omp_atk_pool_size, 512 },
+    { omp_atk_fallback, omp_atv_allocator_fb },
+    { omp_atk_fb_data, 0 },
+    { omp_atk_partition, omp_atv_default } };
+const omp_alloctrait_t traits4[]
+= { { omp_atk_alignment, 128 },
+    { omp_atk_pool_size, 1024 },
+    { omp_atk_fallback, omp_atv_null_fb } };
+
+int
+main ()
+{
+  int *volatile p = (int *) omp_aligned_calloc (sizeof (int), 3, sizeof (int), omp_default_mem_alloc);
+  int *volatile q;
+  int *volatile r;
+  int i;
+  omp_alloctrait_t traits[3]
+    = { { omp_atk_alignment, 64 },
+	{ omp_atk_fallback, omp_atv_null_fb },
+	{ omp_atk_pool_size, 4096 } };
+  omp_allocator_handle_t a, a2;
+
+  if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] || p[1] || p[2])
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  p[2] = 3;
+  omp_free (p, omp_default_mem_alloc);
+  p = (int *) omp_aligned_calloc (2 * sizeof (int), 1, 2 * sizeof (int), omp_default_mem_alloc);
+  if ((((uintptr_t) p) % (2 * sizeof (int))) != 0 || p[0] || p[1])
+    abort ();
+  p[0] = 1;
+  p[1] = 2;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (omp_default_mem_alloc);
+  p = (int *) omp_aligned_calloc (1, 1, sizeof (int), omp_null_allocator);
+  if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0])
+    abort ();
+  p[0] = 3;
+  omp_free (p, omp_get_default_allocator ());
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = (int *) omp_aligned_calloc (32, 3, 1024, a);
+  if ((((uintptr_t) p) % 64) != 0)
+    abort ();
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 1;
+  p[3071 / sizeof (int)] = 2;
+  if (omp_aligned_calloc (8, 192, 16, a) != NULL)
+    abort ();
+  omp_free (p, a);
+  p = (int *) omp_aligned_calloc (128, 6, 512, a);
+  if ((((uintptr_t) p) % 128) != 0)
+    abort ();
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 3;
+  p[3071 / sizeof (int)] = 4;
+  omp_free (p, omp_null_allocator);
+  omp_set_default_allocator (a);
+  if (omp_get_default_allocator () != a)
+    abort ();
+  p = (int *) omp_aligned_calloc (64, 12, 256, omp_null_allocator);
+  for (i = 0; i < 3072 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  if (omp_aligned_calloc (8, 128, 24, omp_null_allocator) != NULL)
+    abort ();
+  omp_free (p, a);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits2) / sizeof (traits2[0]),
+			  traits2);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  p = (int *) omp_aligned_calloc (4, 5, 84, a2);
+  for (i = 0; i < 420 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_aligned_calloc (8, 24, 32, a2);
+  if ((((uintptr_t) q) % 16) != 0)
+    abort ();
+  for (i = 0; i < 768 / sizeof (int); i++)
+    if (q[i])
+      abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  r = (int *) omp_aligned_calloc (8, 64, 8, a2);
+  if ((((uintptr_t) r) % 8) != 0)
+    abort ();
+  for (i = 0; i < 512 / sizeof (int); i++)
+    if (r[i])
+      abort ();
+  r[0] = 9;
+  r[511 / sizeof (int)] = 10;
+  omp_free (p, omp_null_allocator);
+  omp_free (q, a2);
+  omp_free (r, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+
+  a = omp_init_allocator (omp_default_mem_space,
+			  sizeof (traits4) / sizeof (traits4[0]),
+			  traits4);
+  if (a == omp_null_allocator)
+    abort ();
+  if (traits3[5].key != omp_atk_fb_data)
+    abort ();
+  traits3[5].value = (uintptr_t) a;
+  a2 = omp_init_allocator (omp_default_mem_space,
+			   sizeof (traits3) / sizeof (traits3[0]),
+			   traits3);
+  if (a2 == omp_null_allocator)
+    abort ();
+  omp_set_default_allocator (a2);
+#ifdef __cplusplus
+  p = static_cast <int *> (omp_aligned_calloc (4, 21, 20));
+#else
+  p = (int *) omp_aligned_calloc (4, 21, 20, omp_null_allocator);
+#endif
+  if ((((uintptr_t) p) % 32) != 0)
+    abort ();
+  for (i = 0; i < 420 / sizeof (int); i++)
+    if (p[i])
+      abort ();
+  p[0] = 5;
+  p[419 / sizeof (int)] = 6;
+  q = (int *) omp_aligned_calloc (64, 12, 64, omp_null_allocator);
+  if ((((uintptr_t) q) % 128) != 0)
+    abort ();
+  for (i = 0; i < 768 / sizeof (int); i++)
+    if (q[i])
+      abort ();
+  q[0] = 7;
+  q[767 / sizeof (int)] = 8;
+  if (omp_aligned_calloc (8, 24, 32, omp_null_allocator) != NULL)
+    abort ();
+#ifdef __cplusplus
+  omp_free (p);
+  omp_free (q);
+  omp_free (NULL);
+#else
+  omp_free (p, omp_null_allocator);
+  omp_free (q, omp_null_allocator);
+  omp_free (NULL, omp_null_allocator);
+#endif
+  omp_free (NULL, omp_null_allocator);
+  omp_destroy_allocator (a2);
+  omp_destroy_allocator (a);
+  return 0;
+}

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Patch] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc)
  2021-09-30  7:45 [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc Jakub Jelinek
@ 2021-09-30 11:14 ` Tobias Burnus
  2021-09-30 11:31   ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2021-09-30 11:14 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches, fortran; +Cc: Tobias Burnus

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

On 30.09.21 09:45, Jakub Jelinek wrote:

> This patch adds new OpenMP 5.1 allocator entrypoints ...

... and this patch adds the Fortran support for it, using the C→Fortran
converted testcases. Additionally, it fixes and updated the list of API
routine names. We now can also tick off one item in the OpenMP 5.1
implementation status list.

OK for mainline?

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: omp-calloc-fortran.diff --]
[-- Type: text/x-patch, Size: 32600 bytes --]

openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran

gcc/ChangeLog:

	* omp-low.c (omp_runtime_api_call): Add omp_aligned_{,c}alloc and
	omp_{c,re}alloc, fix omp_alloc/omp_free.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.1): Set implementation status to Y for
	omp_aligned_{,c}alloc and omp_{c,re}alloc routines.
	* omp_lib.f90.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
	omp_realloc): Add.
	* omp_lib.h.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
	omp_realloc): Add.
	* testsuite/libgomp.fortran/alloc-10.f90: New test.
	* testsuite/libgomp.fortran/alloc-6.f90: New test.
	* testsuite/libgomp.fortran/alloc-7.c: New test.
	* testsuite/libgomp.fortran/alloc-7.f90: New test.
	* testsuite/libgomp.fortran/alloc-8.f90: New test.
	* testsuite/libgomp.fortran/alloc-9.f90: New test.

 gcc/omp-low.c                                  |   8 +-
 libgomp/libgomp.texi                           |   2 +-
 libgomp/omp_lib.f90.in                         |  43 +++++-
 libgomp/omp_lib.h.in                           |  46 +++++-
 libgomp/testsuite/libgomp.fortran/alloc-10.f90 | 198 +++++++++++++++++++++++++
 libgomp/testsuite/libgomp.fortran/alloc-6.f90  |  45 ++++++
 libgomp/testsuite/libgomp.fortran/alloc-7.c    |   5 +
 libgomp/testsuite/libgomp.fortran/alloc-7.f90  | 174 ++++++++++++++++++++++
 libgomp/testsuite/libgomp.fortran/alloc-8.f90  |  58 ++++++++
 libgomp/testsuite/libgomp.fortran/alloc-9.f90  | 196 ++++++++++++++++++++++++
 10 files changed, 770 insertions(+), 5 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 26c5c0261e9..f7242dfbbca 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3921,8 +3921,12 @@ omp_runtime_api_call (const_tree fndecl)
     {
       /* This array has 3 sections.  First omp_* calls that don't
 	 have any suffixes.  */
-      "omp_alloc",
-      "omp_free",
+      "aligned_alloc",
+      "aligned_calloc",
+      "alloc",
+      "calloc",
+      "free",
+      "realloc",
       "target_alloc",
       "target_associate_ptr",
       "target_disassociate_ptr",
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index b3bab8feddf..02160f81562 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -315,7 +315,7 @@ The OpenMP 4.5 specification is fully supported.
       runtime routines @tab N @tab
 @item @code{omp_get_mapped_ptr} runtime routine @tab N @tab
 @item @code{omp_calloc}, @code{omp_realloc}, @code{omp_aligned_alloc} and
-      @code{omp_aligned_calloc} runtime routines @tab N @tab
+      @code{omp_aligned_calloc} runtime routines @tab Y @tab
 @item @code{omp_alloctrait_key_t} enum: @code{omp_atv_serialized} added,
       @code{omp_atv_default} changed @tab Y @tab
 @item @code{omp_display_env} runtime routine @tab P
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index a36a5626123..1063eee0c94 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -680,13 +680,54 @@
           end function omp_alloc
         end interface
 
+        interface
+          function omp_aligned_alloc (alignment, size, allocator) bind(c)
+            use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+            import :: omp_allocator_handle_kind
+            type(c_ptr) :: omp_aligned_alloc
+            integer(c_size_t), value :: alignment, size
+            integer(omp_allocator_handle_kind), value :: allocator
+          end function omp_aligned_alloc
+        end interface
+
         interface
           subroutine omp_free(ptr, allocator) bind(c)
             use, intrinsic :: iso_c_binding, only : c_ptr
             import :: omp_allocator_handle_kind
             type(c_ptr), value :: ptr
             integer(omp_allocator_handle_kind), value :: allocator
-          end subroutine
+          end subroutine omp_free
+        end interface
+
+        interface
+          function omp_calloc (nmemb, size, allocator) bind(c)
+            use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+            import :: omp_allocator_handle_kind
+            type(c_ptr) :: omp_calloc
+            integer(c_size_t), value :: nmemb, size
+            integer(omp_allocator_handle_kind), value :: allocator
+          end function omp_calloc
+        end interface
+
+        interface
+          function omp_aligned_calloc (alignment, nmemb, size, allocator) bind(c)
+            use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+            import :: omp_allocator_handle_kind
+            type(c_ptr) :: omp_aligned_calloc
+            integer(c_size_t), value :: alignment, nmemb, size
+            integer(omp_allocator_handle_kind), value :: allocator
+          end function omp_aligned_calloc
+        end interface
+
+        interface
+          function omp_realloc (ptr, size, allocator, free_allocator) bind(c)
+            use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+            import :: omp_allocator_handle_kind
+            type(c_ptr) :: omp_realloc
+            type(c_ptr), value :: ptr
+            integer(c_size_t), value :: size
+            integer(omp_allocator_handle_kind), value :: allocator, free_allocator
+          end function omp_realloc
         end interface
 
         interface
diff --git a/libgomp/omp_lib.h.in b/libgomp/omp_lib.h.in
index 1c2eacba554..f40321c479b 100644
--- a/libgomp/omp_lib.h.in
+++ b/libgomp/omp_lib.h.in
@@ -282,13 +282,57 @@
         end function omp_alloc
       end interface
 
+      interface
+        function omp_aligned_alloc (alignment, size, allocator) bind(c)
+          use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+          use, intrinsic :: omp_lib_kinds
+          type(c_ptr) :: omp_aligned_alloc
+          integer(c_size_t), value :: alignment, size
+          integer(omp_allocator_handle_kind), value :: allocator
+        end function omp_aligned_alloc
+      end interface
+
       interface
         subroutine omp_free(ptr, allocator) bind(c)
           use, intrinsic :: iso_c_binding, only : c_ptr
           use, intrinsic :: omp_lib_kinds
           type(c_ptr), value :: ptr
           integer(omp_allocator_handle_kind), value :: allocator
-        end subroutine
+        end subroutine omp_free
+      end interface
+
+      interface
+        function omp_calloc (nmemb, size, allocator) bind(c)
+          use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+          use, intrinsic :: omp_lib_kinds
+          type(c_ptr) :: omp_calloc
+          integer(c_size_t), value :: nmemb, size
+          integer(omp_allocator_handle_kind), value :: allocator
+        end function omp_calloc
+      end interface
+
+      interface
+        function omp_aligned_calloc (alignment, nmemb, size, allocator)   &
+     &      bind(c)
+          use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+          use, intrinsic :: omp_lib_kinds
+          type(c_ptr) :: omp_aligned_calloc
+          integer(c_size_t), value :: alignment, nmemb, size
+          integer(omp_allocator_handle_kind), value :: allocator
+        end function omp_aligned_calloc
+      end interface
+
+      interface
+        function omp_realloc (ptr, size, allocator, free_allocator)      &
+     &      bind(c)
+          use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
+          use, intrinsic :: omp_lib_kinds
+          type(c_ptr) :: omp_realloc
+          type(c_ptr), value :: ptr
+          integer(c_size_t), value :: size
+          integer(omp_allocator_handle_kind), value :: allocator
+          integer(omp_allocator_handle_kind), value :: free_allocator
+        end function omp_realloc
       end interface
 
       interface
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-10.f90 b/libgomp/testsuite/libgomp.fortran/alloc-10.f90
new file mode 100644
index 00000000000..d26a83b216a
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-10.f90
@@ -0,0 +1,198 @@
+! { dg-additional-sources alloc-7.c }
+module m
+  use omp_lib
+  use iso_c_binding
+  implicit none
+
+  type (omp_alloctrait), parameter :: traits2(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 16), &
+        omp_alloctrait (omp_atk_sync_hint, omp_atv_default), &
+        omp_alloctrait (omp_atk_access, omp_atv_default), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_default_mem_fb), &
+        omp_alloctrait (omp_atk_partition, omp_atv_environment)]
+  type (omp_alloctrait) :: traits3(7) &
+    = [ omp_alloctrait (omp_atk_sync_hint, omp_atv_uncontended), &
+        omp_alloctrait (omp_atk_alignment, 32), &
+        omp_alloctrait (omp_atk_access, omp_atv_all), &
+        omp_alloctrait (omp_atk_pool_size, 512), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_allocator_fb), &
+        omp_alloctrait (omp_atk_fb_data, 0), &
+        omp_alloctrait (omp_atk_partition, omp_atv_default)]
+  type (omp_alloctrait), parameter :: traits4(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 128), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_null_fb)]
+
+  interface
+    integer(c_int) function get__alignof_int () bind(C)
+      import :: c_int
+    end
+  end interface
+end module m
+
+program main
+  use m
+  implicit none (external, type)
+  type(c_ptr) :: p, q, r
+  integer, pointer, contiguous :: ip(:), iq(:), ir(:)
+  type (omp_alloctrait) :: traits(3)
+  integer (omp_allocator_handle_kind) :: a, a2
+  integer (c_ptrdiff_t) :: iptr
+  integer :: i
+
+  traits  = [ omp_alloctrait (omp_atk_alignment, 64), &
+              omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
+              omp_alloctrait (omp_atk_pool_size, 4096)]
+
+  p = omp_aligned_calloc (c_sizeof (0), 3_c_size_t, c_sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [3])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
+      .or. ip(1) /= 0 .or. ip(2) /= 0 .or. ip(3) /= 0) &
+    stop 1
+  ip(1) = 1
+  ip(2) = 2
+  ip(3) = 3
+  call omp_free (p, omp_default_mem_alloc)
+  p = omp_aligned_calloc (2 * c_sizeof (0), 1_c_size_t, 2 * c_sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [2])
+  if (mod (TRANSFER (p, iptr), 2 * c_sizeof (0)) /= 0 &
+      .or. ip(1) /= 0 .or. ip(2) /= 0) &
+    stop 2
+  ip(1) = 1
+  ip(2) = 2
+  call omp_free (p, omp_null_allocator)
+  call omp_set_default_allocator (omp_default_mem_alloc)
+  p = omp_aligned_calloc (1_c_size_t, 1_c_size_t, c_sizeof (0), omp_null_allocator)
+  call c_f_pointer (p, ip, [1])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
+      .or. ip(1) /= 0) &
+    stop 3
+  ip(1) = 3
+  call omp_free (p, omp_get_default_allocator ())
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits)
+  if (a == omp_null_allocator) &
+    stop 4
+  p = omp_aligned_calloc (32_c_size_t, 3_c_size_t, 1024_c_size_t, a)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 64) /= 0) &
+    stop 5
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 6
+  end do
+  ip(1) = 1
+  ip(3072 / c_sizeof (0)) = 2
+  if (c_associated (omp_aligned_calloc (8_c_size_t, 192_c_size_t, 16_c_size_t, a))) &
+    stop 7
+  call omp_free (p, a)
+  p = omp_aligned_calloc (128_c_size_t, 6_c_size_t, 512_c_size_t, a)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 128) /= 0) &
+    stop 8
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 9
+  end do
+  ip(1) = 3
+  ip(3072 / c_sizeof (0)) = 4
+  call omp_free (p, omp_null_allocator)
+  call omp_set_default_allocator (a)
+  if (omp_get_default_allocator () /= a) &
+    stop 10
+  p = omp_aligned_calloc (64_c_size_t, 12_c_size_t, 256_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 11
+  end do
+  if (c_associated (omp_aligned_calloc (8_c_size_t, 128_c_size_t, 24_c_size_t, omp_null_allocator))) &
+    stop 12
+  call omp_free (p, a)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits2), traits2)
+  if (a == omp_null_allocator) &
+    stop 13
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 14
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 15
+  p = omp_aligned_calloc (4_c_size_t, 5_c_size_t, 84_c_size_t, a2)
+  call c_f_pointer (p, ip, [420 / c_sizeof (0)])
+  do i = 1, 420 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 16
+  end do
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 17
+  ip(1) = 5
+  ip(420 / c_sizeof (0)) = 6
+  q = omp_aligned_calloc (8_c_size_t, 24_c_size_t, 32_c_size_t, a2)
+  call c_f_pointer (q, iq, [768 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 16) /= 0) &
+    stop 18
+  do i = 1, 768 / c_sizeof (0)
+    if (iq(i) /= 0) &
+      stop 19
+  end do
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+  r = omp_aligned_calloc (8_c_size_t, 64_c_size_t, 8_c_size_t, a2)
+  call c_f_pointer (r, ir, [512 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 8) /= 0) &
+    stop 20
+  do i = 1, 512 / c_sizeof (0)
+    if (ir(i) /= 0) &
+      stop 21
+  end do
+  ir(1) = 9
+  ir(512 / c_sizeof (0)) = 10
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, a2)
+  call omp_free (r, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits4), traits4)
+  if (a == omp_null_allocator) &
+    stop 22
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 23
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 24
+  call omp_set_default_allocator (a2)
+  p = omp_aligned_calloc (4_c_size_t, 21_c_size_t, 20_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [420 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 25
+  do i = 1, 420 / c_sizeof (0)
+    if (ip(i) /= 0)  &
+      stop 26
+  end do
+  ip(1) = 5
+  ip(420 / c_sizeof (0)) = 6
+  q = omp_aligned_calloc (64_c_size_t, 12_c_size_t, 64_c_size_t, omp_null_allocator)
+  call c_f_pointer (q, iq, [768 / c_sizeof (0)])
+  if (mod (TRANSFER (q, iptr), 128) /= 0) &
+    stop 27
+  do i = 1, 768 / c_sizeof (0)
+    if (iq(i) /= 0) &
+      stop 28
+  end do
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+  if (c_associated (omp_aligned_calloc (8_c_size_t, 24_c_size_t, 32_c_size_t, omp_null_allocator))) &
+    stop 29
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-6.f90 b/libgomp/testsuite/libgomp.fortran/alloc-6.f90
new file mode 100644
index 00000000000..59fd14da600
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-6.f90
@@ -0,0 +1,45 @@
+module m
+  use omp_lib
+  implicit none
+
+  type (omp_alloctrait), parameter :: traits(*) &
+    = [ omp_alloctrait (omp_atk_pool_size, 1), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_abort_fb) ]
+end module m
+
+program main
+  use m
+  use iso_c_binding
+  implicit none (external, type)
+  integer (omp_allocator_handle_kind) :: a
+  integer(c_size_t), parameter :: zero = 0_c_size_t
+
+  if (c_associated (omp_alloc (zero, omp_null_allocator))) &
+    stop 1
+  if (c_associated (omp_aligned_alloc (64_c_size_t, zero, omp_null_allocator))) &
+    stop 2
+  if (c_associated (omp_calloc (zero, zero, omp_null_allocator)) &
+      .or. c_associated (omp_calloc (32_c_size_t, zero, omp_null_allocator)) &
+      .or. c_associated (omp_calloc (zero, 64_c_size_t, omp_null_allocator))) &
+    stop 3
+  if (c_associated (omp_aligned_calloc (32_c_size_t, zero, zero, omp_null_allocator)) &
+      .or. c_associated (omp_aligned_calloc (64_c_size_t, 32_c_size_t, zero, omp_null_allocator)) &
+      .or. c_associated (omp_aligned_calloc (16_c_size_t, zero, 64_c_size_t, omp_null_allocator))) &
+    stop 4
+  a = omp_init_allocator (omp_default_mem_space, 2, traits)
+  if (a /= omp_null_allocator) then
+    if (c_associated (omp_alloc (zero, a)) &
+        .or. c_associated (omp_alloc (zero, a)) &
+        .or. c_associated (omp_alloc (zero, a)) &
+        .or. c_associated (omp_aligned_alloc (16_c_size_t, zero, a)) &
+        .or. c_associated (omp_aligned_alloc (128_c_size_t, zero, a)) &
+        .or. c_associated (omp_calloc (zero, zero, a)) &
+        .or. c_associated (omp_calloc (32_c_size_t, zero, a)) &
+        .or. c_associated (omp_calloc (zero, 64_c_size_t, a)) &
+        .or. c_associated (omp_aligned_calloc (32_c_size_t, zero, zero, a)) &
+        .or. c_associated (omp_aligned_calloc (64_c_size_t, 32_c_size_t, zero, a)) &
+        .or. c_associated (omp_aligned_calloc (16_c_size_t, zero, 64_c_size_t, a))) &
+      stop 5
+    call omp_destroy_allocator (a)
+  end if
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-7.c b/libgomp/testsuite/libgomp.fortran/alloc-7.c
new file mode 100644
index 00000000000..4d16d095150
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-7.c
@@ -0,0 +1,5 @@
+int
+get__alignof_int ()
+{
+  return __alignof (int);
+}
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-7.f90 b/libgomp/testsuite/libgomp.fortran/alloc-7.f90
new file mode 100644
index 00000000000..b047b0e4d10
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-7.f90
@@ -0,0 +1,174 @@
+! { dg-additional-sources alloc-7.c }
+module m
+  use omp_lib
+  use iso_c_binding
+  implicit none
+
+  type (omp_alloctrait), parameter :: traits2(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 16), &
+        omp_alloctrait (omp_atk_sync_hint, omp_atv_default), &
+        omp_alloctrait (omp_atk_access, omp_atv_default), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_default_mem_fb), &
+        omp_alloctrait (omp_atk_partition, omp_atv_environment)]
+
+  type (omp_alloctrait) :: traits3(7) &
+    = [ omp_alloctrait (omp_atk_sync_hint, omp_atv_uncontended), &
+        omp_alloctrait (omp_atk_alignment, 32), &
+        omp_alloctrait (omp_atk_access, omp_atv_all), &
+        omp_alloctrait (omp_atk_pool_size, 512), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_allocator_fb), &
+        omp_alloctrait (omp_atk_fb_data, 0), &
+        omp_alloctrait (omp_atk_partition, omp_atv_default)]
+
+  type (omp_alloctrait), parameter :: traits4(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 128), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_null_fb)]
+
+  interface
+    integer(c_int) function get__alignof_int () bind(C)
+      import :: c_int
+    end
+  end interface
+end module m
+
+program main
+  use m
+  implicit none (external, type)
+  integer(c_ptrdiff_t) :: iptr
+  type (c_ptr), volatile :: p, q, r
+  integer, pointer, volatile, contiguous :: ip(:), iq(:), ir(:)
+  type (omp_alloctrait) :: traits(3)
+  integer (omp_allocator_handle_kind) :: a, a2
+  traits  = [ omp_alloctrait (omp_atk_alignment, 64), &
+              omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
+              omp_alloctrait (omp_atk_pool_size, 4096)]
+
+  p = omp_aligned_alloc (c_sizeof (0), 3 * c_sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [3])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0) &
+    stop 1
+  ip(0) = 1
+  ip(1) = 2
+  ip(2) = 3
+  call omp_free (p, omp_default_mem_alloc)
+
+  p = omp_aligned_alloc (2 * c_sizeof (0), 2 * c_sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [2])
+  if (mod (TRANSFER (p, iptr), 2 * c_sizeof (0)) /= 0) &
+    stop 2
+  ip(0) = 1
+  ip(1) = 2
+  call omp_free (p, omp_null_allocator)
+
+  call omp_set_default_allocator (omp_default_mem_alloc)
+  p = omp_aligned_alloc (1_c_size_t, 2 * c_sizeof (0), omp_null_allocator)
+  call c_f_pointer (p, ip, [2])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0) &
+    stop 3
+  ip(0) = 3
+  call omp_free (p, omp_get_default_allocator ())
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits)
+  if (a == omp_null_allocator) &
+    stop 4
+  p = omp_aligned_alloc (32_c_size_t, 3072_c_size_t, a)
+  call c_f_pointer (p, ip, [3072/c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 64) /= 0) &
+    stop 5
+  ip(1) = 1
+  ip(3072 / c_sizeof (0)) = 2
+
+  if (c_associated (omp_aligned_alloc (8_c_size_t, 3072_c_size_t, a))) &
+    stop 6
+
+  call omp_free (p, a)
+
+  p = omp_aligned_alloc (128_c_size_t, 3072_c_size_t, a)
+  call c_f_pointer (p, ip, [3072/c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 128) /= 0) &
+    stop 7
+  ip(1) = 3
+  ip(3072 / c_sizeof (0)) = 4
+  call omp_free (p, omp_null_allocator)
+
+  call omp_set_default_allocator (a)
+  if (omp_get_default_allocator () /= a) &
+    stop 8
+  p = omp_aligned_alloc (64_c_size_t, 3072_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [3072/c_sizeof (0)])
+  if (c_associated (omp_aligned_alloc (8_c_size_t, 3072_c_size_t, omp_null_allocator))) &
+    stop 9
+  call omp_free (p, a)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits2), traits2)
+  if (a == omp_null_allocator) &
+    stop 9
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 10
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 11
+
+  p = omp_aligned_alloc (4_c_size_t, 420_c_size_t, a2)
+  call c_f_pointer (p, ip, [420/c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 12
+  ip(1) = 5
+  ip(420 / c_sizeof (0)) = 6
+
+  q = omp_aligned_alloc (8_c_size_t, 768_c_size_t, a2)
+  call c_f_pointer (q, iq, [768/c_sizeof (0)])
+  if (mod (TRANSFER (q, iptr), 16) /= 0) &
+    stop 13
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+
+  r = omp_aligned_alloc (8_c_size_t, 512_c_size_t, a2)
+  call c_f_pointer (r, ir, [512/c_sizeof (0)])
+  if (mod (TRANSFER (r, iptr), 8) /= 0) &
+    stop 14
+  ir(1) = 9
+  ir(512 / c_sizeof (0)) = 10
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, a2)
+  call omp_free (r, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits4), traits4)
+  if (a == omp_null_allocator) &
+    stop 15
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 16
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 17
+  call omp_set_default_allocator (a2)
+
+  p = omp_aligned_alloc (4_c_size_t, 420_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [420/c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 18
+  ip(0) = 5
+  ip(420 / c_sizeof (0)) = 6
+
+  q = omp_aligned_alloc (64_c_size_t, 768_c_size_t, omp_null_allocator)
+  call c_f_pointer (q, iq, [768/c_sizeof (0)])
+  if (mod (TRANSFER (q, iptr), 128) /= 0) &
+    stop 19
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+  if (c_associated (omp_aligned_alloc (8_c_size_t, 768_c_size_t, omp_null_allocator))) &
+    stop 20
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-8.f90 b/libgomp/testsuite/libgomp.fortran/alloc-8.f90
new file mode 100644
index 00000000000..4bff4d6ea29
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-8.f90
@@ -0,0 +1,58 @@
+module m
+  use omp_lib
+  implicit none
+
+  type (omp_alloctrait), parameter :: traits(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 16), &
+        omp_alloctrait (omp_atk_sync_hint, omp_atv_default), &
+        omp_alloctrait (omp_atk_access, omp_atv_default), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_default_mem_fb), &
+        omp_alloctrait (omp_atk_partition, omp_atv_environment)]
+end module m
+
+program main
+  use m
+  use iso_c_binding
+  implicit none (external, type)
+  integer (omp_allocator_handle_kind) :: a
+  type (c_ptr) :: p, q
+  integer (c_size_t), volatile :: large_sz
+  integer (c_ptrdiff_t) :: iptr
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits), traits)
+  if (a == omp_null_allocator) &
+    stop 1
+  p = omp_alloc (2048_c_size_t, a)
+  if (mod (TRANSFER (p, iptr), 16) /= 0) &
+    stop 2
+  large_sz = NOT (1023_c_size_t)
+  q = omp_alloc (large_sz, a)
+  if (c_associated (q)) &
+    stop 3
+  q = omp_aligned_alloc (32_c_size_t, large_sz, a)
+  if (c_associated (q)) &
+    stop 4
+  q = omp_calloc (large_sz / 4_c_size_t, 4_c_size_t, a)
+  if (c_associated (q)) &
+    stop 5
+  q = omp_aligned_calloc (1_c_size_t, 2_c_size_t, large_sz / 2, a)
+  if (c_associated (q)) &
+    stop 6
+  call omp_free (p, a)
+  large_sz = NOT (0_c_size_t)
+  large_sz = ISHFT (large_sz, -1)
+  large_sz = large_sz + 1
+  if (c_associated (omp_calloc (2_c_size_t, large_sz, a))) &
+    stop 7
+  if (c_associated (omp_calloc (large_sz, 1024_c_size_t, a))) &
+    stop 8
+  if (c_associated (omp_calloc (large_sz, large_sz, a))) &
+    stop 9
+  if (c_associated (omp_aligned_calloc (16_c_size_t, 2_c_size_t, large_sz, a))) &
+    stop 10
+  if (c_associated (omp_aligned_calloc (32_c_size_t, large_sz, 1024_c_size_t, a))) &
+    stop 11
+  if (c_associated (omp_aligned_calloc (64_c_size_t, large_sz, large_sz, a))) &
+    stop 12
+  call omp_destroy_allocator (a)
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-9.f90 b/libgomp/testsuite/libgomp.fortran/alloc-9.f90
new file mode 100644
index 00000000000..6458f35fd1f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-9.f90
@@ -0,0 +1,196 @@
+! { dg-additional-sources alloc-7.c }
+module m
+  use omp_lib
+  use iso_c_binding
+  implicit none
+
+  type (omp_alloctrait), parameter :: traits2(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 16), &
+        omp_alloctrait (omp_atk_sync_hint, omp_atv_default), &
+        omp_alloctrait (omp_atk_access, omp_atv_default), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_default_mem_fb), &
+        omp_alloctrait (omp_atk_partition, omp_atv_environment)]
+  type (omp_alloctrait) :: traits3(7) &
+    = [ omp_alloctrait (omp_atk_sync_hint, omp_atv_uncontended), &
+        omp_alloctrait (omp_atk_alignment, 32), &
+        omp_alloctrait (omp_atk_access, omp_atv_all), &
+        omp_alloctrait (omp_atk_pool_size, 512), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_allocator_fb), &
+        omp_alloctrait (omp_atk_fb_data, 0), &
+        omp_alloctrait (omp_atk_partition, omp_atv_default)]
+  type (omp_alloctrait), parameter :: traits4(*) &
+    = [ omp_alloctrait (omp_atk_alignment, 128), &
+        omp_alloctrait (omp_atk_pool_size, 1024), &
+        omp_alloctrait (omp_atk_fallback, omp_atv_null_fb)]
+
+  interface
+    integer(c_int) function get__alignof_int () bind(C)
+      import :: c_int
+    end
+  end interface
+end module m
+
+program main
+  use m
+  implicit none (external, type)
+  type(c_ptr), volatile :: p, q, r
+  integer, pointer, contiguous, volatile :: ip(:), iq(:), ir(:)
+  type (omp_alloctrait) :: traits(3)
+  integer (omp_allocator_handle_kind) :: a, a2
+  integer (c_ptrdiff_t) :: iptr
+  integer :: i
+
+  traits  = [ omp_alloctrait (omp_atk_alignment, 64), &
+              omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
+              omp_alloctrait (omp_atk_pool_size, 4096)]
+
+  p = omp_calloc (3_c_size_t, sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [3])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
+      .or. ip(1) /= 0 .or. ip(2) /= 0 .or. ip(3) /= 0) &
+    stop 1
+  ip(1) = 1
+  ip(2) = 2
+  ip(3) = 3
+  call omp_free (p, omp_default_mem_alloc)
+  p = omp_calloc (2_c_size_t, sizeof (0), omp_default_mem_alloc)
+  call c_f_pointer (p, ip, [2])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
+      .or. ip(1) /= 0 .or. ip(2) /= 0) &
+    stop 2
+  ip(1) = 1
+  ip(2) = 2
+  call omp_free (p, omp_null_allocator)
+  call omp_set_default_allocator (omp_default_mem_alloc)
+  p = omp_calloc (1_c_size_t, sizeof (0), omp_null_allocator)
+  call c_f_pointer (p, ip, [1])
+  if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
+      .or. ip(1) /= 0) &
+    stop 3
+  ip(1) = 3
+  call omp_free (p, omp_get_default_allocator ())
+
+  a = omp_init_allocator (omp_default_mem_space, 3, traits)
+  if (a == omp_null_allocator) &
+    stop 4
+  p = omp_calloc (3_c_size_t, 1024_c_size_t, a)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 64) /= 0) &
+    stop 5
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 6
+  end do
+  ip(1) = 1
+  ip(3072 / c_sizeof (0)) = 2
+  if (c_associated (omp_calloc (1024_c_size_t, 3_c_size_t, a))) &
+    stop 7
+  call omp_free (p, a)
+  p = omp_calloc (512_c_size_t, 6_c_size_t, a)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 8
+  end do
+  ip(1) = 3
+  ip(3072 / c_sizeof (0)) = 4
+  call omp_free (p, omp_null_allocator)
+  call omp_set_default_allocator (a)
+  if (omp_get_default_allocator () /= a) &
+    stop 9
+  p = omp_calloc (12_c_size_t, 256_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
+  do i = 1, 3072 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 10
+  end do
+  if (c_associated (omp_calloc (128_c_size_t, 24_c_size_t, omp_null_allocator))) &
+    stop 11
+  call omp_free (p, a)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits2), traits2)
+  if (a == omp_null_allocator) &
+    stop 12
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 13
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 14
+  p = omp_calloc (10_c_size_t, 42_c_size_t, a2)
+  call c_f_pointer (p, ip, [420 / c_sizeof (0)])
+  do i = 1, 420 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 15
+  end do
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 16
+  ip(1) = 5
+  ip(420 / c_sizeof (0)) = 6
+  q = omp_calloc (24_c_size_t, 32_c_size_t, a2)
+  call c_f_pointer (q, iq, [768 / c_sizeof (0)])
+  if (mod (TRANSFER (q, iptr), 16) /= 0) &
+    stop 17
+  do i = 1, 768 / c_sizeof (0)
+    if (iq(i) /= 0) &
+      stop 18
+  end do
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+  r = omp_calloc (128_c_size_t, 4_c_size_t, a2)
+  call c_f_pointer (r, ir, [512 / c_sizeof (0)])
+  if (mod (TRANSFER (r, iptr), get__alignof_int ()) /= 0) &
+    stop 19
+  do i = 1, 512 / c_sizeof (0)
+    if (ir(i) /= 0) &
+      stop 20
+  end do
+  ir(1) = 9
+  ir(512 / c_sizeof (0)) = 10
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, a2)
+  call omp_free (r, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+
+  a = omp_init_allocator (omp_default_mem_space, size (traits4), traits4)
+  if (a == omp_null_allocator) &
+    stop 21
+  if (traits3(6)%key /= omp_atk_fb_data) &
+    stop 22
+  traits3(6)%value = a
+  a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
+  if (a2 == omp_null_allocator) &
+    stop 23
+  call omp_set_default_allocator (a2)
+  p = omp_calloc (42_c_size_t, 10_c_size_t, omp_null_allocator)
+  call c_f_pointer (p, ip, [420 / c_sizeof (0)])
+  if (mod (TRANSFER (p, iptr), 32) /= 0) &
+    stop 24
+  do i = 1, 420 / c_sizeof (0)
+    if (ip(i) /= 0) &
+      stop 25
+  end do
+  ip(1) = 5
+  ip(420 / c_sizeof (0)) = 6
+  q = omp_calloc (32_c_size_t, 24_c_size_t, omp_null_allocator)
+  call c_f_pointer (q, iq, [768 / c_sizeof (0)])
+  if (mod (TRANSFER (q, iptr), 128) /= 0) &
+    stop 26
+  do i = 1, 768 / c_sizeof (0)
+    if (iq(i) /= 0) &
+      stop 27
+  end do
+  iq(1) = 7
+  iq(768 / c_sizeof (0)) = 8
+  if (c_associated (omp_calloc (24_c_size_t, 32_c_size_t, omp_null_allocator))) &
+    stop 28
+  call omp_free (p, omp_null_allocator)
+  call omp_free (q, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_free (c_null_ptr, omp_null_allocator)
+  call omp_destroy_allocator (a2)
+  call omp_destroy_allocator (a)
+end program main

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc)
  2021-09-30 11:14 ` [Patch] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc) Tobias Burnus
@ 2021-09-30 11:31   ` Jakub Jelinek
  2021-09-30 12:49     ` [Patch] openmp: Add omp_aligned_{, c}alloc and omp_{c, re}alloc " Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2021-09-30 11:31 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran

On Thu, Sep 30, 2021 at 01:14:49PM +0200, Tobias Burnus wrote:
> On 30.09.21 09:45, Jakub Jelinek wrote:
> 
> > This patch adds new OpenMP 5.1 allocator entrypoints ...
> 
> ... and this patch adds the Fortran support for it, using the C→Fortran
> converted testcases. Additionally, it fixes and updated the list of API
> routine names. We now can also tick off one item in the OpenMP 5.1
> implementation status list.
> 
> OK for mainline?
> 
> Tobias
> 
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

> openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran
> 
> gcc/ChangeLog:
> 
> 	* omp-low.c (omp_runtime_api_call): Add omp_aligned_{,c}alloc and
> 	omp_{c,re}alloc, fix omp_alloc/omp_free.
> 
> libgomp/ChangeLog:
> 
> 	* libgomp.texi (OpenMP 5.1): Set implementation status to Y for
> 	omp_aligned_{,c}alloc and omp_{c,re}alloc routines.
> 	* omp_lib.f90.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
> 	omp_realloc): Add.
> 	* omp_lib.h.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
> 	omp_realloc): Add.
> 	* testsuite/libgomp.fortran/alloc-10.f90: New test.
> 	* testsuite/libgomp.fortran/alloc-6.f90: New test.
> 	* testsuite/libgomp.fortran/alloc-7.c: New test.
> 	* testsuite/libgomp.fortran/alloc-7.f90: New test.
> 	* testsuite/libgomp.fortran/alloc-8.f90: New test.
> 	* testsuite/libgomp.fortran/alloc-9.f90: New test.

Ok, thanks.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] openmp: Add omp_aligned_{, c}alloc and omp_{c, re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc)
  2021-09-30 11:31   ` Jakub Jelinek
@ 2021-09-30 12:49     ` Tobias Burnus
  0 siblings, 0 replies; 4+ messages in thread
From: Tobias Burnus @ 2021-09-30 12:49 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, fortran

[-- Attachment #1: Type: text/plain, Size: 461 bytes --]

Forgot to do a "git add" after modifying three testcases ...

This silences the warning for a flag only valid for f951 but not for cc1.

Committed the follow-up as r12-3984.

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 1869 bytes --]

commit ef37ddf477ac4b21ec4d1be9260cfd3b431fd4a9
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu Sep 30 14:44:06 2021 +0200

    libgomp.fortran/alloc-*.f90: Add missing dg-prune-output
    
    libgomp/
            * testsuite/libgomp.fortran/alloc-7.f90: Add dg-prune-output
            for -fintrinsic-modules-path= warning of the C compiler.
            * testsuite/libgomp.fortran/alloc-9.f90: Likewise.
            * testsuite/libgomp.fortran/alloc-10.f90: Likewise.

diff --git a/libgomp/testsuite/libgomp.fortran/alloc-10.f90 b/libgomp/testsuite/libgomp.fortran/alloc-10.f90
index d26a83b216a..060c16f312b 100644
--- a/libgomp/testsuite/libgomp.fortran/alloc-10.f90
+++ b/libgomp/testsuite/libgomp.fortran/alloc-10.f90
@@ -1,4 +1,5 @@
 ! { dg-additional-sources alloc-7.c }
+! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
 module m
   use omp_lib
   use iso_c_binding
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-7.f90 b/libgomp/testsuite/libgomp.fortran/alloc-7.f90
index b047b0e4d10..d8c7eee8c25 100644
--- a/libgomp/testsuite/libgomp.fortran/alloc-7.f90
+++ b/libgomp/testsuite/libgomp.fortran/alloc-7.f90
@@ -1,4 +1,5 @@
 ! { dg-additional-sources alloc-7.c }
+! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
 module m
   use omp_lib
   use iso_c_binding
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-9.f90 b/libgomp/testsuite/libgomp.fortran/alloc-9.f90
index 6458f35fd1f..1da141631bc 100644
--- a/libgomp/testsuite/libgomp.fortran/alloc-9.f90
+++ b/libgomp/testsuite/libgomp.fortran/alloc-9.f90
@@ -1,4 +1,5 @@
 ! { dg-additional-sources alloc-7.c }
+! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
 module m
   use omp_lib
   use iso_c_binding

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-30 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  7:45 [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc Jakub Jelinek
2021-09-30 11:14 ` [Patch] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran (was: [committed] openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc) Tobias Burnus
2021-09-30 11:31   ` Jakub Jelinek
2021-09-30 12:49     ` [Patch] openmp: Add omp_aligned_{, c}alloc and omp_{c, re}alloc " Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).