[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exposing do_octave_atexit in the API
From: |
c. |
Subject: |
Re: exposing do_octave_atexit in the API |
Date: |
Wed, 26 Mar 2014 11:17:50 +0100 |
On 27 Feb 2014, at 08:07, c. <address@hidden> wrote:
> On 11 Feb 2014, at 16:37, c. <address@hidden> wrote:
>
>> Hi,
>>
>> I'm embedding the interpreter in an MPI application,
>> so I need to call both clean_up_and_exit (0) and MPI_Finalize () at the and
>> of my code.
>>
>> Unfortunately whatever order I choose causes a crash when the application
>> tries to exit.
>>
>> By applying the patch below to toplev.{cc,h} I can di
>>
>>
>> do_octave_atexit ();
>> MPI_Finalize ();
>> return (0);
>>
>>
>> and have my application shut down gracefully.
>> Does anyone know whether this patch is harmful in any way?
>> Would it be OK to apply it in the repository?
>> Is there a better way to achieve the same?
>>
>> Thanks,
>> c.
>>
>>
>> diff --git a/libinterp/corefcn/toplev.cc b/libinterp/corefcn/toplev.cc
>> --- a/libinterp/corefcn/toplev.cc
>> +++ b/libinterp/corefcn/toplev.cc
>> @@ -662,7 +662,7 @@
>>
>> static std::list<std::string> octave_atexit_functions;
>>
>> -static void
>> +void
>> do_octave_atexit (void)
>> {
>> static bool deja_vu = false;
>> diff --git a/libinterp/corefcn/toplev.h b/libinterp/corefcn/toplev.h
>> --- a/libinterp/corefcn/toplev.h
>> +++ b/libinterp/corefcn/toplev.h
>> @@ -485,4 +485,7 @@
>> } \
>> while (0)
>>
>> +void
>> +do_octave_atexit (void);
>> +
>> #endif
>>
>
So,
thanks to a suggestion I got from jwe in IRC,
I used a cleaner solution that does not
require patching Octave, i.e. I defined
void octave_mpi_exit (int)
{
MPI_Finalize ();
}
and then used the following at the endo of my program:
if (rank == 0)
{
octave_exit = octave_mpi_exit;
clean_up_and_exit (0);
}
else
MPI_Finalize ();
return 0;
}
There is currently an example in the source tree and in the manual
about embedding the interpreter, would it be useful if I submitted
a changeset to add an example about ebedding in a parallel application?
thanks,
c.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: exposing do_octave_atexit in the API,
c. <=