Comments (9)
Hi Guido,
I'm always torn on this; personally I like to have the .cc source physically beside the corresponding .h headers. This is what Chroma does, for example and it is one of two obvious conventions.
Whether we call "lib" lib or rename it simple "src" is something have worried about a bit.
My view is partly because, as with say boost, in a template library you end up with most of the library
in headers in the end, with the idea that there can be separation of implementation and interface into src and include trees is perhaps broken?
i.e. templates force header availability of implementation and not just interface so that they
can be compile time instantiated.
from grid.
Having separate source/include files makes some sense if your aim is to export a clean interface for others to use, as it's then easier for users to examine the interface without wading in amongst a bunch of source files.
However, I absolutely understand the desire to put sources and headers together, as for one thing it makes code navigation easier if you're the one maintaining the package. I also understand what Peter's saying, in that much of the code is templated so source files almost become irrelevant.
Actually, on that point, what is sometimes done is to put the implementation into a separate file, sometimes suffixed with .inl, then this is included at the bottom of the header. This way the header isn't cluttered with the implementation, but still "contains" it, so the compiler can instantiate it. I think boost libraries often have something like a "detail" directory where they bung this sort of thing.
from grid.
The big issue for me is that it is easier to maintain with the .c and .h together. I get driven crazy
by switching directories in other packages, (like UKhadron which I wrote!) where the opposite
decision was made because it places things that are logically close very far apart.
Yes, both standard library does this quite often with _impl classes and
boost does the detail thing. To an extent I think this is window dressing; the code still is included
and the slow compile times still arise, so it's very much bending over backwards for users
of the libraries that don't like reading code.
My own view is that this is misguided in scientific code; we are all scientists and are supposed
to know how the code works, verify that it works, and sign papers staking our reputation that
it works. Hiding the code is simply encouraging abdication of that scientific responsibility. MORE people
should read the code, not less. Reading the code should be a pleasure; both more accurate and
more pleasant than reading documentation because the code is so well written.
Regarding .cc vs. .h; Of course, you can also "make install" and read the interface presented
in the install directory, which fundamentally is similar to reading under /usr/include/.
We don't actually know how the C++ standard library is laid out when it is built, only what it
looks like post install.
from grid.
Absolutely. If the source/header are together it is much less painful from a development POV. I've adopted this layout in some of my own code for this very reason. And you're right, if the user runs make install
then all the source files get left behind anyway.
Obviously there's no hard and fast rule, just whatever works best.
from grid.
Our policy with IroIro is what I was suggesting.
We have the main headers, in an include directory. The define the basic classes or include other headers.
The headers with an associated .cpp file are all in the same directory as the source .cpp.
See here
http://suchix.kek.jp/guido_cossu/documents/DoxyGen/html/files.html
This is more or less what mspraggs was suggesting.
This is in the spirit of releasing the code as a standalone library with a clear top level organization that the final user can start looking at when reading the code.
So my original suggestion is not to move all .h but only the ones in /lib/ that are more general and clearly not associated to .cc files.
But it is a matter of taste, I know.
from grid.
also another (very) minor thing would be to use the hpp naming convention for the headers so the editing tools will automatically recognize them as c++ files.
from grid.
I'm thinking about renaming the "lib" tree to be "Grid" and living with the annoying proliferation (*)
of "Grid" subdirectory nestings, so that the includes are all under a "Grid" directory both
before and after install.
(*)
mkdir Grid
cd Grid
git clone http://www.github.com/paboyle/Grid.git
cd ..
ls Grid/Grid/Grid/Init.cc
from grid.
not a big fan of this solution, still the major include files (the ones that are in the root of lib/ now) should be in an Grid/include and not in Grid/lib.
There are only 3 .cc files related to these includes and all can be located in a lib/tools or lib/main (or better names). Not a nightmare for a developer to spot.
from grid.
I sym linked lib to include/Grid
All install to a subdir of include under Grid/Grid.h
Grid/Stencil.h etc...
following the directory structure under lib/
from grid.
Related Issues (20)
- HMC on A100 spends large amounts of time in memory copy HOT 3
- MPI2 romio321 library fails when reading >= 2GB per rank HOT 2
- Cannot compile the gparity and adjoint versions of the CompactWilsonCloverAction
- Compilation errors and warnings build targeting Nvidia GPUs HOT 2
- GPU Benchmark_ITT segfaults with MPI and ranks > 1 HOT 9
- Create a version of Benchmark_ITT including Clover instead of Wilson
- Grid fails to build for Nc != 3
- hipcc on Crusher: function bcopy undefined (compiler does not have openmp enabled?) HOT 1
- Certain operations involving SitePropagator::scalar_object won't compile with CUDA for Nc > 3
- make install doesn't install all headers due to duplicate Config.h and Version.h HOT 3
- Using ILDG checkpointer causes a crash during write HOT 2
- Develop is broken HOT 1
- ARM NEON is broken HOT 2
- Feature request: provenance tracking
- Add hint to shm error message
- Cuda error invalid device ordinal
- Recent commit causing Grid build to fail
- The configure options --enable-setdevice and --diable-setdevice have no effect
- Grid does not compile on Arm with CUDA HOT 9
- invalid configuration argument when running with 1 GPU
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grid.