Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2011 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1380140 to your computer and use it in GitHub Desktop.
Save anonymous/1380140 to your computer and use it in GitHub Desktop.
Intel Cilk Plus -- Example #2 (multiplication table 16x16)
#include <stdio.h>
#include <cstdlib>
#include <cilk/cilk.h>
#include <iostream>
/* ex: set tabstop=8 softtabstop=4 expandtab: */
int main(int argc, char* argv[])
{
int N = 16;
int M = 16;
int * arr = (int *) _mm_malloc(N * M * sizeof(int), 64);
cilk_for(int j = 0; j < N; j++) {
arr[j] = j + 1;
}
cilk_for(int i = 1; i < M; i++) {
int * a = &(arr[i * N]);
a[0:N] = arr[0:N] * (i + 1);
}
int (* a)[N] = (int (*)[N]) arr;
for(int i = 0; i < M; i++) {
for(int j = 0; j < N; j++) {
printf("%4d ", a[i][j]);
}
std::cout << std::endl;
}
_mm_free(a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment