[Carpet] type-cast warnings
Erik Schnetter
schnetter at cct.lsu.edu
Tue Oct 17 17:05:25 CEST 2006
On Oct 17, 2006, at 09:13:54, Bela Szilagyi wrote:
> While compiling Carpet on our AEI cluster "lagavulin" I got the
> following
> warnings:
>
> /home/szilagyi/Cactus/configs/lharm/build/CarpetReduce/reduce.cc
> (459): warning
> # 810: conversion from "double" to
> "CarpetReduce::typeconv<int>::goodtype=
> {int}" m ay
> lose significant bits
> mycnt += w;
> ^
> detected during instantiation of "void
> CarpetReduce::reduce<T,OP>(cons t int *,
> const int
> *, const int *, const std::vector<const void *, std::allocat
> o r<const void *>> &, const std::vector<double,
> std::allocator<double>> &,
> void *, void *, const double *, double)
> [with
> T=CarpetReduce::typeconv<int>::goodtyp e=
> { int},
> OP=CarpetReduce::minimum::op<CarpetReduce::typeconv<int>::goodtype={in
> t}>] "
>
>
> What is worrisome is that the resulting value of (mycnt) could
> depend "w"
> being a roundoff quantity above or below a certain integer. In
> case one runs
> the application across a non-homogeneus architecture cluster, it is
> very
> likely that on certain nodes mycnt will have values different from
> other
> nodes.
>
> It is possible that code before this assignment cleans up the value
> of "w" so
> that the result is architecture independent. But I was not able to
> confirm
> this.
>
> The question is then -- should one worry about these kinds of
> warnings in
> Carpet(Regrid) ?
Béla,
in general you do not need to worry about these warnings in
CarpetReduce. CarpetReduce offers a variety of operations to users
for a variety of types. Among these are e.g. calculating the average
of a set of integers and storing the result as integer. This has,
obviously, the problem you mention. However, these operations are
only performed if someone requests them, and I hope that people won't
do that unless they know what they are doing.
You can see that this is a generic piece of code by the <T,OP> C++
template syntax; the same code implements these operations for all
types. In other, non-generic code, such warnings would be serious.
There is no good way to define e.g. integer averages of integers.
The alternative would be to forbid this operation.
-erik
--
Erik Schnetter <schnetter at cct.lsu.edu>
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from www.keyserver.net.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/developers/attachments/20061017/b5ea0f16/attachment.pgp
More information about the developers
mailing list