Hello,
First of all, thank you for your interest about my (dumb) problem. In my
optimization problem, the cost function J(v) is defined for a large
vector v and the actual value of J(v) is computed after solving a state
equation where these sparse matrices are used. The elements of these
matrices are computed with values of the vector v, and thus change at
each evaluation of J(v) for a different v (but the sparsity pattern does
not change). So *each* element of all matrices have to be updated at
each iteration. Moreover, there is no "litteral expression" of matrices
that could allow to write them as functions of parameter vector v
because the structure of these matrices, which are right hand-sides,
jacobians, ..., are logically "assembled" by traveling on edges of a graph.
The compiled code runs fast enough for me, the problem is the
compilation time...
S.
Le 06/05/2015 16:47, Stefan Karpinski a écrit :
Yes, this seems like a severe abuse of the compiler. It makes much
more sense for this to be input as data rather than code.
On Wed, May 6, 2015 at 8:42 AM, Steven G. Johnson
<[email protected] <mailto:[email protected]>> wrote:
It doesn't make sense to me to use code generation to spit out a
literal expression for inputting a large sparse matrix on each
iteration of optimization. In no conceivable compiler will this be
faster than just using a loop to generate the sparse matrix data
structure, rather than using a loop to generate the code to
generate the sparse matrix and then compiling the generated code.
It should be O(n) work in either case, but the constant factor
will inevitably be worse for a compiler.