"R-package/tests/vscode:/vscode.git/clone" did not exist on "6de9bafaeb4de46b22c81e7199bb5de8b28e6174"
cuda_kernel_launcher.cu 7.51 KB
Newer Older
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
/*!
 * Copyright (c) 2020 IBM Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for license information.
 */
#ifdef USE_CUDA

#include "cuda_kernel_launcher.h"

#include <LightGBM/utils/log.h>

#include <cuda_runtime.h>

#include <cstdio>

namespace LightGBM {

void cuda_histogram(
                int             histogram_size,
                data_size_t     leaf_num_data,
                data_size_t     num_data,
                bool            use_all_features,
                bool            is_constant_hessian,
                int             num_workgroups,
                cudaStream_t    stream,
                uint8_t*        arg0,
                uint8_t*        arg1,
                data_size_t     arg2,
                data_size_t*    arg3,
                data_size_t     arg4,
                score_t*        arg5,
                score_t*        arg6,
                score_t         arg6_const,
                char*           arg7,
                volatile int*   arg8,
                void*           arg9,
                size_t          exp_workgroups_per_feature) {
  if (histogram_size == 16) {
    if (leaf_num_data == num_data) {
      if (use_all_features) {
        if (!is_constant_hessian)
41
          histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
42
43
44
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
45
           histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
46
47
48
49
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
50
           histogram16_fulldata<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
51
52
53
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
54
           histogram16_fulldata<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
55
56
57
58
59
60
61
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    } else {
      if (use_all_features) {
        // seems all features is always enabled, so this should be the same as fulldata
        if (!is_constant_hessian)
62
          histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
63
64
65
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
66
          histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
67
68
69
70
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
71
          histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
72
73
74
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
75
          histogram16<<<num_workgroups, 16, 0, stream>>>(arg0, arg1, arg2,
76
77
78
79
80
81
82
83
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    }
  } else if (histogram_size == 64) {
    if (leaf_num_data == num_data) {
      if (use_all_features) {
        if (!is_constant_hessian)
84
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
85
86
87
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
88
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
89
90
91
92
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
93
          histogram64_fulldata<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
94
95
96
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
97
          histogram64_fulldata<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
98
99
100
101
102
103
104
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    } else {
      if (use_all_features) {
        // seems all features is always enabled, so this should be the same as fulldata
        if (!is_constant_hessian)
105
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
106
107
108
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
109
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
110
111
112
113
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
114
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
115
116
117
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
118
          histogram64<<<num_workgroups, 64, 0, stream>>>(arg0, arg1, arg2,
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    }
  } else {
    if (leaf_num_data == num_data) {
      if (use_all_features) {
        if (!is_constant_hessian)
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
          histogram256_fulldata<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
          histogram256_fulldata<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    } else {
      if (use_all_features) {
        // seems all features is always enabled, so this should be the same as fulldata
        if (!is_constant_hessian)
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      } else {
        if (!is_constant_hessian)
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
        else
          histogram256<<<num_workgroups, 256, 0, stream>>>(arg0, arg1, arg2,
                  arg3, arg4, arg5,
                  arg6_const, arg7, arg8, static_cast<acc_type*>(arg9), exp_workgroups_per_feature);
      }
    }
  }
}

}  // namespace LightGBM

#endif  // USE_CUDA