-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.tsx
More file actions
275 lines (258 loc) · 9.37 KB
/
Copy pathindex.tsx
File metadata and controls
275 lines (258 loc) · 9.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import React, { useEffect, useState, useRef } from "react";
import clsx from "clsx";
import Link from "@docusaurus/Link";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import HomeLayout from "@site/src/components/HomeLayout";
import Heading from "@theme/Heading";
import Navbar from "@theme/Navbar";
import CodeBlock from "@theme/CodeBlock";
import {
FcMultipleDevices,
FcLike,
FcPuzzle,
FcParallelTasks,
FcInTransit,
} from "react-icons/fc";
interface HeroCodeProps {
className?: string;
}
const HeroCode: React.FC<HeroCodeProps> = ({ className = "" }) => {
const rustCode = `\
use glam::UVec3;
use spirv_std::spirv;
#[repr(u32)]
pub enum Outcome {
Fizz,
Buzz,
FizzBuzz,
}
trait Game {
fn fizzbuzz(&self) -> Option<Outcome>;
}
impl Game for usize {
fn fizzbuzz(&self) -> Option<Outcome> {
match (self % 3 == 0, self % 5 == 0) {
(true, true) => Some(Outcome::FizzBuzz),
(true, false) => Some(Outcome::Fizz),
(false, true) => Some(Outcome::Buzz),
_ => None,
}
}
}
#[spirv(compute(threads(64)))]
pub fn main(
#[spirv(global_invocation_id)] id: UVec3,
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)]
output: &mut [Option<Outcome>; 64],
) {
let index = id.x as usize;
output[index] = index.fizzbuzz();
}\
`;
return (
<CodeBlock
language="rust"
className={clsx(
"max-w-[50em] lg:max-w-[80em] overflow-hidden leading-tight w-full text-left",
"text-[8px] lg:text-[11px]",
"font-mono",
className
)}
>
{rustCode}
</CodeBlock>
);
};
function HomepageHeader() {
const { siteConfig } = useDocusaurusContext();
return (
<header className="flex flex-col w-full max-w-[1200px] justify-center mx-auto">
<div className="flex flex-col flex-grow items-center justify-center w-full">
{/* Row 1 */}
<div className="flex flex-col lg:flex-row w-full gap-8 items-center">
{/* Left Column */}
<div className="flex flex-col items-center justify-center text-center w-full lg:w-1/2">
<h1 className="heading-text text-5xl font-bold font-text my-0">
{siteConfig.title}
</h1>
<h3 className="title-text mx-4 lg:mx-0 text-3xl mt-[1em] font-text font-medium">
{siteConfig.tagline}
</h3>
</div>
{/* Right Column */}
<div className="flex items-center justify-center w-full lg:w-1/2 h-full mx-2 lg:ml-0 lg:mr-8 overflow-hidden">
<HeroCode />
</div>
</div>
</div>
{/* Row 2 (Learn More at the Bottom) */}
<div className="flex justify-center w-full mt-auto mb-4">
<h4 className="text-md font-text font-normal cursor-pointer">
<a
id="learn-more"
onClick={() =>
document
.getElementById("features")
?.scrollIntoView({ behavior: "smooth" })
}
>
Learn More ⇣
</a>
</h4>
</div>
</header>
);
}
interface FeatureSectionProps {
className?: string;
children: React.ReactNode;
}
const FeatureSection: React.FC<FeatureSectionProps> = ({
className = "",
children,
}) => {
return (
<div className={clsx("ml-8 pl-4 border-l-2 border-[#e5e7eb]", className)}>
{children}
</div>
);
};
function Features() {
const { siteConfig } = useDocusaurusContext();
return (
<div
id="features"
className={`flex flex-col justify-center pb-12 pt-12 px-[2em] max-w-[1200px] w-full`}
>
<div className="w-full text-4xl mb-8 font-text text-center">
Finally, a modern language for GPUs
</div>
<div className="w-full justify-center">
<p>
Rust GPU makes it possible to write and run GPU software in Rust,
leveraging the language's powerful safety and concurrency features to
enhance performance and reliability. With Rust GPU, you can seamlessly
develop for both CPU and GPU using a unified codebase while benefiting
from Rust's existing ecosystem.
</p>
<h2 id="multi-vendor">
<FcMultipleDevices className="inline-block mb-1 mr-2" /> Multi-Vendor
</h2>
<FeatureSection>
<p>
The Rust GPU compiler backend emits code compatible with{" "}
<a href="https://www.vulkan.org">Vulkan</a>, ensuring your code runs
across a{" "}
<a href="https://vulkan.gpuinfo.org/">
wide range of devices and vendors
</a>
.
</p>
<p>
If instead you wish to stick to the NVIDIA-only ecosystem, stay
tuned as the{" "}
<a href="https://github.com/rust-gpu/rust-cuda">Rust CUDA</a>{" "}
project is in the process of being rebooted and possibly integrated
with Rust GPU.
</p>
</FeatureSection>
<h2 id="modern-and-unified">
<FcLike className="inline-block mb-1 mr-2" />
Modern and Unified
</h2>
<FeatureSection>
<p>
There is no longer a need to learn a GPU-specific programming
language. You can write both CPU and GPU code in Rust, leveraging
your existing Rust knowledge and maintaining a consistent
development experience. Furthermore, the{" "}
<em>same code can run on both the CPU and GPU</em>, with divergent
behavior gated behind <code>cfg</code> attributes and macros where
necessary.
</p>
<p>
Even if your current codebase isn't written in Rust, choosing Rust
for the GPU parts gives you more widely applicable skills in one of
the{" "}
<a href="https://octoverse.github.com/2022/top-programming-languages">
fastest-growing languages on GitHub
</a>
. Rust is also one of the{" "}
<a href="https://github.blog/developer-skills/programming-languages-and-frameworks/why-rust-is-the-most-admired-language-among-developers/">
most admired programming languages
</a>{" "}
while GPU-specific languages are considered a necessary evil.
</p>
</FeatureSection>
<h2 id="fearless-concurrency">
<FcParallelTasks className="inline-block mb-1 mr-2" />
Fearless Concurrency
</h2>
<FeatureSection>
<p>
Rust's ownership model and type system guarantee memory safety,
minimizing bugs and undefined behavior. Rust's borrow checker also
enables fearless concurrency, which is essential for maximizing
performance on massively parallel GPUs.
</p>
</FeatureSection>
<h2 id="powerful-abstractions">
<FcPuzzle className="inline-block mb-1 mr-2" />
Powerful Abstractions
</h2>
<FeatureSection>
<p>
Programming in GPU-specific languages can often feel like{" "}
<a href="https://xol.io/blah/death-to-shading-languages/">
taking a step back to the 90s
</a>
, where primitive tools and sharp edges abound. Because of this,
code written for GPUs is simplistic with low cyclomatic complexity.
Rust has an expressive type system and zero-cost abstractions that
enable writing high-level, reusable code without sacrificing
performance. This approach leads to more maintainable and
sophisticated GPU programs, streamlining the development process and
enhancing productivity.
</p>
</FeatureSection>
<h2 id="existing-ecosystem">
<FcInTransit className="inline-block mb-1 mr-2" />
Existing Ecosystem
</h2>
<FeatureSection>
<p>
The state-of-the-art for sharing GPU code is copy and pasting. With
Rust GPU we are excited to bring the excellent <code>cargo</code>{" "}
and crates.io ecosystem to GPU programming and provide some sanity.
</p>
<p>
Rust's <code>no_std</code> ecosystem offers a wide array of
libraries that can be used in environments without the standard
library. Traditionally this has meant embedded devices, but a lot of
the same assumptions apply to GPUs! As a consequence, you can reuse{" "}
<a href="https://crates.io/categories/no-std::no-alloc">
existing <code>no_std</code> libraries from crates.io
</a>{" "}
in your GPU code{" "}
<em>without the authors explicitly adding GPU support</em>. This is
uniquely enabled by Rust GPU's implementation choices and Rust's{" "}
<a href="https://without.boats/blog/the-registers-of-rust/">
registers
</a>
. Sharing and reusing code from the greater Rust ecosystem is a
superpower when writing GPU programs that will massively compound
over time.
</p>
</FeatureSection>
</div>
</div>
);
}
export default function Home(): JSX.Element {
const { siteConfig } = useDocusaurusContext();
return (
<HomeLayout description={siteConfig.tagline} hero={<HomepageHeader />}>
<Features />
</HomeLayout>
);
}