-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy path{{PROJECT_NAME_LOWER}}.cu
More file actions
67 lines (60 loc) · 2.37 KB
/
Copy path{{PROJECT_NAME_LOWER}}.cu
File metadata and controls
67 lines (60 loc) · 2.37 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "megakernel.cuh"
#include "config.cuh"
#include <iostream>
#include "pyutils/pyutils.cuh" // Kittens Python utilities
#include <pybind11/pybind11.h>
using namespace kittens;
struct globals {
using instruction_layout = megakernel::instruction_layout<{{PROJECT_NAME_LOWER}}_config>;
using timing_layout = megakernel::timing_layout<{{PROJECT_NAME_LOWER}}_config>;
instruction_layout instructions;
timing_layout timings;
dim3 grid() { return dim3(148); }
dim3 block() { return dim3({{PROJECT_NAME_LOWER}}_config::NUM_THREADS); }
int dynamic_shared_memory() { return {{PROJECT_NAME_LOWER}}_config::DYNAMIC_SHARED_MEMORY; }
};
using state = megakernel::state<{{PROJECT_NAME_LOWER}}_config>;
struct TestOp {
static constexpr int opcode = 1;
struct controller {
static __device__ int init_semaphores(const globals &g, state &s) {
return 0;
}
static __device__ int release_lid(const globals &g, typename {{PROJECT_NAME_LOWER}}_config::instruction_t &instruction, int &query) {
return query;
}
};
struct loader {
static __device__ void run(const globals &g, state &s) {
if(laneid() == 0) { printf("Hello, world from {{PROJECT_NAME_LOWER}}!\n"); }
}
};
struct launcher {
static __device__ void run(const globals &g, state &s) {
// Wait and release pages
if(laneid() < {{PROJECT_NAME_LOWER}}_config::NUM_PAGES) {
s.wait_page_ready(laneid());
s.finish_page(laneid(), {{PROJECT_NAME_LOWER}}_config::NUM_CONSUMER_WARPS);
}
#ifdef KITTENS_BLACKWELL
else if(laneid() == {{PROJECT_NAME_LOWER}}_config::NUM_PAGES) {
s.wait_tensor_ready();
arrive(s.tensor_finished, {{PROJECT_NAME_LOWER}}_config::NUM_CONSUMER_WARPS);
}
#endif
}
};
struct consumer {
static __device__ void run(const globals &g, state &s) {}
};
struct storer {
static __device__ void run(const globals &g, state &s) {}
};
};
PYBIND11_MODULE({{PROJECT_NAME_LOWER}}, m)
{
m.doc() = "";
kittens::py::bind_kernel<megakernel::mk<{{PROJECT_NAME_LOWER}}_config, globals, TestOp>>(m, "example_megakernel",
&globals::instructions,
&globals::timings);
}