mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-13 02:47:00 +00:00
dbce4532f4
CUDA is a C++ superset, so .cu/.cuh files parse cleanly with tree-sitter-cpp (already a dependency). Two registrations wire it up: - detect.py: add .cu/.cuh to CODE_EXTENSIONS so they're detected and watched (watch.py's _WATCHED_EXTENSIONS derives from CODE_EXTENSIONS). - extract.py: route .cu/.cuh through extract_cpp in _DISPATCH, which also makes collect_files() pick them up (_EXTENSIONS = _DISPATCH.keys()). Adds tests/fixtures/sample.cu (kernel + __device__/host functions + struct + includes) and CUDA cases in test_languages.py covering kernel/ device function extraction, structs, includes, and host call edges. Documents the new extensions in the README extension table and CHANGELOG. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
568 B
Plaintext
31 lines
568 B
Plaintext
#include <cstdio>
|
|
#include <vector>
|
|
|
|
struct Vec3 {
|
|
float x;
|
|
float y;
|
|
float z;
|
|
};
|
|
|
|
__device__ float dot(const Vec3& a, const Vec3& b) {
|
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
}
|
|
|
|
__global__ void saxpy(int n, float a, const float* x, float* y) {
|
|
int i = blockIdx.x * blockDim.x + threadIdx.x;
|
|
if (i < n) {
|
|
y[i] = a * x[i] + y[i];
|
|
}
|
|
}
|
|
|
|
float host_norm(const Vec3& v) {
|
|
return dot(v, v);
|
|
}
|
|
|
|
int main() {
|
|
Vec3 v{1.0f, 2.0f, 3.0f};
|
|
float n = host_norm(v);
|
|
saxpy<<<1, 256>>>(256, 2.0f, nullptr, nullptr);
|
|
return 0;
|
|
}
|