Skip to content

Commit 6c3b5f8

Browse files
[NFC] Fix Werror on clang23
Also replace NULL with nullptr in a bunch of places. Co-authored-by: Greg Bonik <gbonik@nvidia.com> Signed-off-by: Asher Mancinelli <amancinelli@nvidia.com>
1 parent 2783ab8 commit 6c3b5f8

2 files changed

Lines changed: 12 additions & 39 deletions

File tree

cext/cuda_helper.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Status check_driver_version(const DriverApi* driver, int minimum_version) {
3434
PyObject* get_max_grid_size(PyObject *self, PyObject *args) {
3535
int device_id;
3636
if (!PyArg_ParseTuple(args, "i", &device_id))
37-
return NULL;
37+
return nullptr;
3838

3939
Result<const DriverApi*> driver = get_driver_api();
40-
if (!driver.is_ok()) return NULL;
40+
if (!driver.is_ok()) return nullptr;
4141

4242
CUdevice dev;
4343
CUresult res = (*driver)->cuDeviceGet(&dev, device_id);
@@ -62,7 +62,7 @@ PyObject* get_compute_capability(PyObject *self, PyObject *Py_UNUSED(ignored)) {
6262
CUdevice dev;
6363

6464
Result<const DriverApi*> driver_result = get_driver_api();
65-
if (!driver_result.is_ok()) return NULL;
65+
if (!driver_result.is_ok()) return nullptr;
6666
const DriverApi* d = *driver_result;
6767

6868
CUresult res = d->cuDeviceGet(&dev, 0);
@@ -84,7 +84,7 @@ PyObject* get_driver_version(PyObject *self, PyObject *Py_UNUSED(ignored)) {
8484
int major, minor;
8585

8686
Result<const DriverApi*> driver_result = get_driver_api();
87-
if (!driver_result.is_ok()) return NULL;
87+
if (!driver_result.is_ok()) return nullptr;
8888
const DriverApi* d = *driver_result;
8989

9090
CUresult res = d->cuDriverGetVersion(&major);
@@ -100,7 +100,7 @@ PyObject* get_driver_version(PyObject *self, PyObject *Py_UNUSED(ignored)) {
100100

101101
PyObject* synchronize_context(PyObject* self, PyObject* Py_UNUSED(ignored)) {
102102
Result<const DriverApi*> driver_result = get_driver_api();
103-
if (!driver_result.is_ok()) return NULL;
103+
if (!driver_result.is_ok()) return nullptr;
104104
const DriverApi* d = *driver_result;
105105

106106
CUresult res = d->cuCtxSynchronize();
@@ -115,7 +115,7 @@ PyObject* synchronize_context(PyObject* self, PyObject* Py_UNUSED(ignored)) {
115115

116116
PyObject* create_stream(PyObject* self, PyObject* Py_UNUSED(ignored)) {
117117
Result<const DriverApi*> driver_result = get_driver_api();
118-
if (!driver_result.is_ok()) return NULL;
118+
if (!driver_result.is_ok()) return nullptr;
119119
const DriverApi* d = *driver_result;
120120

121121
CUstream stream;
@@ -129,10 +129,10 @@ PyObject* create_stream(PyObject* self, PyObject* Py_UNUSED(ignored)) {
129129

130130
PyObject* destroy_stream(PyObject* self, PyObject* arg) {
131131
CUstream stream = static_cast<CUstream>(PyLong_AsVoidPtr(arg));
132-
if (PyErr_Occurred()) return NULL;
132+
if (PyErr_Occurred()) return nullptr;
133133

134134
Result<const DriverApi*> driver_result = get_driver_api();
135-
if (!driver_result.is_ok()) return NULL;
135+
if (!driver_result.is_ok()) return nullptr;
136136
const DriverApi* d = *driver_result;
137137

138138
CUresult res = d->cuStreamDestroy(stream);
@@ -217,7 +217,7 @@ static PyMethodDef functions[] = {
217217
"Destroy a CUDA stream given its int handle."},
218218
{"_spy_on_cuLaunchKernel_begin", spy_on_cuLaunchKernel_begin, METH_O, nullptr},
219219
{"_spy_on_cuLaunchKernel_end", spy_on_cuLaunchKernel_end, METH_NOARGS, nullptr},
220-
NULL
220+
{}
221221
};
222222

223223
Status cuda_helper_init(PyObject* m) {

cext/tile_kernel.cpp

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,6 @@ static Result<CudaKernel> load_cuda_kernel(const DriverApi* driver,
273273
}
274274

275275

276-
static inline void hash_combine(size_t& h, size_t other) {
277-
h ^= other + 0x9e3779b9 + (h << 6) + (h >> 2);
278-
}
279-
280-
template <typename T>
281-
struct HashVector {
282-
size_t operator() (const Vec<T>& v) const {
283-
size_t ret = 0;
284-
const std::hash<T> elem_hash;
285-
for (const T& x : v)
286-
hash_combine(ret, elem_hash(x));
287-
return ret;
288-
}
289-
};
290-
291276
// X(Name, #Attrs, MinStack, StackEffect)
292277
#define FOREACH_SIZE_OPCODE(X) \
293278
X(Const, 1, 0, 1) \
@@ -1867,18 +1852,6 @@ static Result<TileKernel> compile(const DriverApi* driver,
18671852
std::move(hoisted_tensor_maps)};
18681853
}
18691854

1870-
static inline bool has_torch_tensor_input(const Vec<PyTypeObject*>& pyarg_types) {
1871-
return std::any_of(pyarg_types.begin(), pyarg_types.end(), [](PyTypeObject* pytype) {
1872-
return PyType_IsSubtype(pytype, g_torch_Tensor_type);
1873-
});
1874-
}
1875-
1876-
static inline bool has_cupy_array_input(const Vec<PyTypeObject*>& pyarg_types) {
1877-
return std::any_of(pyarg_types.begin(), pyarg_types.end(), [](PyTypeObject* pytype) {
1878-
return PyType_IsSubtype(pytype, g_cupy_ndarray_type);
1879-
});
1880-
}
1881-
18821855
static Result<CUstream> parse_stream(PyObject* py_stream) {
18831856
PyPtr py_raw_stream;
18841857
if (g_torch_cuda_Stream_type && PyObject_TypeCheck(py_stream, g_torch_cuda_Stream_type)) {
@@ -2433,7 +2406,7 @@ static int TileContext_set_autotune_cache(PyObject* self, PyObject* value, void*
24332406
TileContext& context = py_unwrap<TileContext>(self);
24342407

24352408
// `del ctx.autotune_cache` → set back to None
2436-
if (value == NULL) {
2409+
if (value == nullptr) {
24372410
context.autotune_cache = newref(Py_None);
24382411
return 0;
24392412
}
@@ -2447,7 +2420,7 @@ static PyGetSetDef TileContext_getsetters[] = {
24472420
(getter)TileContext_get_autotune_cache,
24482421
(setter)TileContext_set_autotune_cache,
24492422
nullptr},
2450-
{nullptr} /* Sentinel */
2423+
{} /* Sentinel */
24512424
};
24522425

24532426

@@ -2786,7 +2759,7 @@ static PyMethodDef functions[] = {
27862759
"Benchmark a cuTile kernel using CUDA graphs.\n\n"
27872760
"Returns total elapsed time in microseconds (L2 flush between invocations).\n"
27882761
},
2789-
nullptr
2762+
{}
27902763
};
27912764

27922765
// Add the launch_extended() function separately because we want its name

0 commit comments

Comments
 (0)