File: codestyle.md

package info (click to toggle)
ucc 1.7.0~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 11,956 kB
  • sloc: ansic: 66,490; cpp: 35,364; makefile: 1,052; xml: 214; sh: 80
file content (52 lines) | stat: -rw-r--r-- 1,820 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
### Check style with clang-format

####  Usage 
clang-format --style=file ucc.h > ucc.formatted.h

### Examples where format with clang-format fails

clang-format tool formats the C source. Though the .clang-format style captures
the preferred style by the UCC project, there are some edge cases where it
fails. The examples below captures the scenarios: 


```C
Good
typedef void(*ucc_reduction_dtype_mapper_t)(void *invec, void *inoutvec,
                                           ucc_count_t *count, ucc_datatype_t dtype);
```                                            
                                            
clang-format generated

```C
typedef void (*ucc_reduction_dtype_mapper_t)(void *invec, void *inoutvec,
                                             ucc_count_t *  count,
                                             ucc_datatype_t dtype);
```
                                             
                                             
Good

```C
typedef struct ucc_context_oob_coll {
    int                  (*allgather)(void *src_buf, void *recv_buf, size_t size,
                                      void *allgather_info,  void **request);
    ucc_status_t         (*req_test)(void *request);
    ucc_status_t         (*req_free)(void *request);
    uint32_t             participants;
    void                 *coll_info;
}  ucc_context_oob_coll_t;                                   
```
                                             
clang-format generated

```C
typedef struct ucc_context_oob_coll {
    int (*allgather)(void *src_buf, void *recv_buf, size_t size,
                     void *allgather_info, void **request);
    ucc_status_t (*req_test)(void *request);
    ucc_status_t (*req_free)(void *request);
    uint32_t participants;
    void *   coll_info;
} ucc_context_oob_coll_t;
```