Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodingGuideLines: Add Link to Wiki #140

Merged

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Jan 21, 2014

@f-schmitt-zih @Heikman @ahelm @psychocoderHPC @PrometheusPi Please add your comments about the current draft in this pull request!

@f-schmitt
Copy link
Member

  • typo: "Indentation"
  • I would prefer the following (space for comparisons):
    foo( param1, param2 )
    if ( param1, param2 )
  • Template Arguments shall have descriptive names (i.e. not T or T_)

@ax3l
Copy link
Member Author

ax3l commented Jan 21, 2014

thanks!
what we mean by Template Arguments: they should be descriptive, but only start with T_. They can/should most of the time be typedef'ed anyway (e.g. in classes) before they get used, so a ValueType or Option can change and the rest of the "implementation" only depends on that typdef at the beginning of the class.

@ax3l
Copy link
Member Author

ax3l commented Jan 21, 2014

After a short talk: I personally prefer sticking the (...) without a space to the caller, since a space after if, for, foo( ... ) looks quite c-style (CastMe) otherGuy and one can see the guarded call arguments quite easy for long calls.
However we decide, I would handle method/function calls the same as if/for's since they are basically also a lambda like functor.

@psychocoderHPC
Copy link
Member

Should we use one more line to define functions, because the return type of a function can be very complex e.g.

template<class T_A>  /* templates */
HDINLINE         /* compiler hints */
typename boost::result_of< typename OtherClass<T_A>::type >::type /*result type of function*/
functionName( ... )  /* name params */
{
  /* ... */
}

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

We should also add a point about the conventions ValueType, resultOf/type (only cause of boost...) and others in template meta programming.

@psychocoderHPC
Copy link
Member

To the Point with 2 or 4 spaces: I think we should switch to 2 spaces because of the strong template usage we had very long lines.

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

... and due to a whole bunch of namespaces and sub-classes and stuff.
btw: if we go for two spaces, we could indent namespaces again :)

@psychocoderHPC
Copy link
Member

We should add the rule that we not indent inside of namespaces

namespace Bob
{
struct Foo;
}
//wrong style
namespace Alice
{
    Struct FooWrong;
}

@f-schmitt
Copy link
Member

I propose to use uncrustify as a pre-commit hook to ensure coding guidelines.

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

Good idea, I though about vera++ so far, too.
@f-schmitt-zih Does uncrustify support transformations and user-defined rules?

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

@psychocoderHPC namespaces:

I would prefer intenting namespaces (if standard spacing is 2 spaces).

Anyway, if not I would prefer to start intending with the first non-namespace object like this:

namespace Bob
{
/* no spaces */
namespace Alice
{
  /* this guy gets intended */
  Struct FooMe;
} // namespace Alice
} // namespace Bob

@f-schmitt
Copy link
Member

+1 for @ax3l s comment

let's just indent (yes, it is written like this) just non-namespaces

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

k, so no spaces for opening a new namespace. but every level inside them. added to wiki.

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

Maybe the only exception for this rule?

namespace Bob   /* "general" outer namespace */
{
namespace Alice /* "general" outer namespace */
{
  /* this guy gets intended */
  Struct FooMe;

  /* some brainy likes to create a long mixed file
   * -> indent to avoid mixing it with the general outer namespaces */
  namespace SI
  {
    /* you should avoid that, ok in config files like .param ? */
  } // namespace SI

  /* this guy gets intended */
  Struct FooMeAgain;

} // namespace Alice
} // namespace Bob

But we could also skip that and stay as it is defined in the first place. Just looks a bit crude.

@PrometheusPi
Copy link
Member

looks good to me 👍
Why must we not comment as written below (except that this is an inline comment)?

int var = 12.0; // the meaning of life

@psychocoderHPC
Copy link
Member

for precompiler commands we should also use a nice style like this:

#if(VARIABLE_BOB==1)
#  if(VARIABLE_ALICE==1)
#    define HPC +1
#  endif
#endif

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

👍 boost does the same, I like that, too.

Related to #143 : we should check if the file contains a recent copyright notice (if possible) and on a directory-basis if the right license header was added.

@ax3l
Copy link
Member Author

ax3l commented Jan 22, 2014

@PrometheusPi

Why must we not comment as written below (except that this is an inline comment)?
int var = 12.0; // the meaning of life

Because that causes hard to track nvcc compile errors in cases like this:

void function( int a, // my first parameter
               int b
                   )
{
  /* ... */
}

Nvcc comments out the follow-up line(s) int b which sometimes still produces valid code but is definitely not what one intended. (_Disclaimer: can be "old" nvcc behaviour.)
Furthermore, /_ ... */ is more explicit (in the closing section) so one should prefer that.

ax3l referenced this pull request in ComputationalRadiationPhysics/libSplash Jan 22, 2014
@ax3l
Copy link
Member Author

ax3l commented Jan 23, 2014

@ComputationalRadiationPhysics/picongpu-maintainers I really had to try that feature.
Any more comments?

@psychocoderHPC
Copy link
Member

Can we use no white spaces between compare operators? Than we have a stronger binding of compare and other operators.

      if ( test == 1 && test2 == true )
      {
        y = y + -1;
      }

vs no spaces

      if ( test==1 && test2==true )
      {
        y = y + -1;
      }

@f-schmitt
Copy link
Member

behold, I let's use parantheses instead!

if ( ( test == 1 ) && ( test2 == true ) )
{ }

@psychocoderHPC
Copy link
Member

I think this is not possible with uncrustify.

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

I think using spaces is just fine.
And yes, "you"™ should add parentheses :) and @f-schmitt-zih really needs a sarcasm-annotator™.

@psychocoderHPC
Copy link
Member

Do we need a limitation of 80 character per line? At the moment we wrap all long lines in #161. Is someone developing our code on such a small console? We use often very long names for classes and have a lot of typedefs and templates this effects line breaks and unreadable code on many parts of the code.
I vote to set the 80 character limit to 120 or 140.

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

80 characters would be nice, since we actually do 3-way-merges.
Example see:
http://blogs.webworks.com/lauren/files/2010/10/3_way_comparison_xsl.png

But I would just ignore that for now (no warning). We might add a hard limit to 160 characters or so?
Lets go for 120 or 140 max.

@psychocoderHPC
Copy link
Member

I have tested 100 and 120, both looks good for me, more than 120 is to much.

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

ok, so let us try maybe 100 for now?

@psychocoderHPC
Copy link
Member

👍 for 100 character per line.

@PrometheusPi
Copy link
Member

👍 100 characters

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

Reordered the wiki page: grouped the rules in 5 useful sections for better orientation.

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

@ComputationalRadiationPhysics/picongpu-maintainers Any more comments? Else I would just say we can merge that for now and discuss minor updates in uncrustify related pull-requests?

@ghost ghost assigned f-schmitt Jan 27, 2014
@bussmann
Copy link
Member

Also zu MEINER Zeit haben wir nur 40 Zeichen gebraucht.

Am 27.01.2014 um 17:31 schrieb Richard Pausch [email protected]:

:+1 100 characters


Reply to this email directly or view it on GitHub.

@ax3l
Copy link
Member Author

ax3l commented Jan 27, 2014

Your braille display did not support more output anyway :shipit:

label if (logical something) then
         some statements
         goto label
      endif 

Edit: just realized that comment is in arbitrary levels inappropriate.
Edit2: believe it or not, it is suprisingly true - Braille displays wrap at character 40

@psychocoderHPC
Copy link
Member

A IBM punch card has 80 columns http://en.m.wikipedia.org/wiki/Punched_card

@f-schmitt
Copy link
Member

100 cols is fine, more is not. otherwise a kdiff3 merge is scrolling hell!

@f-schmitt
Copy link
Member

