File: test_c.c

package info (click to toggle)
haskell-futhark 0.25.32-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 277
file content (29 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (2)
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
#include "c.h"
#include <assert.h>
#include <stdio.h>

// Test repeated creations and destructions of context.  If the
// context does not clean up properly after itself, then it is likely
// that this test will fail to run.

static const int runs = 100;
static const int alloc_per_run = 1024*1024*1024; // 1GiB

int main() {
  for (int i = 0; i < runs; i++) {
    struct futhark_context_config *cfg = futhark_context_config_new();
    struct futhark_context *ctx = futhark_context_new(cfg);

    int err;

    struct futhark_i64_1d *arr;
    err = futhark_entry_main(ctx, &arr, alloc_per_run/8);
    assert(err == 0);

    err = futhark_free_i64_1d(ctx, arr);
    assert(err == 0);

    futhark_context_free(ctx);
    futhark_context_config_free(cfg);
  }
}