diff mbox series

Add support for dumping multiple dump files under one name

Message ID 20180622111614.GA10763@kam.mff.cuni.cz
State New
Headers show
Series Add support for dumping multiple dump files under one name | expand

Commit Message

Jan Hubicka June 22, 2018, 11:16 a.m. UTC
Hi,
this patch adds dumpfile support for dumps that come in multiple parts.  This
is needed for WPA stream-out dump since we stream partitions in parallel and
the dumps would come up in random order.  Parts are added by new parameter that
is initialzed by default to -1 (no parts). 

One thing I skipped is any support for duplicated opening of file
with parts since I do not need it.

Bootstrapped/regtested x86_64-linux, OK?

Honza

	* dumpfile.c (gcc::dump_manager::get_dump_file_name): Add PART
	 parameter.
	(gcc::dump_manager::get_dump_file_name): likewise.
	(dump_begin): Likewise.
	* dumpfile.h (dump_begin): Update prototype.
	(gcc::dump_manager::get_dump_file_name,
	gcc::dump_manager::get_dump_file_name): Update prototype.

Comments

Richard Biener June 29, 2018, 8:15 a.m. UTC | #1
On Fri, 22 Jun 2018, Jan Hubicka wrote:

> Hi,
> this patch adds dumpfile support for dumps that come in multiple parts.  This
> is needed for WPA stream-out dump since we stream partitions in parallel and
> the dumps would come up in random order.  Parts are added by new parameter that
> is initialzed by default to -1 (no parts). 
> 
> One thing I skipped is any support for duplicated opening of file
> with parts since I do not need it.
> 
> Bootstrapped/regtested x86_64-linux, OK?

Looks reasonable - David, anything you want to add / have changed?

Thanks,
Richard.

> Honza
> 
> 	* dumpfile.c (gcc::dump_manager::get_dump_file_name): Add PART
> 	 parameter.
> 	(gcc::dump_manager::get_dump_file_name): likewise.
> 	(dump_begin): Likewise.
> 	* dumpfile.h (dump_begin): Update prototype.
> 	(gcc::dump_manager::get_dump_file_name,
> 	gcc::dump_manager::get_dump_file_name): Update prototype.
> Index: dumpfile.c
> ===================================================================
> --- dumpfile.c	(revision 261885)
> +++ dumpfile.c	(working copy)
> @@ -269,7 +269,7 @@ get_dump_file_info_by_switch (const char
>  
>  char *
>  gcc::dump_manager::
> -get_dump_file_name (int phase) const
> +get_dump_file_name (int phase, int part) const
>  {
>    struct dump_file_info *dfi;
>  
> @@ -278,7 +278,7 @@ get_dump_file_name (int phase) const
>  
>    dfi = get_dump_file_info (phase);
>  
> -  return get_dump_file_name (dfi);
> +  return get_dump_file_name (dfi, part);
>  }
>  
>  /* Return the name of the dump file for the given dump_file_info.
> @@ -288,7 +288,7 @@ get_dump_file_name (int phase) const
>  
>  char *
>  gcc::dump_manager::
> -get_dump_file_name (struct dump_file_info *dfi) const
> +get_dump_file_name (struct dump_file_info *dfi, int part) const
>  {
>    char dump_id[10];
>  
> @@ -312,7 +312,14 @@ get_dump_file_name (struct dump_file_inf
>  	dump_id[0] = '\0';
>      }
>  
> -  return concat (dump_base_name, dump_id, dfi->suffix, NULL);
> +  if (part != -1)
> +    {
> +       char part_id[8];
> +       snprintf (part_id, sizeof (part_id), ".%i", part);
> +       return concat (dump_base_name, dump_id, part_id, dfi->suffix, NULL);
> +    }
> +  else
> +    return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>  }
>  
>  /* Open a dump file called FILENAME.  Some filenames are special and
> @@ -592,17 +599,19 @@ dump_finish (int phase)
>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>     *FLAG_PTR and returns a stream to write to. If the dump is not
>     enabled, returns NULL.
> -   Multiple calls will reopen and append to the dump file.  */
> +   PART can be used for dump files which should be split to multiple
> +   parts. PART == -1 indicates dump file with no parts.
> +   If PART is -1, multiple calls will reopen and append to the dump file.  */
>  
>  FILE *
> -dump_begin (int phase, dump_flags_t *flag_ptr)
> +dump_begin (int phase, dump_flags_t *flag_ptr, int part)
>  {
> -  return g->get_dumps ()->dump_begin (phase, flag_ptr);
> +  return g->get_dumps ()->dump_begin (phase, flag_ptr, part);
>  }
>  
>  FILE *
>  gcc::dump_manager::
> -dump_begin (int phase, dump_flags_t *flag_ptr)
> +dump_begin (int phase, dump_flags_t *flag_ptr, int part)
>  {
>    char *name;
>    struct dump_file_info *dfi;
> @@ -611,12 +620,14 @@ dump_begin (int phase, dump_flags_t *fla
>    if (phase == TDI_none || !dump_phase_enabled_p (phase))
>      return NULL;
>  
> -  name = get_dump_file_name (phase);
> +  name = get_dump_file_name (phase, part);
>    if (!name)
>      return NULL;
>    dfi = get_dump_file_info (phase);
>  
> -  stream = dump_open (name, dfi->pstate < 0);
> +  /* We do not support re-opening of dump files with parts.  This would require
> +     tracking pstate per part of the dump file.  */
> +  stream = dump_open (name, part != -1 || dfi->pstate < 0);
>    if (stream)
>      dfi->pstate = 1;
>    free (name);
> Index: dumpfile.h
> ===================================================================
> --- dumpfile.h	(revision 261885)
> +++ dumpfile.h	(working copy)
> @@ -269,7 +269,7 @@ struct dump_file_info
>  };
>  
>  /* In dumpfile.c */
> -extern FILE *dump_begin (int, dump_flags_t *);
> +extern FILE *dump_begin (int, dump_flags_t *, int part=-1);
>  extern void dump_end (int, FILE *);
>  extern int opt_info_switch_p (const char *);
>  extern const char *dump_flag_name (int);
> @@ -343,10 +343,10 @@ public:
>    /* Return the name of the dump file for the given phase.
>       If the dump is not enabled, returns NULL.  */
>    char *
> -  get_dump_file_name (int phase) const;
> +  get_dump_file_name (int phase, int part = -1) const;
>  
>    char *
> -  get_dump_file_name (struct dump_file_info *dfi) const;
> +  get_dump_file_name (struct dump_file_info *dfi, int part = -1) const;
>  
>    int
>    dump_switch_p (const char *arg);
> @@ -365,7 +365,7 @@ public:
>    dump_finish (int phase);
>  
>    FILE *
> -  dump_begin (int phase, dump_flags_t *flag_ptr);
> +  dump_begin (int phase, dump_flags_t *flag_ptr, int part);
>  
>    /* Returns nonzero if tree dump PHASE has been initialized.  */
>    int
> 
>
David Malcolm June 29, 2018, 10:13 a.m. UTC | #2
On Fri, 2018-06-29 at 10:15 +0200, Richard Biener wrote:
> On Fri, 22 Jun 2018, Jan Hubicka wrote:
> 
> > Hi,
> > this patch adds dumpfile support for dumps that come in multiple
> > parts.  This
> > is needed for WPA stream-out dump since we stream partitions in
> > parallel and
> > the dumps would come up in random order.  Parts are added by new
> > parameter that
> > is initialzed by default to -1 (no parts). 
> > 
> > One thing I skipped is any support for duplicated opening of file
> > with parts since I do not need it.
> > 
> > Bootstrapped/regtested x86_64-linux, OK?
> 
> Looks reasonable - David, anything you want to add / have changed?

No worries from my side; I don't think it interacts with the
optimization records stuff I'm working on - presumably this is just for
dumping the WPA stream-out, rather than for dumping specific
optimizations.

[...snip...]

Dave
Andre Vieira (lists) July 3, 2018, 10 a.m. UTC | #3
On 29/06/18 11:13, David Malcolm wrote:
> On Fri, 2018-06-29 at 10:15 +0200, Richard Biener wrote:
>> On Fri, 22 Jun 2018, Jan Hubicka wrote:
>>
>>> Hi,
>>> this patch adds dumpfile support for dumps that come in multiple
>>> parts.  This
>>> is needed for WPA stream-out dump since we stream partitions in
>>> parallel and
>>> the dumps would come up in random order.  Parts are added by new
>>> parameter that
>>> is initialzed by default to -1 (no parts). 
>>>
>>> One thing I skipped is any support for duplicated opening of file
>>> with parts since I do not need it.
>>>
>>> Bootstrapped/regtested x86_64-linux, OK?
>>
>> Looks reasonable - David, anything you want to add / have changed?
> 
> No worries from my side; I don't think it interacts with the
> optimization records stuff I'm working on - presumably this is just for
> dumping the WPA stream-out, rather than for dumping specific
> optimizations.
> 
> [...snip...]
> 
> Dave
> 

Hi David,

I believe r262245 is causing the following failures on aarch64 and arm:

FAIL: gcc.dg/vect/slp-perm-1.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-1.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-2.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-2.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-3.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-3.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-5.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-5.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-6.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-6.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-7.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-7.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-8.c -flto -ffat-lto-objects  scan-tree-dump
vect "note: Built SLP cancelled: can use load/store-lanes"
FAIL: gcc.dg/vect/slp-perm-8.c scan-tree-dump vect "note: Built SLP
cancelled: can use load/store-lanes"

Could you please have a look?

Cheers,
Andre
David Malcolm July 3, 2018, 2:15 p.m. UTC | #4
On Tue, 2018-07-03 at 11:00 +0100, Andre Vieira (lists) wrote:
> On 29/06/18 11:13, David Malcolm wrote:
> > On Fri, 2018-06-29 at 10:15 +0200, Richard Biener wrote:
> > > On Fri, 22 Jun 2018, Jan Hubicka wrote:
> > > 
> > > > Hi,
> > > > this patch adds dumpfile support for dumps that come in
> > > > multiple
> > > > parts.  This
> > > > is needed for WPA stream-out dump since we stream partitions in
> > > > parallel and
> > > > the dumps would come up in random order.  Parts are added by
> > > > new
> > > > parameter that
> > > > is initialzed by default to -1 (no parts). 
> > > > 
> > > > One thing I skipped is any support for duplicated opening of
> > > > file
> > > > with parts since I do not need it.
> > > > 
> > > > Bootstrapped/regtested x86_64-linux, OK?
> > > 
> > > Looks reasonable - David, anything you want to add / have
> > > changed?
> > 
> > No worries from my side; I don't think it interacts with the
> > optimization records stuff I'm working on - presumably this is just
> > for
> > dumping the WPA stream-out, rather than for dumping specific
> > optimizations.
> > 
> > [...snip...]
> > 
> > Dave
> > 
> 
> Hi David,
> 
> I believe r262245 is causing the following failures on aarch64 and
> arm:
> 
> FAIL: gcc.dg/vect/slp-perm-1.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-1.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-2.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-2.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-3.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-3.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-5.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-5.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-6.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-6.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-7.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-7.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-8.c -flto -ffat-lto-objects  scan-tree-
> dump
> vect "note: Built SLP cancelled: can use load/store-lanes"
> FAIL: gcc.dg/vect/slp-perm-8.c scan-tree-dump vect "note: Built SLP
> cancelled: can use load/store-lanes"
> 
> Could you please have a look?

Sorry about this; I think my r262246 ("dumpfile.c: add indentation via
DUMP_VECT_SCOPE") caused this.

Does https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00122.html help?

Dave
Andre Vieira (lists) July 3, 2018, 4:20 p.m. UTC | #5
On 03/07/18 15:15, David Malcolm wrote:
> On Tue, 2018-07-03 at 11:00 +0100, Andre Vieira (lists) wrote:
>> On 29/06/18 11:13, David Malcolm wrote:
>>> On Fri, 2018-06-29 at 10:15 +0200, Richard Biener wrote:
>>>> On Fri, 22 Jun 2018, Jan Hubicka wrote:
>>>>
>>>>> Hi,
>>>>> this patch adds dumpfile support for dumps that come in
>>>>> multiple
>>>>> parts.  This
>>>>> is needed for WPA stream-out dump since we stream partitions in
>>>>> parallel and
>>>>> the dumps would come up in random order.  Parts are added by
>>>>> new
>>>>> parameter that
>>>>> is initialzed by default to -1 (no parts). 
>>>>>
>>>>> One thing I skipped is any support for duplicated opening of
>>>>> file
>>>>> with parts since I do not need it.
>>>>>
>>>>> Bootstrapped/regtested x86_64-linux, OK?
>>>>
>>>> Looks reasonable - David, anything you want to add / have
>>>> changed?
>>>
>>> No worries from my side; I don't think it interacts with the
>>> optimization records stuff I'm working on - presumably this is just
>>> for
>>> dumping the WPA stream-out, rather than for dumping specific
>>> optimizations.
>>>
>>> [...snip...]
>>>
>>> Dave
>>>
>>
>> Hi David,
>>
>> I believe r262245 is causing the following failures on aarch64 and
>> arm:
>>
>> FAIL: gcc.dg/vect/slp-perm-1.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-1.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-2.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-2.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-3.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-3.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-5.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-5.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-6.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-6.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-7.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-7.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-8.c -flto -ffat-lto-objects  scan-tree-
>> dump
>> vect "note: Built SLP cancelled: can use load/store-lanes"
>> FAIL: gcc.dg/vect/slp-perm-8.c scan-tree-dump vect "note: Built SLP
>> cancelled: can use load/store-lanes"
>>
>> Could you please have a look?
> 
> Sorry about this; I think my r262246 ("dumpfile.c: add indentation via
> DUMP_VECT_SCOPE") caused this.
> 
> Does https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00122.html help?

Yes it does. Thank you!

Andre
> 
> Dave
>
diff mbox series

Patch

Index: dumpfile.c
===================================================================
--- dumpfile.c	(revision 261885)
+++ dumpfile.c	(working copy)
@@ -269,7 +269,7 @@  get_dump_file_info_by_switch (const char
 
 char *
 gcc::dump_manager::
-get_dump_file_name (int phase) const
+get_dump_file_name (int phase, int part) const
 {
   struct dump_file_info *dfi;
 
@@ -278,7 +278,7 @@  get_dump_file_name (int phase) const
 
   dfi = get_dump_file_info (phase);
 
-  return get_dump_file_name (dfi);
+  return get_dump_file_name (dfi, part);
 }
 
 /* Return the name of the dump file for the given dump_file_info.
@@ -288,7 +288,7 @@  get_dump_file_name (int phase) const
 
 char *
 gcc::dump_manager::
-get_dump_file_name (struct dump_file_info *dfi) const
+get_dump_file_name (struct dump_file_info *dfi, int part) const
 {
   char dump_id[10];
 
@@ -312,7 +312,14 @@  get_dump_file_name (struct dump_file_inf
 	dump_id[0] = '\0';
     }
 
-  return concat (dump_base_name, dump_id, dfi->suffix, NULL);
+  if (part != -1)
+    {
+       char part_id[8];
+       snprintf (part_id, sizeof (part_id), ".%i", part);
+       return concat (dump_base_name, dump_id, part_id, dfi->suffix, NULL);
+    }
+  else
+    return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }
 
 /* Open a dump file called FILENAME.  Some filenames are special and
@@ -592,17 +599,19 @@  dump_finish (int phase)
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
-   Multiple calls will reopen and append to the dump file.  */
+   PART can be used for dump files which should be split to multiple
+   parts. PART == -1 indicates dump file with no parts.
+   If PART is -1, multiple calls will reopen and append to the dump file.  */
 
 FILE *
-dump_begin (int phase, dump_flags_t *flag_ptr)
+dump_begin (int phase, dump_flags_t *flag_ptr, int part)
 {
-  return g->get_dumps ()->dump_begin (phase, flag_ptr);
+  return g->get_dumps ()->dump_begin (phase, flag_ptr, part);
 }
 
 FILE *
 gcc::dump_manager::
-dump_begin (int phase, dump_flags_t *flag_ptr)
+dump_begin (int phase, dump_flags_t *flag_ptr, int part)
 {
   char *name;
   struct dump_file_info *dfi;
@@ -611,12 +620,14 @@  dump_begin (int phase, dump_flags_t *fla
   if (phase == TDI_none || !dump_phase_enabled_p (phase))
     return NULL;
 
-  name = get_dump_file_name (phase);
+  name = get_dump_file_name (phase, part);
   if (!name)
     return NULL;
   dfi = get_dump_file_info (phase);
 
-  stream = dump_open (name, dfi->pstate < 0);
+  /* We do not support re-opening of dump files with parts.  This would require
+     tracking pstate per part of the dump file.  */
+  stream = dump_open (name, part != -1 || dfi->pstate < 0);
   if (stream)
     dfi->pstate = 1;
   free (name);
Index: dumpfile.h
===================================================================
--- dumpfile.h	(revision 261885)
+++ dumpfile.h	(working copy)
@@ -269,7 +269,7 @@  struct dump_file_info
 };
 
 /* In dumpfile.c */
-extern FILE *dump_begin (int, dump_flags_t *);
+extern FILE *dump_begin (int, dump_flags_t *, int part=-1);
 extern void dump_end (int, FILE *);
 extern int opt_info_switch_p (const char *);
 extern const char *dump_flag_name (int);
@@ -343,10 +343,10 @@  public:
   /* Return the name of the dump file for the given phase.
      If the dump is not enabled, returns NULL.  */
   char *
-  get_dump_file_name (int phase) const;
+  get_dump_file_name (int phase, int part = -1) const;
 
   char *
-  get_dump_file_name (struct dump_file_info *dfi) const;
+  get_dump_file_name (struct dump_file_info *dfi, int part = -1) const;
 
   int
   dump_switch_p (const char *arg);
@@ -365,7 +365,7 @@  public:
   dump_finish (int phase);
 
   FILE *
-  dump_begin (int phase, dump_flags_t *flag_ptr);
+  dump_begin (int phase, dump_flags_t *flag_ptr, int part);
 
   /* Returns nonzero if tree dump PHASE has been initialized.  */
   int