Skip to content

Crash when re-initialized after finalized #525

@lschork2

Description

@lschork2

When bli_finalize() is called, then it is not possible to re-initialize the library with bli_init(). Doing so causes a crash in the next call to bli_dgemm(). The code snippet below is a working example to reproduce this.

It would be useful to allow re-initializing the library after it has been finalized. In our application we would like to deallocate the memory after part of the computation is finished, and reallocate later if needed for another part.

#include "blis.h"

static void do_work()
{
  enum {DIM_M = 4, DIM_N = 5, DIM_K = 3};
  double a[DIM_M*DIM_K], b[DIM_K*DIM_N], c[DIM_M*DIM_N];
  double zero = 0.0, one = 1.0, alpha = 2.0, beta = 3.0;
  const int m = DIM_M;
  const int n = DIM_N;
  const int k = DIM_K;
  const int csa = m;
  const int csb = k;
  const int csc = m;
  const int rsa = 1;
  const int rsb = 1;
  const int rsc = 1;

  bli_drandm(0, BLIS_DENSE, m, k, a, rsa, csa);
  bli_dsetm(BLIS_NO_CONJUGATE, 0, BLIS_NONUNIT_DIAG, BLIS_DENSE,
            k, n, &one, b, rsb, csb);
  bli_dsetm(BLIS_NO_CONJUGATE, 0, BLIS_NONUNIT_DIAG, BLIS_DENSE,
            m, n, &zero, c, rsc, csc);

  bli_dgemm(BLIS_NO_TRANSPOSE, BLIS_NO_TRANSPOSE,
            m, n, k, &alpha, a, rsa, csa, b, rsb, csb,
            &beta, c, rsc, csc);
  bli_dprintm("c: after gemm", m, n, c, rsc, csc, "%4.1f", "");
}

int main()
{

  bli_init();
  do_work();
  bli_finalize();

  bli_init();
  do_work();
  bli_finalize();

  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions