Question

I am writing an MPI program in which rank 0 reads parameters from a file and broadcasts the parameters on all the other ranks using MPI_BCAST.

I am trying to validate if the long long integers obtained are non zero or not in C, While I can validate if the variables are non zero, but for I cannot validate the converse. (I have initialized the variables to zero). I have verified that the broadcast does work correctly but yet I am unable to validate

if ((min_length==0LL) || (max_length==0LL) || (stride_length==0LL) || (nflops == 0LL))

Whereas I can validate its converse i.e.

if ((min_length!=0LL) || (max_length!=0LL) || (stride_length!=0LL) || (nflops != 0LL))

Just to clear out the stuff, none of the values are zero, if any value obtained is zero, my program needs to terminate.

Thank you in advance.

Était-ce utile?

La solution

Use de Morgan is you want to inverse/negate your condition

if (min_length!=0LL && max_length!=0LL && stride_length!=0LL && nflops != 0LL) {
}

http://en.wikipedia.org/wiki/De_Morgan%27s_laws

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top