[petsc-users] PetscLogFlop for a sqrt()
Justin Chang
jychang48 at gmail.com
Tue Apr 21 10:54:34 CDT 2015
Matt,
Thank you for the clarification. Couple more questions:
1) Is there a difference between calling:
y = <some value>;
and
y = 0;
y+=<some value>;
that is, for the latter case it would require PetscLogFlop(1) and the
former would not?
2) Looking through the source code of some of these PETSc functions, it
seems the calculation of an index location for an array is not counted with
PetscLogFlop(). For instance when I see:
for (d = 0; d < dim; d++) {
for (f = 0; f < dim; f++) {
J[d*dim+f] = 0.0;
for (g = 0; g < dim; g++) {
J[d*dim+f] += R[d*dim+g]*J0[g*dim+f];
}
}
}
PetscLogFlops(18.0);
where R is a diagonal matrix and dim =3, the flops to document d*dim+f
within J[...] is not accounted for within the 18 count (I think).
If I had done something like
pos = d*dim+f;
J[pos] = ...
wouldn't that be an extra 2 flops per loop iteration (excluding the zero
off-diagonal parts)?
Thanks,
Justin
On Tue, Apr 21, 2015 at 5:33 AM, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, Apr 21, 2015 at 12:59 AM, Justin Chang <jchang27 at uh.edu> wrote:
>
>> Hi everyone,
>>
>> I want to manually count the number of flops that take place within my
>> user-defined functions. Say I have to calculate the following:
>>
>> y = sqrt(pow(x[0],2)+pow(x[1],2)+pow(x[2],2));
>>
>> What should the flop counter be for each call?
>>
>
> 1) I would use PetscSqr() instead of pow(*, 2) and PetscSqrtReal/Scalar()
>
> 2) Sqrt is obviously more expensive than a multiply, but there is no good
> standard, so we just count it as 1 flop
>
> Thanks,
>
> Matt
>
>
>> Thanks,
>>
>>
>> --
>> Justin Chang
>> PhD Candidate, Civil Engineering - Computational Sciences
>> University of Houston, Department of Civil and Environmental Engineering
>> Houston, TX 77004
>> (512) 963-3262
>>
>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150421/d8c29bb1/attachment.html>
More information about the petsc-users
mailing list