Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • pystencils pystencils
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pycodegen
  • pystencilspystencils
  • Merge requests
  • !251

Use int64 for indexing

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Markus Holzer requested to merge holzer/pystencils:type_boundary into master Jun 07, 2021
  • Overview 0
  • Commits 3
  • Pipelines 3
  • Changes 4

For indexed kernels, int32 is too small for large domain sizes. Thus the coordinates are cast to int64 in this MR to allow huge domain sizes.

As an example of the adaption the generated code for a Neumann boundary is shown. Before:

FUNC_PREFIX void kernel(double * RESTRICT _data_C, uint8_t * RESTRICT const _data_indexField, int64_t const _size_indexField_0, int64_t const _stride_indexField_0)
{
   #pragma omp parallel
   {
      #pragma omp for schedule(static)
      for (int64_t ctr_0 = 0; ctr_0 < _size_indexField_0; ctr_0 += 1)
      {
         const int32_t x = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0]));
         const int32_t y = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0 + 4]));
         
         
         const int64_t cx [] = { 0, 0, 0, -1, 1, -1, 1, -1, 1 };
         const int64_t cy [] = { 0, 1, -1, 0, 0, 1, 1, -1, -1 };
         const int invdir [] = { 0, 2, 1, 4, 3, 8, 7, 6, 5 };
         
         const int32_t dir = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0 + 8]));
         _data_C[x + 11*y] = _data_C[x + 11*y + cx[dir] + 11*cy[dir]];
      }
   }
}

After:

FUNC_PREFIX void kernel(double * RESTRICT _data_C, uint8_t * RESTRICT const _data_indexField, int64_t const _size_indexField_0, int64_t const _stride_indexField_0)
{
   #pragma omp parallel
   {
      #pragma omp for schedule(static)
      for (int64_t ctr_0 = 0; ctr_0 < _size_indexField_0; ctr_0 += 1)
      {
         const int64_t x = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0]));
         const int64_t y = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0 + 4]));
         
         
         const int64_t cx [] = { 0, 0, 0, -1, 1, -1, 1, -1, 1 };
         const int64_t cy [] = { 0, 1, -1, 0, 0, 1, 1, -1, -1 };
         const int64_t invdir [] = { 0, 2, 1, 4, 3, 8, 7, 6, 5 };
         
         const int64_t dir = *((int32_t *)(& _data_indexField[12*_stride_indexField_0*ctr_0 + 8]));
         _data_C[x + 11*y] = _data_C[x + 11*y + cx[dir] + 11*cy[dir]];
      }
   }
}
Edited Jun 07, 2021 by Markus Holzer
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: type_boundary