JeffersonLab / qphix

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

Double include guards really needed? #34

Closed martin-ueding closed 7 years ago

martin-ueding commented 7 years ago

In some of the tests, I found double include guards. In the file tests/testMInvCG.cc, there is the following:

#ifndef DSLASH_M_W_H
#include "dslashm_w.h"
#endif

The included file now defines that include guard:

#ifndef DSLASH_M_W_H
#define DSLASH_M_W_H

I do not really see the point of this structure. This pattern is kind of nice with lacking compilers like MSVC++ which cannot figure out that the file was already included without opening it again. This would increase the compile times. Compilers like GCC are actually able to interpret the #ifndef include guard and not open the file again. So this is not really needed.

Also compile time with QPhiX is already really long, it will probably make no perceivable difference to remove that double include guard. So why are those still around?

We could also just move to #pragma once. That is shorter, less error prone, and also fast on MSVC++ (if that was ever a concern). IBM XL version 12 cannot do that, but that version cannot even do C++0x, so that is of no concern.

bjoo commented 7 years ago

Hi Martin, I think i found this pattern somewhere and just used it, in one case. It is doubly redundant, I agree. We can remove it I suppose.

Best, B

On Apr 22, 2017, at 9:50 AM, Martin Ueding notifications@github.com wrote:

In some of the tests, I found double include guards. In the file tests/testMInvCG.cc, there is the following:

ifndef

DSLASH_M_W_H # include "dslashm_w.h"

# endif The included file now defines that include guard:

ifndef

DSLASH_M_W_H # define DSLASH_M_W_H I do not really see the point of this structure. This pattern is kind of nice with lacking compilers like MSVC++ which cannot figure out that the file was already included without opening it again. This would increase the compile times. Compilers like GCC are actually able to interpret the #ifndef include guard and not open the file again. So this is not really needed.

Also compile time with QPhiX is already really long, it will probably make no perceivable difference to remove that double include guard. So why are those still around?

We could also just move to #pragma once. That is shorter, less error prone, and also fast on MSVC++ (if that was ever a concern). IBM XL version 12 cannot do that, but that version cannot even do C++0x, so that is of no concern.

— 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