Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2011 10:54
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/1380143 to your computer and use it in GitHub Desktop.
Save anonymous/1380143 to your computer and use it in GitHub Desktop.
Intel Cilk Plus -- Example #3 (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[])
{
#define N 16
#define M 16
int (* a)[N] = (int (*)[N]) _mm_malloc(N * M * sizeof(int), 64);
cilk_for(int j = 0; j < N; j++) {
a[0][j] = j + 1;
}
cilk_for(int i = 1; i < M; i++) {
a[i][:] = a[0][:];
}
for(int i = 1; i < M; i++) {
a[i][:] += a[i - 1][:];
}
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