Skip to content

Commit ccdd7f4

Browse files
committed
Added more instructions to generate code. Generated for cuDNN7.1 from scratch
1 parent 6549fde commit ccdd7f4

File tree

4 files changed

+161
-60
lines changed

4 files changed

+161
-60
lines changed

cmd/gencudnn/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
1. Preprocess the cudnn file: `gcc -E -P cudnn_.h > cudnn.h`
3+
2. Add the following "headers" to cheat the compiler:
4+
```
5+
typedef long int ptrdiff_t;
6+
typedef long unsigned int size_t;
7+
typedef long unsigned int rsize_t;
8+
typedef int wchar_t;
9+
typedef long double max_align_t;
10+
struct dummy;
11+
typedef struct dummy cudaStream_t;
12+
```
13+
3. Delete the following debug related stuff (only cuDNN 7.1+):
14+
```
15+
typedef struct {
16+
unsigned cudnn_version;
17+
cudnnStatus_t cudnnStatus;
18+
unsigned time_sec;
19+
unsigned time_usec;
20+
unsigned time_delta;
21+
cudnnHandle_t handle;
22+
cudaStream_t stream;
23+
unsigned long long pid;
24+
unsigned long long tid;
25+
int cudaDeviceId;
26+
int reserved[15];
27+
} cudnnDebug_t;
28+
typedef void (*cudnnCallback_t) (cudnnSeverity_t sev, void *udata, const cudnnDebug_t *dbg, const char *msg);
29+
cudnnStatus_t cudnnSetCallback(
30+
unsigned mask,
31+
void *udata,
32+
cudnnCallback_t fptr);
33+
cudnnStatus_t cudnnGetCallback(
34+
unsigned *mask,
35+
void **udata,
36+
cudnnCallback_t *fptr);
37+
```

cmd/gencudnn/main.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"log"
77
"os/exec"
8+
"sort"
89
"strings"
910

1011
"os"
@@ -63,7 +64,7 @@ func main() {
6364
// Step 2: generate mappings for this package, then edit them manually
6465
// Specifically, the `ignored` map is edited - things that will be manually written are not removed from the list
6566
// Some enum map names may also be changed
66-
// generateMappings(true)
67+
generateMappings(true)
6768

6869
// Step 3: generate enums, then edit the file in the dnn package.
6970
// generateEnums()
@@ -117,8 +118,13 @@ func reportUnconvertedFns(pkg *PkgState, file string, things ...bindgen.FilterFu
117118
}
118119

119120
}
120-
fmt.Printf("## Unconverted C Functions ##\n\n")
121+
keys := make([]string, 0, len(allFuncs))
121122
for k := range allFuncs {
123+
keys = append(keys, k)
124+
}
125+
sort.Strings(keys)
126+
fmt.Printf("## Unconverted C Functions ##\n\n")
127+
for _, k := range keys {
122128
if _, ok := used[k]; !ok {
123129
fmt.Printf("* `%v`\n", k)
124130
}
@@ -140,9 +146,13 @@ func reportUnconvertedTypes(pkg *PkgState, file string, things ...bindgen.Filter
140146
allTypes[name] = struct{}{}
141147
}
142148
}
143-
144-
fmt.Printf("## Unconverted/Unused C Types ##\n\n")
149+
keys := make([]string, 0, len(allTypes))
145150
for k := range allTypes {
151+
keys = append(keys, k)
152+
}
153+
sort.Strings(keys)
154+
fmt.Printf("## Unconverted/Unused C Types ##\n\n")
155+
for _, k := range keys {
146156
if _, ok := used[k]; !ok {
147157
fmt.Printf("* `%v`\n", k)
148158
}

0 commit comments

Comments
 (0)