Mind-bending new programming language for GPUs just dropped...

Fireship · Intermediate ·⚡ Algorithms & Data Structures ·2y ago

Key Takeaways

This video introduces the Bend programming language for parallel computing on GPUs with a Python-like syntax

Full Transcript

yesterday the clouds opened up and a weird new programming language came down to earth with a promise of parallelism for allou who writeth code this is big if true because parallel Computing is a superpower it allows a programmer to take a problem that could be solved in a week and instead solve it in seven days using seven different computers unfortunately running code in parallel is like conducting a symphony one wrong note and the entire thing becomes a total disaster but luckily Bend offers Hope by making a bold promise everything that can run in parallel will run in parallel you don't need to know anything about Cuda blocks locks mutexes or regex's to write algorithms that take advantage of all 24 of your CPU cores or even all 16,000 of your GPU cores you just write some highlevel python looking code and the rest is Magic it is May 17th 2024 and you're watching the code report when you write code in a language like python your code runs on a single thread that means only one thing can happen at a time it's like going to a KFC with only one employee who takes the order cleans the toilets and Cooks the food in that order now on a modern CPU you might have a clock cycle around 4 GHz and if it's handling one instruction per cycle you're only able to perform 4 billion instructions per second now if four giips is not enough you can modify your python code to take advantage of multiple threads but it adds a lot of complexity to your code and there's all kinds of gotas like race conditions Deadlocks thread starvation and may even lead to conflicts with demons even if you do manage to get it working you might find that your CPU just doesn't have enough juice at which point you look into using the thousands of cacor on your GPU you but now you'll need to write some C++ code and likely blow your leg off in the process well what if there is a language that just knew how to run things in parallel by default that's the promise of Bend imagine we have a computation that adds two completely random numbers together in Python The Interpreter is going to convert this into B code and then eventually run it on the python virtual machine pretty simple but in Bend things are a little more complex the elements of the computation are structured into a graph which are called interaction combinators you can think of it as a big network of all the computations that need to be done when two nodes run into each other the computation progresses by following a simple set of rules that rewrite the computation in a way that can be done in parallel it continues this pattern until all computations are done it then merges the result back into whatever expression was returned from the function this concept of interaction combinators goes all the way back to the 1990s and is implemented in a runtime called the higher order virtual machine hbm is not meant to be used directly and that's why they build bend a highle language to interface with it and the language itself is implemented in Rust its syntax is very similar to Python and we can write a Hello World by defining a main function that returns a string now to execute this code we can pull up the terminal and use the Ben run command by default this is going to use the rust interpreter which will execute it sequentially just like any other boring language but now here's where things get interesting imagine we have an algorithm that needs to count a bunch of numbers and then add them together the first thing that might blow your mind is that bend does not have loops like we can't just do a for Loop like we would in Python instead Bend has something entirely different called a fold that works like a search and replace for data types and any algorithm that requires a loop can be replaced with a fold basically a fold allows you to consume recursive data types in parallel like a list or a tree but first we need to construct a recursive data type and for that we have the bend keyword which is like the opposite of fold now if that's a little too mind-bending maybe check out my back catalog for recursion in 100 seconds but now let's see what this looks like from a performance standpoint when I try to run this algorithm on a single thread it takes forever like 10 minutes or more however I can run the same code without any modification whatsoever with the bend run C command when I do that it's now utilizing all 24 threads on my CPU and now it only takes about 30 seconds to run the computation that's a huge Improvement but I think we can still do better because I'm a baller I have an Nvidia RTX 490 and once again I can run this code without any modification on Cuda with Bend run- cuu and now this code only takes 1 and 1 half seconds to run and I'll just go ahead and drop the mic right there this has been the code report thanks for watching and I will see you in the next one

Original Description

What is the Bend programming language for parallel computing? Let's take a first look at Bend and how it uses a Python-like syntax to write high performance code that can run on the GPU. #programming #tech #thecodereport 💬 Chat with Me on Discord https://discord.gg/fireship 🔗 Resources Bend Language GitHub https://github.com/HigherOrderCO/Bend CUDA in 100 Seconds https://youtu.be/pPStdjuYzSI Recursion in 100 Seconds https://youtu.be/rf60MejMz3E 🔥 Get More Content - Upgrade to PRO Upgrade at https://fireship.io/pro Use code YT25 for 25% off PRO access 🎨 My Editor Settings - Atom One Dark - vscode-icons - Fira Code Font 🔖 Topics Covered - What is Bend language? - Parallelism vs Concurrency - Rust programming language projects - CUDA alternatives - How to run code on a GPU
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Fireship · Fireship · 0 of 60

← Previous Next →
1 Angular 4 Development and Production Environments with Firebase
Angular 4 Development and Production Environments with Firebase
Fireship
2 OAuth with Angular and Firebase Tutorial
OAuth with Angular and Firebase Tutorial
Fireship
3 Anonymous Authentication with Angular and Firebase - Lazy Registration
Anonymous Authentication with Angular and Firebase - Lazy Registration
Fireship
4 Angular Router Guards for Firebase Users
Angular Router Guards for Firebase Users
Fireship
5 Angular Firebase CRUD App with NoSQL Database Tutorial
Angular Firebase CRUD App with NoSQL Database Tutorial
Fireship
6 Upload Files from Angular to Firebase Storage
Upload Files from Angular to Firebase Storage
Fireship
7 How to Deploy an Angular App to Firebase Hosting
How to Deploy an Angular App to Firebase Hosting
Fireship
8 Sharing Data between Components in Angular
Sharing Data between Components in Angular
Fireship
9 Loading Spinners for Asynchronous Firebase Data
Loading Spinners for Asynchronous Firebase Data
Fireship
10 Angular 4 Transactional Email with Google Firebase Cloud Functions
Angular 4 Transactional Email with Google Firebase Cloud Functions
Fireship
11 Firebase Database Rules Tutorial
Firebase Database Rules Tutorial
Fireship
12 Autocomplete Search with Angular4 and Firebase
Autocomplete Search with Angular4 and Firebase
Fireship
13 Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Fireship
14 Angular Drag-and-Drop File Uploads to Firebase Storage
Angular Drag-and-Drop File Uploads to Firebase Storage
Fireship
15 Text Translation with Firebase Cloud Functions onWrite and Angular 4
Text Translation with Firebase Cloud Functions onWrite and Angular 4
Fireship
16 Custom Usernames with Firebase Authentication
Custom Usernames with Firebase Authentication
Fireship
17 Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Fireship
18 Simple Pagination with Firebase and Angular 4
Simple Pagination with Firebase and Angular 4
Fireship
19 How to Connect Firebase Users to their Data - 3 Methods
How to Connect Firebase Users to their Data - 3 Methods
Fireship
20 Add Toast Message Notifications to your Angular App
Add Toast Message Notifications to your Angular App
Fireship
21 Facebook-Inspired Reactions System with Angular and Firebase
Facebook-Inspired Reactions System with Angular and Firebase
Fireship
22 Learn NgModule in Angular with Examples
Learn NgModule in Angular with Examples
Fireship
23 Lazy Loading Components in Angular 4
Lazy Loading Components in Angular 4
Fireship
24 Stripe Checkout Payments with Angular and Firebase - Part 1
Stripe Checkout Payments with Angular and Firebase - Part 1
Fireship
25 Process Stripe Payments with Firebase Cloud Functions - Part 2
Process Stripe Payments with Firebase Cloud Functions - Part 2
Fireship
26 Selling Digital Content in Angular with Stripe Payments - Part 3
Selling Digital Content in Angular with Stripe Payments - Part 3
Fireship
27 Angular 4 Full Text Search with Algolia - Part 1
Angular 4 Full Text Search with Algolia - Part 1
Fireship
28 Algolia with Firebase Cloud Functions - Part 2
Algolia with Firebase Cloud Functions - Part 2
Fireship
29 Firebase Phone Authentication in Angular 4
Firebase Phone Authentication in Angular 4
Fireship
30 Top 7 RxJS Concepts for Angular Developers
Top 7 RxJS Concepts for Angular Developers
Fireship
31 Learn Angular Animations with 5 Examples
Learn Angular Animations with 5 Examples
Fireship
32 Advanced Firebase Data Filtering (Multi-Property)
Advanced Firebase Data Filtering (Multi-Property)
Fireship
33 Realtime Maps with Mapbox + Firebase + Angular
Realtime Maps with Mapbox + Firebase + Angular
Fireship
34 Angular Reactive Forms with Firebase Database Backend
Angular Reactive Forms with Firebase Database Backend
Fireship
35 Send Push Notifications in Angular with Firebase Cloud Messaging
Send Push Notifications in Angular with Firebase Cloud Messaging
Fireship
36 Top 7 Ways to Debug Angular 4 Apps
Top 7 Ways to Debug Angular 4 Apps
Fireship
37 Infinite Scroll with Angular and Firebase
Infinite Scroll with Angular and Firebase
Fireship
38 Use TypeScript with Firebase Cloud Functions
Use TypeScript with Firebase Cloud Functions
Fireship
39 Realtime Graphs and Charts with Plotly and Firebase
Realtime Graphs and Charts with Plotly and Firebase
Fireship
40 Role-Based User Permissions in Firebase
Role-Based User Permissions in Firebase
Fireship
41 User Presence System in Realtime - Online, Offline, Away
User Presence System in Realtime - Online, Offline, Away
Fireship
42 Location-based Queries with GeoFire and Angular Google Maps
Location-based Queries with GeoFire and Angular Google Maps
Fireship
43 Angular ngrx Redux Quick Start Tutorial
Angular ngrx Redux Quick Start Tutorial
Fireship
44 Angular Ngrx Effects with Firebase Database
Angular Ngrx Effects with Firebase Database
Fireship
45 Progressive Web Apps with Angular
Progressive Web Apps with Angular
Fireship
46 Angular Ngrx with Firebase Google OAuth User Authentication
Angular Ngrx with Firebase Google OAuth User Authentication
Fireship
47 RxJS Quick Start with Practical Examples
RxJS Quick Start with Practical Examples
Fireship
48 Send SMS Text Messages with Twilio and Firebase
Send SMS Text Messages with Twilio and Firebase
Fireship
49 Firebase Database Performance Profiling
Firebase Database Performance Profiling
Fireship
50 Native Desktop Apps with Angular and Electron
Native Desktop Apps with Angular and Electron
Fireship
51 Subscription Payments with Stripe, Angular, and Firebase
Subscription Payments with Stripe, Angular, and Firebase
Fireship
52 Firestore with AngularFire5 Quick Start Tutorial
Firestore with AngularFire5 Quick Start Tutorial
Fireship
53 Angular HTTP Client Quick Start Tutorial
Angular HTTP Client Quick Start Tutorial
Fireship
54 Google Sign-In with Firestore Custom User Data
Google Sign-In with Firestore Custom User Data
Fireship
55 Star Review System from Scratch with Firestore + Angular
Star Review System from Scratch with Firestore + Angular
Fireship
56 Angular Chatbot with Dialogflow (API.ai)
Angular Chatbot with Dialogflow (API.ai)
Fireship
57 Learn @ngrx/entity and Feature Modules
Learn @ngrx/entity and Feature Modules
Fireship
58 Infinite Scroll Pagination with Firestore
Infinite Scroll Pagination with Firestore
Fireship
59 Faster Firestore via Data Aggregation
Faster Firestore via Data Aggregation
Fireship
60 Contentful - CMS for Angular Progressive Web Apps
Contentful - CMS for Angular Progressive Web Apps
Fireship

Related Reads

📰
Data Structures & Algorithms for Mobile App Developers
Learn essential data structures and algorithms for mobile app development to improve performance and efficiency
Medium · Programming
📰
Data Structures and Algorithms Deep‑Dive — Real-world Applications of Hash Tables (Chapter 3…
Learn how hash tables are used in real-world applications and improve your coding skills with practical examples
Medium · Programming
📰
Data Structures and Algorithms Deep‑Dive — Real-world Applications of Hash Tables (Chapter 3…
Learn how hash tables are applied in real-world scenarios and improve your coding skills with practical examples
Medium · Python
📰
Day 29/100 Koko Eating Bananas (Binary Search)
Learn to implement binary search to solve the Koko Eating Bananas problem and improve your algorithmic skills
Medium · Programming
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →