JeffersonLab / qphix

QCD for Intel Xeon Phi and Xeon processors
http://jeffersonlab.github.io/qphix/
Other
13 stars 11 forks source link

“using namespace” within headers #39

Closed martin-ueding closed 7 years ago

martin-ueding commented 7 years ago

In a lot of headers, there is a using namespace directive. In the QDP packers for instance, there is the following:

using namespace QDP;

namespace QPhiX { 

It is nice for the user of QPhiX to have all the QPhiX names in a namespace. But at the same time the user gets all of QDP dumped into the main namespace.

The QDP packers are only used in the internal tests, so it is not really that bad. The only namespace which is pulled in within geometry.h is std.

When I started reading the code, it would have helped me to have QPhiX:: and QDP::, such that I could see where those functions and types come from. Now I have some idea where the various parts come from.

Would we want to invest the time to remove those using namespace directives within the headers?

include/qphix/Barrier_mic.h:using namespace std;
include/qphix/Barrier_stubs.h:using namespace std;
include/qphix/clover_dslash_body.h:using namespace std;
include/qphix/clover_dslash_body.h:using namespace std;
include/qphix/dslash_utils.h:using namespace std;
include/qphix/geometry.h:using namespace std;
include/qphix/print_utils.h:using namespace std;
include/qphix/qdp_packer.h:using namespace QDP;
include/qphix/qdp_packer_parscalar.h:using namespace QDP;
include/qphix/qdp_packer_qdpjit.h:using namespace QDP;
bjoo commented 7 years ago

Yes, we should not have this in headers other than the ones using QDP++ and / or QDP_JIT And we can get rid of using and use explicit QDP:: to get rid of namespace pollution in .h-s

On Apr 30, 2017, at 5:20 AM, Martin Ueding notifications@github.com wrote:

In a lot of headers, there is a using namespace directive. In the QDP packers for instance, there is the following:

using namespace QDP;

namespace QPhiX { It is nice for the user of QPhiX to have all the QPhiX names in a namespace. But at the same time the user gets all of QDP dumped into the main namespace.

The QDP packers are only used in the internal tests, so it is not really that bad. The only namespace which is pulled in within geometry.h is std.

When I started reading the code, it would have helped me to have QPhiX:: and QDP::, such that I could see where those functions and types come from. Now I have some idea where the various parts come from.

Would we want to invest the time to remove those using namespace directives within the headers?

include/qphix/Barrier_mic.h:using namespace std; include/qphix/Barrier_stubs.h:using namespace std; include/qphix/clover_dslash_body.h:using namespace std; include/qphix/clover_dslash_body.h:using namespace std; include/qphix/dslash_utils.h:using namespace std; include/qphix/geometry.h:using namespace std; include/qphix/print_utils.h:using namespace std; include/qphix/qdp_packer.h:using namespace QDP; include/qphix/qdp_packer_parscalar.h:using namespace QDP; include/qphix/qdp_packer_qdpjit.h:using namespace QDP;

— 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

I have removed the using namespace std in the headers in include. There are some using namespace QDP left in include/qphix/qdp_packer.h, include/qphix/qdp_packer_parscalar.h, and include/qphix/qdp_packer_qdpjit.h. Ideally they should also go, but I fear to break the QDP-JIT build for which we don't have automated building yet.