usqcd-software / qdpxx

The QDP++ Framework for Lattice QCD
http://usqcd-software.github.io/qdpxx/
Other
17 stars 18 forks source link

QDPIO::cout does not support io manipulation #25

Closed martin-ueding closed 7 years ago

martin-ueding commented 7 years ago

The QDPIO::cout looks like a wrapper of std::cout that will check for MPI rank 0 and OpenMP thread 0. However, there are missing overloads for the stuff defined in <iomanip>:

/home/mu/Projekte/qphix/tests/compare_qdp_spinors.h:45:42: Fehler: no match for »operator<<« (operand types are »QDP::StandardOutputStream« and »std::_Setw«)
                 QDPIO::cout << "(x,y,z,t)=(" << x << "," << y << "," << z << "," << t
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             << ") site=" << std::setw(5) ind << " spin=" << s
                             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~

It is not possible to use std::setw, which I'd like to use to nicely format the output.

bjoo commented 7 years ago

Hi Martin, This is because the QDPIO::cout is not really a proper stream as such I don’t think. This was a nuisance for me too, sometimes. However for QPhiX tests you ought to be able to use QPhiX::masterPrintf() or QPhiX::localPrintf() which will let you do formatted output… It’s in include/qphix/print_utils.h

Best, B

On May 12, 2017, at 2:36 PM, Martin Ueding notifications@github.com wrote:

The QDPIO::cout looks like a wrapper of std::cout that will check for MPI rank 0 and OpenMP thread 0. However, there are missing overloads for the stuff defined in :

/home/mu/Projekte/qphix/tests/compare_qdp_spinors.h:45:42: Fehler: no match for »operator<<« (operand types are »QDP::StandardOutputStream« and »std::_Setw«) QDPIO::cout << "(x,y,z,t)=(" << x << "," << y << "," << z << "," << t


                             << ") site=" << std::setw(5) ind << " spin=" << s
                             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~

It is not possible to use std::setw, which I'd like to use to nicely format the output.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Dr Balint Joo High Performance Computational Scientist Jefferson Lab 12000 Jefferson Ave, Suite 3, MS 12B2, Room F217, Newport News, VA 23606, USA Tel: +1-757-269-5339, Fax: +1-757-269-5427 email: bjoo@jlab.org

martin-ueding commented 7 years ago

So QDPIO::cout does not fulfil the Liskov Substitution Principle? Perhaps we can fix that at some point.

I really don't like printf for its lack of type safety, but I guess I will just use that for now. Complicated number formatting seems a tad easier with that, or my brain is just more used to this style.

grokqcd commented 7 years ago

QDPIO::count should be substitutable. Apparently things are missing. It hadn't been really necessary before, but apparently I had not encountered the needs. I do recall that stdio opens up lots of secondary dependencies. One has to decide what is the purpose. Just printing some things is nice. We had wanted to focus more on logging facilities, etc

Robert

On May 12, 2017, at 3:34 PM, Martin Ueding notifications@github.com wrote:

So QDPIO::cout does not fulfil the Liskov Substitution Principle? Perhaps we can fix that at some point.

I really don't like printf for its lack of type safety, but I guess I will just use that for now. Complicated number formatting seems a tad easier with that, or my brain is just more used to this style.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.