James Muller
2011-Dec-27 22:58 UTC
[Rd] Initializing a large data structure to be accessed strictly within a shared C library
Dear R-devel members, The question: Is it possible to initialize and later free a large data structure strictly within a shared C library, to be used by a function in the C library that I'll call from R--without ever having to pass data to and from R? This is analogous to C++ object initialization/use/destruction, but if possible I'd like to stay in C. The context: I'm implementing a particle swarm optimization of a 60-dimension nonlinear transform, where the transform is defined in a half-gigabyte dataset. By carefully initializing a C struct I can trim a large amount of work from the PSO iteration stage. This is, of course, straight forward if I implement the whole thing in a self-contained C program--however, I'd like R to handle the optimization routines, and my shared library to implement the value function. So: what do folks think? Cheers, James [[alternative HTML version deleted]]
James Muller
2011-Dec-27 23:11 UTC
[R] Initializing a large data structure to be accessed strictly within a shared C library
Dear R-help members, *(My apologies for cross-posting to both R-help and R-devel -- this question straddles both domains...)* The question: Is it possible to initialize and later free a large data structure strictly within a shared C library, to be used by a function in the C library that I'll call from R--without ever having to pass data to and from R? This is analogous to C++ object initialization/use/destruction, but if possible I'd like to stay in C. The context: I'm implementing a particle swarm optimization of a 60-dimension nonlinear transform, where the transform is defined in a half-gigabyte dataset. By carefully initializing a C struct I can trim a large amount of work from the PSO iteration stage. This is, of course, straight forward if I implement the whole thing in a self-contained C program--however, I'd like R to handle the optimization routines, and my shared library to implement the value function. So: what do folks think? Cheers, James [[alternative HTML version deleted]]
James Muller
2011-Dec-27 23:16 UTC
[R] Initializing a large data structure to be accessed strictly within a shared C library
Dear R-help members, *(My apologies for cross-posting to both R-help and R-devel -- this question straddles both domains...)* The question: Is it possible to initialize and later free a large data structure strictly within a shared C library, to be used by a function in the C library that I'll call from R--without ever having to pass data to and from R? This is analogous to C++ object initialization/use/destruction, but if possible I'd like to stay in C. The context: I'm implementing a particle swarm optimization of a 60-dimension nonlinear transform, where the transform is defined in a half-gigabyte dataset. By carefully initializing a C struct I can trim a large amount of work from the PSO iteration stage. This is, of course, straight forward if I implement the whole thing in a self-contained C program--however, I'd like R to handle the optimization routines, and my shared library to implement the value function. So: what do folks think? Cheers, James [[alternative HTML version deleted]]
James Muller
2011-Dec-27 23:58 UTC
[Rd] Initializing a large data structure to be accessed strictly within a shared C library
Dear R-help members, *(My apologies for cross-posting to both R-help and R-devel -- this question straddles both domains...)* The question: Is it possible to initialize and later free a large data structure strictly within a shared C library, to be used by a function in the C library that I'll call from R--without ever having to pass data to and from R? This is analogous to C++ object initialization/use/destruction, but if possible I'd like to stay in C. The context: I'm implementing a particle swarm optimization of a 60-dimension nonlinear transform, where the transform is defined in a half-gigabyte dataset. By carefully initializing a C struct I can trim a large amount of work from the PSO iteration stage. This is, of course, straight forward if I implement the whole thing in a self-contained C program--however, I'd like R to handle the optimization routines, and my shared library to implement the value function. So: what do folks think? Cheers, James
Duncan Murdoch
2011-Dec-28 01:09 UTC
[Rd] Initializing a large data structure to be accessed strictly within a shared C library
On 11-12-27 5:58 PM, James Muller wrote:> Dear R-devel members, > > The question: Is it possible to initialize and later free a large data > structure strictly within a shared C library, to be used by a function in > the C library that I'll call from R--without ever having to pass data to > and from R? This is analogous to C++ object initialization/use/destruction, > but if possible I'd like to stay in C.Yes, if you use malloc or Calloc you'll get memory that you can manage yourself. See Writing R Extensions, section 6.1.2. Duncan Murdoch> > The context: I'm implementing a particle swarm optimization of a > 60-dimension nonlinear transform, where the transform is defined in a > half-gigabyte dataset. By carefully initializing a C struct I can trim a > large amount of work from the PSO iteration stage. This is, of course, > straight forward if I implement the whole thing in a self-contained C > program--however, I'd like R to handle the optimization routines, and my > shared library to implement the value function. > > So: what do folks think? > > Cheers, > > James > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Reasonably Related Threads
- Initializing a large data structure to be accessed strictly within a shared C library
- GSOC-2016 Project : Clustering of search results
- Implementation of the "Shuffled Complex Evolution" (SCE-UA) Algorithm
- GSOC-2016 Project : Clustering of search results
- GSOC-2016 Project : Clustering of search results