<commit_before>Tutorial: Optimizing Block Matrix Multiplication
================================================

This tutorial assumes that you have checked out a copy of opentuner. For guidelines on how to get opentuner set up, refer [here][technique-tutorial].

[technique-tutorial]: http://opentuner.org/tutorial/setup

Identifying a Program to Autotune
---------------------------------

In order to do autotuning, you first need something to autotune. This will normally be your own program that you want to make either fast or better in some way.  For this tutorial we will use a blocked version of matrix multiply as an example. We will use opentuner to find the optimal value of the block size parameter.

We will autotone the sample code below(based off of modification of code found [here][matrix-multiply-code]), making sure to take the block size as a compile time constant to the program. 

[technique-tutorial]: http://csapp.cs.cmu.edu/public/waside/waside-blocking.pdf

Save the sample code below to examples/tutorials/mmm_block.cpp

    #include <stdio.h>
    #include <cstdlib>

    int main(int argc, const char** argv)
    {
      int BlockSize = atoi(argv[1])*5;
      int n = BlockSize * (n/BlockSize);
      int a[100][100];
      int b[100][100];
      int c[100][100];
      int sum=0;
      for(int k1=0;k1<n;k1+=BlockSize)
      {
          for(int j1=0;j1<n;j1+=BlockSize)
          {
              for(int k1=0;k1<n;k1+=BlockSize)
              {
                  for(int i=0;i<n;i++)
                  {
                      for(int j=j1;j<j1+BlockSize;j++)
                      {
                          sum = c[i][j];
                          for(int k=k1;k<k1+BlockSize;k++)
                          {               
                              sum += a[i][k] * b[k][j];<commit_msg>fixed broken link issue<commit_after>Tutorial: Optimizing Block Matrix Multiplication
================================================

This tutorial assumes that you have checked out a copy of opentuner. For guidelines on how to get opentuner set up, refer [here][technique-tutorial].

[technique-tutorial]: http://opentuner.org/tutorial/setup

Identifying a Program to Autotune
---------------------------------

In order to do autotuning, you first need something to autotune. This will normally be your own program that you want to make either fast or better in some way.  For this tutorial we will use a blocked version of matrix multiply as an example. We will use opentuner to find the optimal value of the block size parameter.

We will autotone the sample code below(based off of modification of code found [here][matrix-multiply-code]), making sure to take the block size as a compile time constant to the program. 

[matrix-multiply-code]: http://csapp.cs.cmu.edu/public/waside/waside-blocking.pdf

Save the sample code below to examples/tutorials/mmm_block.cpp

    #include <stdio.h>
    #include <cstdlib>

    int main(int argc, const char** argv)
    {

      int n = BLOCK_SIZE * (n/BLOCK_SIZE);
      int a[100][100];
      int b[100][100];
      int c[100][100];
      int sum=0;
      for(int k1=0;k1<n;k1+=BLOCK_SIZE)
      {
          for(int j1=0;j1<n;j1+=BLOCK_SIZE)
          {
              for(int k1=0;k1<n;k1+=BLOCK_SIZE)
              {
                  for(int i=0;i<n;i++)
                  {
                      for(int j=j1;j<j1+BLOCK_SIZE;j++)
                      {
                          sum = c[i][j];
                          for(int k=k1;k<k1+BLOCK_SIZE;k++)
                          {               
                              sum += a[i][k] * b[k][j];
{'fraction_non_alphanumeric': 0.13777900248002203, 'fraction_numerical': 0.020391292367043262, 'mean_word_length': 2.145580589254766, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7469635', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1055, 'n_words': 347}