I am not sure if certain agencies can properly parse this and use our comments against us if not written in ASCII English
^annotated using sarcAnot, v1.0

@ax3l
Copy link
Member Author

ax3l commented Jan 28, 2014

👍 for sarcAnot, v1.0.

Btt:

@ComputationalRadiationPhysics/picongpu-maintainers Any more comments? Else I would just say we can merge that for now and discuss minor updates in uncrustify related pull-requests?

@f-schmitt
Copy link
Member

I'm fine with the current state, no remarks so far.

f-schmitt pushed a commit that referenced this pull request Jan 29, 2014
CodingGuideLines: Add Link to Wiki
@f-schmitt f-schmitt merged commit 58fb074 into ComputationalRadiationPhysics:dev Jan 29, 2014
@ax3l ax3l deleted the topic-codingGuideLines branch January 29, 2014 12:57
psychocoderHPC pushed a commit to psychocoderHPC/picongpu that referenced this pull request Feb 6, 2017
977b55f Merge pull request ComputationalRadiationPhysics#141 from ax3l/doc-usagelink
0f79cd5 Link Usage.md
8415cb1 Merge pull request ComputationalRadiationPhysics#140 from psychocoderHPC/topic-makeAllocatorSelfConstistent
ee6f58e update examples
8822cb0 remove `finalizeHeap()` from `creationPolicies`
ebb37f5 update `Usage.md`
66785ac selfe consistent allocator
a036d5c Merge pull request ComputationalRadiationPhysics#135 from psychocoderHPC/fix-missingPoolSizeReset
449bc7b Merge pull request ComputationalRadiationPhysics#136 from psychocoderHPC/topic-destructiveResize
b2e0d76 add `destructiveResize` method
d0ecb62 fix missing local size change in `finalizeHeap()`
9c58f4d Merge pull request ComputationalRadiationPhysics#133 from psychocoderHPC/fix-ptxSpecialRegisterUsage
4cd47f0 fix missing '%%' to use ptx special register
cee846f Merge pull request ComputationalRadiationPhysics#127 from slizzered/documentation-add-thesis
b92f67f Merge pull request ComputationalRadiationPhysics#128 from slizzered/travis-fix_Werror
53e86b4 simpler handling of CXX_FLAGS
d2c4e08 Merge pull request ComputationalRadiationPhysics#126 from slizzered/fix_115
85143c0 Updated Readme.md
5f84db9 fixed string concatenation
eb1ad2d Fix to travis file: -Werror
ad72a61 Check heap pointer in Scatter creation policy
ffa4f7e Merge pull request ComputationalRadiationPhysics#125 from ComputationalRadiationPhysics/slizzered-patch-1
368478c moar fixes
a0bd2eb Update Usage.md
69a6973 Merge pull request ComputationalRadiationPhysics#109 from Flamefire/staticConstexpr
638fa5b Use BOOST_STATIC_CONSTEXPR
c0c6450 Merge pull request ComputationalRadiationPhysics#116 from slizzered/issue113-separate_object_host_device
4070f40 some renamig and freeing at end of examples
b9fe440 added implicit conversion to device handle
7f742b8 fixed OldMalloc policy to comply with new interface
0de5416 removed unnecessary inheritance
28c52c2 fixed a return type to comply with defined interface
503f0bd changed pointer to handle
d281cbe replaced initHeap function with constructor
74ba8aa Replaced the global __device__ object
4fa2d75 Merge pull request ComputationalRadiationPhysics#121 from ax3l/fix-cincludes
d99a6f3 Fix: Includes from C headers
b52c2b2 Merge pull request ComputationalRadiationPhysics#119 from ax3l/fix-travis
eb096f7 Updating to Travis-CI Trusty Beta
93ab74b Merge pull request ComputationalRadiationPhysics#112 from slizzered/issue110-error-handling
90881fd Fixed problems leading to uninitialized pointers
8980ead Merge pull request ComputationalRadiationPhysics#108 from Flamefire/exampleC++11
a92d4e1 Rename some shadowed variables in C++11 mode

