File: main.c

package info (click to toggle)
eztrace 2.0%2Brepack-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,132 kB
  • sloc: ansic: 23,501; perl: 910; sh: 857; cpp: 771; makefile: 696; fortran: 327; f90: 320; python: 57
file content (43 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* -*- c-file-style: "GNU" -*- */
/*
 * Copyright (C) CNRS, INRIA, Université Bordeaux 1, Télécom SudParis
 * See COPYING in top-level directory.
 */

/* simple program that calls the libexample library */

#include <stdlib.h>
#include <stdio.h>
#include "example.h"

#define SIZE (1024*1024)

int main(int argc, char**argv) {
  double *double_array = malloc(sizeof(double) * SIZE);
  int *int_array = malloc(sizeof(int) * SIZE);
  int i;

  /* initialize the array with something */
  for (i = 0; i < SIZE; i++) {
    double_array[i] = (i * i) / 31;
  }

  double sum_double = example_function1(double_array, SIZE);

  /* initialize the array with something */
  for (i = 0; i < SIZE; i++) {
    double_array[i] = (i * i) / 31;
  }

  double static_sum_double = example_static_function(double_array, SIZE);

  for (i = 0; i < SIZE; i++) {
    int_array[i] = i % 17;
  }
  int sum_int = example_function2(int_array, SIZE);

  printf("sum double = %lf\n", sum_double);
  printf("static sum double = %lf\n", static_sum_double);
  printf("sum int = %d\n", sum_int);
  return 0;
}