Skip to content

Commit 00cf469

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 50bcf7a commit 00cf469

File tree

175 files changed

+5348
-5357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+5348
-5357
lines changed

.augment/rules/update-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ I will provide you with two folders shortly. I need you to systematically update
2020
5. **Consistency**: Ensure naming conventions and documentation style are consistent across all binding files
2121
6. **Error Handling**: Properly handle C++ exceptions and convert them to appropriate Python exceptions
2222

23-
Please work through each module systematically, and let me know when you've completed each one so I can review the changes before proceeding to the next module.
23+
Please work through each module systematically, and let me know when you've completed each one so I can review the changes before proceeding to the next module.

.claude/settings.local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
"deny": [],
3030
"ask": []
3131
}
32-
}
32+
}

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ ctest -R "algorithm_*" --output-on-failure
121121
### Building with All Features
122122
```bash
123123
./scripts/build.sh --release --python --examples --tests --docs --package
124-
```
124+
```

atom/algorithm/core/opencl_utils.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,101 +16,101 @@ auto Platform::getPlatforms() -> std::vector<cl_platform_id> {
1616
if (err != CL_SUCCESS || num_platforms == 0) {
1717
return {};
1818
}
19-
19+
2020
std::vector<cl_platform_id> platforms(num_platforms);
2121
err = clGetPlatformIDs(num_platforms, platforms.data(), nullptr);
2222
if (err != CL_SUCCESS) {
2323
return {};
2424
}
25-
25+
2626
return platforms;
2727
}
2828

2929
auto Platform::getDevices(cl_platform_id platform, DeviceType device_type) -> std::vector<cl_device_id> {
3030
cl_uint num_devices;
31-
cl_int err = clGetDeviceIDs(platform, static_cast<cl_device_type>(device_type),
31+
cl_int err = clGetDeviceIDs(platform, static_cast<cl_device_type>(device_type),
3232
0, nullptr, &num_devices);
3333
if (err != CL_SUCCESS || num_devices == 0) {
3434
return {};
3535
}
36-
36+
3737
std::vector<cl_device_id> devices(num_devices);
38-
err = clGetDeviceIDs(platform, static_cast<cl_device_type>(device_type),
38+
err = clGetDeviceIDs(platform, static_cast<cl_device_type>(device_type),
3939
num_devices, devices.data(), nullptr);
4040
if (err != CL_SUCCESS) {
4141
return {};
4242
}
43-
43+
4444
return devices;
4545
}
4646

4747
auto Platform::getDeviceInfo(cl_device_id device) -> DeviceInfo {
4848
DeviceInfo info;
49-
49+
5050
// Get device name
5151
usize name_size;
5252
clGetDeviceInfo(device, CL_DEVICE_NAME, 0, nullptr, &name_size);
5353
std::string name(name_size, '\0');
5454
clGetDeviceInfo(device, CL_DEVICE_NAME, name_size, name.data(), nullptr);
5555
info.name = name.c_str(); // Remove null terminator
56-
56+
5757
// Get vendor
5858
usize vendor_size;
5959
clGetDeviceInfo(device, CL_DEVICE_VENDOR, 0, nullptr, &vendor_size);
6060
std::string vendor(vendor_size, '\0');
6161
clGetDeviceInfo(device, CL_DEVICE_VENDOR, vendor_size, vendor.data(), nullptr);
6262
info.vendor = vendor.c_str();
63-
63+
6464
// Get version
6565
usize version_size;
6666
clGetDeviceInfo(device, CL_DEVICE_VERSION, 0, nullptr, &version_size);
6767
std::string version(version_size, '\0');
6868
clGetDeviceInfo(device, CL_DEVICE_VERSION, version_size, version.data(), nullptr);
6969
info.version = version.c_str();
70-
70+
7171
// Get device type
7272
cl_device_type type;
7373
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, nullptr);
7474
info.type = static_cast<DeviceType>(type);
75-
75+
7676
// Get compute units
7777
cl_uint compute_units;
7878
clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, nullptr);
7979
info.max_compute_units = compute_units;
80-
80+
8181
// Get max work group size
8282
usize work_group_size;
8383
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(work_group_size), &work_group_size, nullptr);
8484
info.max_work_group_size = work_group_size;
85-
85+
8686
// Get global memory size
8787
cl_ulong global_mem_size;
8888
clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(global_mem_size), &global_mem_size, nullptr);
8989
info.global_memory_size = global_mem_size;
90-
90+
9191
// Get local memory size
9292
cl_ulong local_mem_size;
9393
clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(local_mem_size), &local_mem_size, nullptr);
9494
info.local_memory_size = local_mem_size;
95-
95+
9696
// Check double precision support
9797
usize extensions_size;
9898
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 0, nullptr, &extensions_size);
9999
std::string extensions(extensions_size, '\0');
100100
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, extensions_size, extensions.data(), nullptr);
101101
info.supports_double = extensions.find("cl_khr_fp64") != std::string::npos;
102-
102+
103103
return info;
104104
}
105105

106106
auto Platform::createContext(const std::vector<cl_device_id>& devices) -> Context {
107107
cl_int err;
108-
cl_context context = clCreateContext(nullptr, static_cast<cl_uint>(devices.size()),
108+
cl_context context = clCreateContext(nullptr, static_cast<cl_uint>(devices.size()),
109109
devices.data(), nullptr, nullptr, &err);
110110
if (err != CL_SUCCESS) {
111111
THROW_RUNTIME_ERROR("Failed to create OpenCL context: error {}", err);
112112
}
113-
113+
114114
return Context(context);
115115
}
116116

@@ -120,18 +120,18 @@ auto Platform::createCommandQueue(const Context& context, cl_device_id device) -
120120
if (err != CL_SUCCESS) {
121121
THROW_RUNTIME_ERROR("Failed to create OpenCL command queue: error {}", err);
122122
}
123-
123+
124124
return CommandQueue(queue);
125125
}
126126

127127
auto Platform::createBuffer(const Context& context, MemoryFlags flags, usize size, void* host_ptr) -> Buffer {
128128
cl_int err;
129-
cl_mem buffer = clCreateBuffer(context.get(), static_cast<cl_mem_flags>(flags),
129+
cl_mem buffer = clCreateBuffer(context.get(), static_cast<cl_mem_flags>(flags),
130130
size, host_ptr, &err);
131131
if (err != CL_SUCCESS) {
132132
THROW_RUNTIME_ERROR("Failed to create OpenCL buffer: error {}", err);
133133
}
134-
134+
135135
return Buffer(buffer);
136136
}
137137

@@ -141,56 +141,56 @@ auto Platform::buildKernel(const Context& context,
141141
const std::string& kernel_name,
142142
const std::string& build_options) -> Kernel {
143143
cl_int err;
144-
144+
145145
// Create program from source
146146
const char* source_ptr = source.c_str();
147147
usize source_size = source.length();
148148
cl_program program = clCreateProgramWithSource(context.get(), 1, &source_ptr, &source_size, &err);
149149
if (err != CL_SUCCESS) {
150150
THROW_RUNTIME_ERROR("Failed to create OpenCL program: error {}", err);
151151
}
152-
152+
153153
// Build program
154-
err = clBuildProgram(program, static_cast<cl_uint>(devices.size()), devices.data(),
154+
err = clBuildProgram(program, static_cast<cl_uint>(devices.size()), devices.data(),
155155
build_options.empty() ? nullptr : build_options.c_str(), nullptr, nullptr);
156-
156+
157157
if (err != CL_SUCCESS) {
158158
// Get build log for debugging
159159
usize log_size;
160160
clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, 0, nullptr, &log_size);
161161
std::string build_log(log_size, '\0');
162162
clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, log_size, build_log.data(), nullptr);
163-
163+
164164
clReleaseProgram(program);
165165
THROW_RUNTIME_ERROR("Failed to build OpenCL program: error {}\nBuild log: {}", err, build_log);
166166
}
167-
167+
168168
// Create kernel
169169
cl_kernel kernel = clCreateKernel(program, kernel_name.c_str(), &err);
170170
clReleaseProgram(program); // Release program as kernel holds reference
171-
171+
172172
if (err != CL_SUCCESS) {
173173
THROW_RUNTIME_ERROR("Failed to create OpenCL kernel '{}': error {}", kernel_name, err);
174174
}
175-
175+
176176
return Kernel(kernel);
177177
}
178178

179179
auto ComputeManager::initialize(DeviceType preferred_type) -> bool {
180180
if (initialized_) {
181181
return true;
182182
}
183-
183+
184184
try {
185185
auto platforms = Platform::getPlatforms();
186186
if (platforms.empty()) {
187187
return false;
188188
}
189-
189+
190190
// Try to find a device of the preferred type
191191
cl_device_id best_device = nullptr;
192192
std::vector<cl_device_id> context_devices;
193-
193+
194194
for (auto platform : platforms) {
195195
auto devices = Platform::getDevices(platform, preferred_type);
196196
if (!devices.empty()) {
@@ -199,7 +199,7 @@ auto ComputeManager::initialize(DeviceType preferred_type) -> bool {
199199
break;
200200
}
201201
}
202-
202+
203203
// If preferred type not found, try any device
204204
if (!best_device) {
205205
for (auto platform : platforms) {
@@ -211,20 +211,20 @@ auto ComputeManager::initialize(DeviceType preferred_type) -> bool {
211211
}
212212
}
213213
}
214-
214+
215215
if (!best_device) {
216216
return false;
217217
}
218-
218+
219219
// Create context and command queue
220220
context_ = Platform::createContext(context_devices);
221221
queue_ = Platform::createCommandQueue(context_, best_device);
222222
device_ = best_device;
223223
device_info_ = Platform::getDeviceInfo(best_device);
224-
224+
225225
initialized_ = true;
226226
return true;
227-
227+
228228
} catch (const std::exception&) {
229229
return false;
230230
}

0 commit comments

Comments
 (0)