@@ -36,7 +36,7 @@ invoked from the host using this library.
3636
3737using namespace gpu; // CreateContext, CreateTensor, CreateKernel,
3838 // CreateShader, DispatchKernel, Wait, ToCPU
39- // GPUTensor , Kernel, GPUContext , Shape, kf32
39+ // Tensor , Kernel, Context , Shape, kf32
4040
4141static const char *kGelu = R"(
4242const GELU_SCALING_FACTOR: f32 = 0.7978845608028654; // sqrt(2.0 / PI)
@@ -56,15 +56,14 @@ fn main(
5656)";
5757
5858int main(int argc, char **argv) {
59- printf("\nHello, gpu.cpp\n\n");
60- GPUContext ctx = CreateContext();
59+ Context ctx = CreateContext();
6160 static constexpr size_t N = 3072;
6261 std::array<float, N> inputArr, outputArr;
6362 for (int i = 0; i < N; ++i) {
6463 inputArr[i] = static_cast<float>(i) / 2.0; // dummy input data
6564 }
66- GPUTensor input = CreateTensor(ctx, Shape{N}, kf32, inputArr.data());
67- GPUTensor output = CreateTensor(ctx, Shape{N}, kf32);
65+ Tensor input = CreateTensor(ctx, Shape{N}, kf32, inputArr.data());
66+ Tensor output = CreateTensor(ctx, Shape{N}, kf32);
6867 Kernel op = CreateKernel(ctx, CreateShader(kGelu, 256, kf32), input, output);
6968 DispatchKernel(ctx, op);
7069 Wait(ctx, op.future);
@@ -83,6 +82,8 @@ the equivalent functionality is implemented using the WebGPU C API in
8382
8483## Quick Start: Building and Running
8584
85+ * Tutorial App*
86+
8687The only dependency of this library is a WebGPU implementation. Currently we
8788recommend using the Dawn backend until further testing, but we plan to support
8889emscripten (web) and wgpu (native) backends.
@@ -115,7 +116,6 @@ Welcome!
115116--------
116117
117118This program is a brief intro to the gpu.cpp library.
118-
119119...
120120
121121```
@@ -126,6 +126,8 @@ minutes. The gpu.cpp library itself is small so after building the Dawn backend
126126the first time, subsequent builds of the library should take seconds on most
127127personal computing devices.
128128
129+ * Using gpu.cpp as a Library*
130+
129131You can build the library itself which builds a shared library that you can
130132link against for your own projects. This builds a library that can be used in
131133other C++ projects (most of the code is in ` gpu.h ` , plus some supporting code
@@ -135,8 +137,11 @@ in `utils/`).
135137make libgpu
136138```
137139
138- ((TODO(avh): link to a template repo that with gpu.cpp as a library already
139- configured.))
140+ If you are starting a new project using gpu.cpp as a library dependency, we
141+ recommend starting by cloning the template project
142+ [ https://github.com/AnswerDotAI/gpu.cpp-template ] ( https://github.com/AnswerDotAI/gpu.cpp-template ) .
143+
144+ * Example Demos in ` examples/ ` *
140145
141146From there you can explore the example projects in ` examples/ ` which illustrate
142147how to use gpu.cpp as a library. For example a standalone version of the hello
@@ -165,6 +170,8 @@ Hello, gpu.cpp
165170...
166171```
167172
173+ * Machine Learning Kernel Implementations (WIP)*
174+
168175A more extensive set of (machine learning-centric) kernels is implemented in
169176` utils/test_kernels.cpp ` . This can be built and run (from the top level
170177directory) using:
@@ -176,6 +183,8 @@ make tests
176183For more configurability and control of the build, see the ` cmake ` invocations
177184in the ` Makefile ` , as well as the configuration in ` Cmakelists.txt ` .
178185
186+ * Resetting Build State / Removing Build Artifacts*
187+
179188If you need to clean up the build artifacts, you can run:
180189
181190```
@@ -232,12 +241,15 @@ convenient API with both both native (e.g. Dawn) and browser implementations.
232241It uses WebGPU as a portable GPU API first and foremost, with the possibility
233242of running in the browser being support being a convenient bonus.
234243
244+ For additional background on WebGPU as a portable native GPU API, see Elie
245+ Michel's talk [ WebGPU is Not Just about the
246+ Web] ( https://www.youtube.com/watch?v=qHrx41aOTUQ ) .
247+
235248Finally, the focus of gpu.cpp is general-purpose GPU computation rather than
236249rendering/graphics on the GPU, although it might be useful for compute shaders
237250in graphics projects - one of the examples is a small compute renderer,
238251rendered to the terminal.
239252
240-
241253## Contributing and Work-in-Progress
242254
243255We welcome contributions! There's a lot of low hanging fruit - fleshing out
0 commit comments