git-subtree-dir: thirdParty/mallocMC
git-subtree-split: 977b55f98fe0e6e4545f6e092660b7b4f1b54493
psychocoderHPC pushed a commit to psychocoderHPC/picongpu that referenced this pull request Jan 8, 2020
0594a68a0 Merge pull request ComputationalRadiationPhysics#140 from psychocoderHPC/topic-cuplaTargetBehavior
0991f2c6e compile cupla interfaces into static cupla library
914a87133 Merge pull request ComputationalRadiationPhysics#136 from psychocoderHPC/topic-refactorKernelExecution
0027076c7 Merge pull request ComputationalRadiationPhysics#137 from psychocoderHPC/topic-supportForAlpakaOMP4Backend
d2b118662 Merge pull request ComputationalRadiationPhysics#139 from psychocoderHPC/fix-configHeader
16c084970 support for alpaka OMP4 backend
e990d63c5 fix config header
e2048f565 refactor cupla kernel execution
d5f969a93 Merge pull request ComputationalRadiationPhysics#132 from sbastrakov/doc-clarifyIncludeOrder
cca400a60 Clarify documentation of inclusion order
4578ae151 Merge pull request ComputationalRadiationPhysics#128 from psychocoderHPC/topic-updateAlpakaToCurrent0.4.0dev
0c090e536 Merge commit 'dd8afa5cec90a1398b8da3f9cd7d30aa59664cb5' into topic-updateAlpakaToCurrent0.4.0dev
dd8afa5ce Squashed 'alpaka/' changes from 0a2b6161..d5e59590
767768a88 rename alpaka queue names
8c227fbb6 Merge pull request ComputationalRadiationPhysics#130 from psychocoderHPC/fix-configHeaderTest
a6c3da536 fix `config header` test
a439c9d6b Merge pull request ComputationalRadiationPhysics#129 from psychocoderHPC/topic-updateTravisCMakeTo3.15.4
2e0daaf1b update tavis CMake to 3.15.4
04698e9c6 Merge pull request ComputationalRadiationPhysics#123 from SimeonEhrig/ci_enable_backends
25e64b623 time command add to ci test
c559bf432 Merge pull request ComputationalRadiationPhysics#107 from SimeonEhrig/init-gitlab-ci
488a2e95f Merge pull request ComputationalRadiationPhysics#117 from tdd11235813/pr-fixes-atomics
c2916be68 Adds atomicAnd, atomicXor, atomicOr.
7c330a5a9 Merge pull request ComputationalRadiationPhysics#112 from psychocoderHPC/topic-standaloneHeader
d84f2fdea configuration header
6a97c1cf1 Merge pull request ComputationalRadiationPhysics#113 from fwyzard/dev_cuplaGetErrorName
d210a37a0 Add cuplaGetErrorName with the same functionality as cuplaGetErrorString
d050bf3cd Merge pull request ComputationalRadiationPhysics#111 from tdd11235813/doc-subtree
19cf46913 Describes how to pull subtree as generic git author.
4ecc143f4 Merge pull request ComputationalRadiationPhysics#103 from tdd11235813/dev
16c806e68 Merge pull request ComputationalRadiationPhysics#104 from tdd11235813/dev-targets
43fd52319 Add gitlab-ci.yml for GitLab CI tests
fd37e7b7d Alpaka as git subtree instead of git submodule.
16b455107 Squashed 'alpaka/' content from commit 0a2b6161
69b79bd95 Merge commit '16b4551075f93cdd71309433b02936a152dfee9f' as 'alpaka'
fa5cc5260 Removes alpaka git module.
67485d510 Some stylistic changes.
4f2b9c019 CUPLA_ADD_EXECUTABLE links cupla target. Target provides c++11.

git-subtree-dir: thirdParty/cupla
git-subtree-split: 0594a68a0d9bdbfc949391f83473d4734575a7f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation regarding documentation or wiki discussions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants