Skip to content

Support user-defined allocation functions #3

Description

@ahueck

TypeART should be configurable for user-defined allocation (and deallocation) functions

Consider the AMG multi grid solver.

AMG uses macros for memory allocation, e.g., a calloc-like implementation:

#define hypre_CTAlloc(type, count) \
( (type *)hypre_CAlloc((unsigned int)(count), (unsigned int)sizeof(type)) )

In turn the called function looks approximately like this:

char* hypre_CAlloc(int count, int elt_size) {
  char* ptr;
  int size = count * elt_size;

  ptr = calloc(count, elt_size);

  return ptr;
}

The defect:

Assume a call like:

 double* a = hypre_CTAlloc(double, num_variables);
  1. Our static pass is not aware of this macro, it instead finds the C calloc.
  2. Thus, it deduces the char* type for that calloc, which is put into our runtime.
  3. The subsequent cast of the char* returned by hypre_CAlloc to double is not found by our current implementation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlong-termIssues will be addressed sometime the future

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions