Skip to content

Commit 6fdba0a

Browse files
committed
Update 2 Kernels
1 parent af60dc2 commit 6fdba0a

File tree

30 files changed

+404
-173
lines changed

30 files changed

+404
-173
lines changed

.clangd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Diagnostics:
3434
]
3535

3636
CheckOptions:
37-
readability-identifier-naming.VariableCase: lowerCamelCase
38-
readability-identifier-naming.ProtectedMemberCase: lowerCamelCase
39-
readability-identifier-naming.PrivateMemberCase: lowerCamelCase
40-
readability-identifier-naming.PublicMemberCase: lowerCamelCase
37+
readability-identifier-naming.VariableCase: aNy_CasE
38+
readability-identifier-naming.ProtectedMemberCase: camelBack
39+
readability-identifier-naming.PrivateMemberCase: camelBack
40+
readability-identifier-naming.PublicMemberCase: camelBack
4141
readability-identifier-naming.NamespaceCase: lower_case
42-
readability-identifier-naming.EnumCase: lowerCamelCase
42+
readability-identifier-naming.EnumCase: camelBack
4343
readability-identifier-naming.ClassCase: CamelCase
4444
readability-identifier-naming.StructCase: CamelCase
45-
readability-identifier-naming.FunctionCase: lowerCamelCase
46-
readability-identifier-naming.ClassMethodCase: lowerCamelCase
45+
readability-identifier-naming.FunctionCase: camelBack
46+
readability-identifier-naming.ClassMethodCase: camelBack

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"llvm-vs-code-extensions.vscode-clangd", // clangd
44
"twxs.cmake", // cmake
5+
"josetr.cmake-language-support-vscode",
56
"ms-vscode.cpptools", // C/C++
67
"ms-python.python", // Python
78
"ms-python.black-formatter", // Python formatter

.vscode/launch.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch: [Debug|GDB]",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/build/test/pmpp_test",
9+
"args": [],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}",
12+
"externalConsole": false,
13+
"MIMode": "gdb",
14+
"setupCommands": [
15+
{
16+
"description": "Enable pretty-printing for gdb",
17+
"text": "-enable-pretty-printing",
18+
"ignoreFailures": true
19+
}
20+
],
21+
"miDebuggerPath": "gdb"
22+
}
23+
]
24+
}

.vscode/settings.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
{
2-
"editor.formatOnPaste": true,
3-
"editor.formatOnType": true,
2+
"cmake.configureOnOpen": false,
3+
"cmake.showOptionsMovedNotification": false,
4+
"cmake.automaticReconfigure": false,
5+
"cmake.configureOnEdit": false,
6+
"cmake.pinnedCommands": [
7+
"workbench.action.tasks.configureTaskRunner",
8+
"workbench.action.tasks.runTask"
9+
],
10+
"cmake.showConfigureWithDebuggerNotification": false,
11+
"cmake.touchbar.visibility": "hidden",
412
"C_Cpp.errorSquiggles": "disabled",
513
"C_Cpp.intelliSenseEngineFallback": "disabled",
614
"C_Cpp.intelliSenseEngine": "disabled",
7-
"C_Cpp.default.compileCommands": "${workspaceFolder}/compile_commands.json",
15+
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
16+
"[cpp]": {
17+
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
18+
},
819
"clangd.path": "clangd",
920
"clangd.arguments": [
1021
"--compile-commands-dir=${workspaceFolder}/build",
@@ -17,7 +28,7 @@
1728
"--header-insertion=iwyu",
1829
"--header-insertion-decorators",
1930
"--background-index",
20-
"-j=6",
31+
"-j=8",
2132
"--pch-storage=memory",
2233
"--function-arg-placeholders=false",
2334
],

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ctest --test-dir ./build --output-on-failure
2525
To build and instll the corresponding python lib:
2626

2727
```bash
28-
pip3 install --no-build-isolation .
28+
pip3 install --no-build-isolation -v .
2929
```
3030

3131
`torch.ops.pmpp.vector_add` will be available after installation;

csrc/cmake/libraries/libtorch.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ set(PYTORCH_CMAKE_PREFIX_PATH "${PY_OUTPUT}")
1515
list(APPEND CMAKE_PREFIX_PATH ${PYTORCH_CMAKE_PREFIX_PATH})
1616

1717
find_package(Torch REQUIRED)
18+
19+
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -DTORCH_USE_CUDA_DSA=1")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "pmpp/system.hpp"
4+
#include "pmpp/types/cxx_types.hpp"
5+
#include "pmpp/types/torch_types.hpp"
6+
7+
namespace pmpp::ops
8+
{
9+
10+
template <DeviceType DeviceT>
11+
void launchCvtRGBtoGray(uint8_t* picOut, const uint8_t* picIn, uint32_t width,
12+
uint32_t height) = delete;
13+
14+
template <>
15+
PMPP_API void launchCvtRGBtoGray<DeviceType::CUDA>(uint8_t* picOut,
16+
const uint8_t* picIn,
17+
uint32_t width,
18+
uint32_t height);
19+
20+
template <>
21+
PMPP_API void launchCvtRGBtoGray<DeviceType::CPU>(uint8_t* picOut,
22+
const uint8_t* picIn,
23+
uint32_t width,
24+
uint32_t height);
25+
} // namespace pmpp::ops

csrc/include/pmpp/ops/vec_add.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@
22

33
#include "pmpp/system.hpp"
44
#include "pmpp/types/cxx_types.hpp"
5-
#include "pmpp/types/device.hpp"
5+
#include "pmpp/types/torch_types.hpp"
66

77
namespace pmpp::ops
88
{
99

10-
using Device = ::pmpp::Device;
11-
12-
template <typename ScalarT, Device DeviceT>
10+
template <DeviceType DeviceT, typename ScalarT>
1311
void launchVecAdd(const ScalarT* a, const ScalarT* b, ScalarT* c,
1412
size_t n) = delete;
1513

1614
template <>
17-
PMPP_API void launchVecAdd<fp32_t, Device::CPU>(const fp32_t* a,
18-
const fp32_t* b, fp32_t* c,
19-
size_t n);
15+
PMPP_API void launchVecAdd<DeviceType::CPU>(const fp32_t* a, const fp32_t* b,
16+
fp32_t* c, size_t n);
2017
template <>
21-
PMPP_API void launchVecAdd<fp32_t, Device::CUDA>(const fp32_t* a,
22-
const fp32_t* b, fp32_t* c,
23-
size_t n);
18+
PMPP_API void launchVecAdd<DeviceType::CUDA>(const fp32_t* a, const fp32_t* b,
19+
fp32_t* c, size_t n);
2420

2521
} // namespace pmpp::ops

csrc/include/pmpp/ops/vec_compare.hpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

csrc/include/pmpp/pmpp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
#include "pmpp/types/cxx_types.hpp"

0 commit comments

Comments
 (0)