K3_AI: Run command on SpacemiT K3's AI cores

hasheddan1 pts0 comments

GitHub - brucehoult/k3_ai: Utility to start a program on the A100 "AI" cores on SpacemiT K3 machines. · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

brucehoult

k3_ai

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>2 Commits<br>2 Commits

LICENSE

LICENSE

Makefile

Makefile

README.md

README.md

ai

ai

aix.S

aix.S

View all files

Repository files navigation

Run command on K3's AI cores

Utility to run a command with arguments on the A100 "AI" cores on SpacemiT K3.

Quick start

$ git clone https://github.com/brucehoult/k3_ai<br>$ cd k3_ai<br>$ make<br>$ ai bash

Usage

ai cmd arg1 arg2 ...

aix path arg1 arg2 ...

Normally prefer to use ai. This is a shell script that converts a bare program name to the absolute path<br>of the executable and then chains to aix. It's about 1ms slower than calling aix directly.

aix is a tiny assembly language program that needs the absolute or relative path of the program to run.<br>It is written to be pure asm using only syscalls, no libraries, no dynamic linker, so as to be<br>really sure that nothing has used any RVV instructions in this process, and therefore no<br>decisions have been made based on the X100 core's shorter VLEN.

Examples

# just run a single program on the A100 cores<br>ai as hello.s -o hello.o

# same thing but maybe 1ms faster<br>aix /usr/bin/as hello.s -o hello.o

# run a whole build. All processes started by `make` will run on the A100 cores.<br>ai make -j8 test

# start a shell on the A100 cores. All programs run from it will be run only on the A100 cores<br>ai bash

Why you need it

The K3 has eight high performance Out-of-Order X100 cores with RISC-V vector length of 256 bits.<br>These cores are what all normal Linux programs run on.

There are also eight lower performance in-order A100 "AI" cores similar to the X60 cores in the<br>SpacemiT K1/M1 chips, but with long 1024 bit vector registers and ALU.

The "AI" cores can actually run all normal Linux programs. On standard scalar code they have<br>approximately 40% the performance of the main X100 cores, but on certain kinds of vectorised<br>code (for example Llama) they have considerably higher performance.

Even ignoring vectorised code, the A100 cores by themselves have more computing power than<br>any previous RISC-V computer under $1000, including those using the Allwinner D1, StarFive JH7110,<br>THead TH1520, SpacemiT K1/M1, or even Eswin EIC7700x.

As such, it is well worth using the A100 cores to run normal programs and adding 40% to the<br>overall power of a K3 computer.

Because of the different vector length, it is dangerous to move a program between X100 and A100<br>cores -- in either direction -- once it has been started.

SpacemiT provides a mechanism to move an existing running program from the X100 cores to the<br>A100 cores by writing the PID of the process to /proc/set_ai_thread but that is dangerous<br>depending on what that process has already done.

This utility creates a new process and then moves it to the A100 cores before it has done<br>anything dangerous, and then does EXEC() on the program you really wanted to run.

About

Utility to start a program on the A100 "AI" cores on SpacemiT K3 machines.

Resources

Readme

License

MIT license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

stars

Watchers

watching

Forks

forks

Report repository

Releases

No releases published

Packages

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

Assembly<br>66.4%

Shell<br>23.1%

Makefile<br>10.5%

You can’t perform that action at this time.

cores a100 program spacemit reload k3_ai

Related Articles