Single-Assignment C
An array programming language for numerically intensive applications and signal processing.
— Latest Release: NoJS
SaC focuses on
Performance
Combining state-of-the-art optimisations with targeted code generation techniques, SaC can make the most out of your system.
Productivity
Effortlessly create programs for scientific workloads, using abstractions in SaC that match closely to the underlying mathematics. Through suitable interfaces, SaC can be integrated into your existing application stack and workflow.
Portability
Write it once, reuse it everywhere is a central theme of SaC. Why waste time rethinking your algorithm for the next architecture or new system configuration. Let SaC do that for you!
You can read more about SaC's
or have a look at our for details on our optimisations.Familiar, but different
SaC looks and feels like C/C++, with some extra functionality on top without the headaches and pitfalls of memory management. To give you a little taste and feel of SaC, here are some examples:
Matrix Multiplication
test
use Array: all; double[.,.] matmul (double[.,.] a, double[.,.] b) { // transpose bt = { [i,j] -> b[j,i] }; // multiplication return { iv -> sum (a[iv[0]] * bt[iv[1]]) | iv < [shape(a)[0],shape(b)[1]] }; } int main() { // create matrices A = reshape ([6,8], tod (iota (48))); B = reshape ([8,2], tod (iota (16))); C = matmul (A, B); StdIO::print (C); return 0; }
Parallel Scan
int [+], int scan (int [+] a) { // TODO TC multiple return not supported yet a, m = { iv -> scan (a[iv ]) | iv < drop ([ -1] , shape (a)) }; m, s = scan (m); a = a ^+ m; return (a, s); }
The all pair N-body problem can be almost literally transliterated from its mathematical formulation into a valid SaC program:
\begin{eqnarray} \overset{\tiny k+1}{p_i} &=& \overset{k}{p_i} + \overset{k}{v_i} dt \\ \overset{k+1}{v_i} &=& \overset{k}{v_i} + \overset{k}{a_i} dt \\ \overset{k+1}{a_i} &=& \sum\limits_{j \neq i}^{n} \dfrac{m_j (\overset{k+1}{p_j} - \overset{k+1}{p_i})} {\left|\overset{k+1}{p_j} - \overset{k+1}{p_i} \right|^3} \end{eqnarray}
p = p + v * dt; v = v + a * dt; a = {[i] -> vsum ({[j] -> (i == j ? [0.0, 0.0, 0.0] : m[j] * (p[j] - p[i]) / (l2norm (p[j] - p[i]) ^ 3) }) };
Have a look at the
for more details.Getting Started
You can try out SaC without installing it, have look at:
Or you can start your journey by
.Under the hood
Get involved
SaC is a community effort by developers like you, whether you're coming from industry, academia, or are a hobbyist, with your help we can make SaC better!
Contributing
Do you have an idea, some way to improve the SaC experience, or just want to tame dragons with us? Then come join us and help to shape SaC! See our
for details.Bug Reporting
Have you spotted a bug? Noticed an issue? Who you going to call? Your friendly bug zapping developers! Submit your report on our
.Chat with us
Want to pick our brains, or have some question? We're happy to chat! Have a look at our
on how to reach us.