public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* is it safe to generate profiles from multiple concurrent processes?
       [not found] <3D1DD18C-D9D8-4135-9CB5-4E3CDACBF0F1@gmail.com>
@ 2014-06-25 12:40 ` Vincenzo Innocente
  2014-06-25 12:58   ` Markus Trippelsdorf
  0 siblings, 1 reply; 5+ messages in thread
From: Vincenzo Innocente @ 2014-06-25 12:40 UTC (permalink / raw)
  To: gcc-help

I have built a library with -fprofile-generate. 
Now I want to generate profiles using various applications that link that library.

My understanding is that it is safe to run a multi-thread process to populate the profiles.
It is unclear to me if one can safely run multiple processes concurrently.

is there any risk of corruption or overwriting of the various "gcda” files if different processes attempt to write on them?
If safe I can easily speed up the generation of profiles by orders of magnitude.

 thanks,
     vincenzo


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

* Re: is it safe to generate profiles from multiple concurrent processes?
  2014-06-25 12:40 ` is it safe to generate profiles from multiple concurrent processes? Vincenzo Innocente
@ 2014-06-25 12:58   ` Markus Trippelsdorf
  2014-06-25 13:52     ` Arbol One
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Trippelsdorf @ 2014-06-25 12:58 UTC (permalink / raw)
  To: Vincenzo Innocente; +Cc: gcc-help

On 2014.06.25 at 11:35 +0200, Vincenzo Innocente wrote:
> I have built a library with -fprofile-generate.  Now I want to
> generate profiles using various applications that link that library.
> 
> My understanding is that it is safe to run a multi-thread process to
> populate the profiles.
> It is unclear to me if one can safely run multiple processes concurrently.
> 
> is there any risk of corruption or overwriting of the various "gcda”
> files if different processes attempt to write on them?  If safe I can
> easily speed up the generation of profiles by orders of magnitude.

The gcda files are accessed by proper locks, so you should be save.
(See gcc/gcov-io.c).

-- 
Markus

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

* Re: is it safe to generate profiles from multiple concurrent processes?
  2014-06-25 12:58   ` Markus Trippelsdorf
@ 2014-06-25 13:52     ` Arbol One
  2014-06-25 15:23       ` Jonathan Wakely
  2014-06-25 16:57       ` Vincenzo Innocente
  0 siblings, 2 replies; 5+ messages in thread
From: Arbol One @ 2014-06-25 13:52 UTC (permalink / raw)
  To: Markus Trippelsdorf, Vincenzo Innocente; +Cc: gcc-help

I would like to change this code
------
#include <fstream>
int main () {
  std::fstream fs;
  fs.open ("test.txt", std::fstream::in | std::fstream::out | 
std::fstream::app);
  fs << " more lorem ipsum";
  fs.close();
  return 0;
}
-------
To look like this
#include <fstream>
int main () {
  using my_read = std::fstream::in; //<== Error: expected type-specifier
  std::fstream fs;
  fs.open ("test.txt", my_read | std::fstream::out; | std::fstream::app);
  fs << " more lorem ipsum";
  fs.close();
  return 0;
}

What am I doing wrong?

-----Original Message----- 
From: Markus Trippelsdorf
Sent: Wednesday, June 25, 2014 7:59 AM
To: Vincenzo Innocente
Cc: gcc-help@gcc.gnu.org
Subject: Re: is it safe to generate profiles from multiple concurrent 
processes?

On 2014.06.25 at 11:35 +0200, Vincenzo Innocente wrote:
> I have built a library with -fprofile-generate.  Now I want to
> generate profiles using various applications that link that library.
>
> My understanding is that it is safe to run a multi-thread process to
> populate the profiles.
> It is unclear to me if one can safely run multiple processes concurrently.
>
> is there any risk of corruption or overwriting of the various "gcda”
> files if different processes attempt to write on them?  If safe I can
> easily speed up the generation of profiles by orders of magnitude.

The gcda files are accessed by proper locks, so you should be save.
(See gcc/gcov-io.c).

-- 
Markus 

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

* Re: is it safe to generate profiles from multiple concurrent processes?
  2014-06-25 13:52     ` Arbol One
@ 2014-06-25 15:23       ` Jonathan Wakely
  2014-06-25 16:57       ` Vincenzo Innocente
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2014-06-25 15:23 UTC (permalink / raw)
  To: Arbol One; +Cc: gcc-help

On 25 June 2014 14:13, Arbol One wrote:

Please don't hijack other people's threads for unrelated questions.


> To look like this
> #include <fstream>
> int main () {
>  using my_read = std::fstream::in; //<== Error: expected type-specifier

"using" declares a typedef, not a variable.

Try:

   auto my_read = ...

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

* Re: is it safe to generate profiles from multiple concurrent processes?
  2014-06-25 13:52     ` Arbol One
  2014-06-25 15:23       ` Jonathan Wakely
@ 2014-06-25 16:57       ` Vincenzo Innocente
  1 sibling, 0 replies; 5+ messages in thread
From: Vincenzo Innocente @ 2014-06-25 16:57 UTC (permalink / raw)
  To: Arbol One; +Cc: gcc-help

> std::fstream::in is not a type 

the error is indeed 
error: ‘in’ in ‘std::fstream {aka class std::basic_fstream<char>}’ does not name a type

btw  you have a spurious “;” before "|"

I think you are confusing the usage of “using” and “auto” keywords

this compiles

#include <fstream>
int main () {
auto && my_read = std::fstream::in;
std::fstream fs;
fs.open ("test.txt", my_read | std::fstream::out | std::fstream::app);
fs << " more lorem ipsum";
fs.close();
return 0;
}


On 25 Jun, 2014, at 3:13 PM, Arbol One <arbolone@hotmail.ca> wrote:

> #include <fstream>
> int main () {
> using my_read = std::fstream::in; //<== Error: expected type-specifier
> std::fstream fs;
> fs.open ("test.txt", my_read | std::fstream::out; | std::fstream::app);
> fs << " more lorem ipsum";
> fs.close();
> return 0;
> }

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

end of thread, other threads:[~2014-06-25 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3D1DD18C-D9D8-4135-9CB5-4E3CDACBF0F1@gmail.com>
2014-06-25 12:40 ` is it safe to generate profiles from multiple concurrent processes? Vincenzo Innocente
2014-06-25 12:58   ` Markus Trippelsdorf
2014-06-25 13:52     ` Arbol One
2014-06-25 15:23       ` Jonathan Wakely
2014-06-25 16:57       ` Vincenzo Innocente

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).