Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request for adios_write to accept 'const void * var' #9

Closed
andrewcorrigan opened this issue Oct 4, 2013 · 7 comments
Closed

request for adios_write to accept 'const void * var' #9

andrewcorrigan opened this issue Oct 4, 2013 · 7 comments

Comments

@andrewcorrigan
Copy link

Can adios_write please be modified to accept 'const void * var'? I assume that it is safe to do so, in which case it'd be preferable to have an explicit assurance that it is safe to assume the data pointed to by var is not modified.

@pnorbert
Copy link
Contributor

I would do this in a clean code. However, the adios_var_struct->data pointer is used for different things (read buffer in old adios_read, transformed variable instead of the original) and I am not able to safely separate them. This will stay open for a while...

@andrewcorrigan
Copy link
Author

Thank you for looking into this.

So are there any circumstances under which it is safe to assume that the data pointed to by var will not be modified by ADIOS? I'm not familiar with what adios_var_struct->data is and how it relates to the data I am passing in to adios_write, but I don't believe I have any variable transformations (I'm just dumping raw data), and I am only concerned with adios_write, not adios_read. If it is safe under those circumstances, then it saves the expense of my code allocating and copying into a temporary buffer.

@pnorbert
Copy link
Contributor

Ah yes, ADIOS does not touch the user data in adios_write() in any
circumstances. It will actually copy data into a buffer (for buffered I/O).
If you buffer too, that is a complete waste of memory. The input arguments
should have been const void * from the beginning, it's just so much harder
to clean this up after several developers grabbing it for their own
purposes over the years :-(

On Mon, May 12, 2014 at 11:50 AM, Andrew Corrigan
notifications@github.comwrote:

Thank you for looking into this.

So are there any circumstances under which it is safe to assume that the
data pointed to by var will not be modified by ADIOS? I'm not familiar with
what adios_var_struct->data is and how it relates to the data I am passing
in to adios_write, but I don't believe I have any variable transformations
(I'm just dumping raw data), and I am only concerned with adios_write, not
adios_read. If it is safe under those circumstances, then it saves the
expense of my code allocating and copying into a temporary buffer.


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-42849679
.

@daboyuka
Copy link
Contributor

Just a thought, since adios_write is really just a wrapper function around
the internal "common" layer, and nowadays it is guaranteed to treat the
data buffer as if it were const, couldn't the signature of adios_write
simply be changed to const void data, and then data be cast to void
before passing to the internal layer? It's a bit ugly, but I believe this
has perfectly well-defined behavior in C, since the buffer is never
actually modified.

Ah yes, ADIOS does not touch the user data in adios_write() in any
circumstances. It will actually copy data into a buffer (for buffered
I/O).
If you buffer too, that is a complete waste of memory. The input arguments
should have been const void * from the beginning, it's just so much harder
to clean this up after several developers grabbing it for their own
purposes over the years :-(

On Mon, May 12, 2014 at 11:50 AM, Andrew Corrigan
notifications@github.comwrote:

Thank you for looking into this.

So are there any circumstances under which it is safe to assume that the
data pointed to by var will not be modified by ADIOS? I'm not familiar
with
what adios_var_struct->data is and how it relates to the data I am
passing
in to adios_write, but I don't believe I have any variable
transformations
(I'm just dumping raw data), and I am only concerned with adios_write,
not
adios_read. If it is safe under those circumstances, then it saves the
expense of my code allocating and copying into a temporary buffer.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42849679>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-42850390
.

@pnorbert
Copy link
Contributor

I am trying to get rid of the many compiler warnings, not to add new ones.

On Mon, May 12, 2014 at 12:49 PM, daboyuka notifications@github.com wrote:

Just a thought, since adios_write is really just a wrapper function around
the internal "common" layer, and nowadays it is guaranteed to treat the
data buffer as if it were const, couldn't the signature of adios_write
simply be changed to const void data, and then data be cast to void
before passing to the internal layer? It's a bit ugly, but I believe this
has perfectly well-defined behavior in C, since the buffer is never
actually modified.

Ah yes, ADIOS does not touch the user data in adios_write() in any
circumstances. It will actually copy data into a buffer (for buffered
I/O).
If you buffer too, that is a complete waste of memory. The input
arguments
should have been const void * from the beginning, it's just so much
harder
to clean this up after several developers grabbing it for their own
purposes over the years :-(

On Mon, May 12, 2014 at 11:50 AM, Andrew Corrigan
notifications@github.comwrote:

Thank you for looking into this.

So are there any circumstances under which it is safe to assume that
the
data pointed to by var will not be modified by ADIOS? I'm not familiar
with
what adios_var_struct->data is and how it relates to the data I am
passing
in to adios_write, but I don't believe I have any variable
transformations
(I'm just dumping raw data), and I am only concerned with adios_write,
not
adios_read. If it is safe under those circumstances, then it saves the
expense of my code allocating and copying into a temporary buffer.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42849679>
.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42850390>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-42857236
.

@daboyuka
Copy link
Contributor

Definitely understandable. I'm fairly sure explicit casting never triggers
warnings, though, so maybe it's still something to keep in mind as a
potential option down the road.

  • Drew

On Mon, May 12, 2014 at 1:00 PM, pnorbert notifications@github.com wrote:

I am trying to get rid of the many compiler warnings, not to add new ones.

On Mon, May 12, 2014 at 12:49 PM, daboyuka notifications@github.com
wrote:

Just a thought, since adios_write is really just a wrapper function
around
the internal "common" layer, and nowadays it is guaranteed to treat the
data buffer as if it were const, couldn't the signature of adios_write
simply be changed to const void data, and then data be cast to void
before passing to the internal layer? It's a bit ugly, but I believe
this
has perfectly well-defined behavior in C, since the buffer is never
actually modified.

Ah yes, ADIOS does not touch the user data in adios_write() in any
circumstances. It will actually copy data into a buffer (for buffered
I/O).
If you buffer too, that is a complete waste of memory. The input
arguments
should have been const void * from the beginning, it's just so much
harder
to clean this up after several developers grabbing it for their own
purposes over the years :-(

On Mon, May 12, 2014 at 11:50 AM, Andrew Corrigan
notifications@github.comwrote:

Thank you for looking into this.

So are there any circumstances under which it is safe to assume that
the
data pointed to by var will not be modified by ADIOS? I'm not
familiar
with
what adios_var_struct->data is and how it relates to the data I am
passing
in to adios_write, but I don't believe I have any variable
transformations
(I'm just dumping raw data), and I am only concerned with
adios_write,
not
adios_read. If it is safe under those circumstances, then it saves
the
expense of my code allocating and copying into a temporary buffer.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42849679>
.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42850390>
.


Reply to this email directly or view it on GitHub<
https://github.com/ornladios/ADIOS/issues/9#issuecomment-42857236>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-42858503
.

@pnorbert
Copy link
Contributor

This has been fixed in 1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants