diff --git a/codes/heat-3d/heat-3d.c b/codes/heat-3d/heat-3d.c
index b976459aca88490cbb6afa40879a9534688d4994..f171a17d21335e01b7ba126aaeab325539611ee7 100644
--- a/codes/heat-3d/heat-3d.c
+++ b/codes/heat-3d/heat-3d.c
@@ -57,6 +57,26 @@ void print_array(int n,
   POLYBENCH_DUMP_FINISH;
 }
 
+extern double _binary_data_bin_start;
+extern double _binary_data_bin_end;
+
+static
+void calc_error(int n,
+		 DATA_TYPE POLYBENCH_3D(A,N,N,N,n,n,n))
+{
+    int i;
+    double err = 0;
+    double *accurate = &_binary_data_bin_start;
+    double *test = &(A[0][0][0]);
+
+    /* calculate the mean squared error */
+    for(i = 0; i < n*n*n; i++) {
+        err += (accurate[i] - test[i])*(accurate[i] - test[i]);
+    }
+    err /= n*n*n;
+    printf("error: %f\n", err);
+}
+
 /* Main computational kernel. The whole function will be timed,
    including the call and return. */
 static
@@ -123,6 +143,8 @@ int main(int argc, char** argv)
      by the function call in argument. */
   polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A)));
 
+  calc_error(n, POLYBENCH_ARRAY(A));
+
   /* Be clean. */
   POLYBENCH_FREE_ARRAY(A);