aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/nvhost_priv.h
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-04-08 13:33:28 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2024-04-08 14:02:07 -0400
commitac60151ea0a4a1f3882fde3c486af870029b7977 (patch)
tree4a32ead49a987030cb4222c687b23bc1f23d4d34 /include/os/linux/nvhost_priv.h
parent3aab3c220f3f0bcc3d3d58d0daf6fd6acf1819e2 (diff)
Rework LCE<->PCE and GRCE->LCE configuration printing APIarchive/saman63-wip
Rather than up to dozens of individual files exposing part of each copy engine's configuration, have one file which exposes a unified view of the full topology. Example new output on RTX 2080 Ti: $ cat /proc/gpu0/copy_topology GRCE0 -> LCE04 GRCE1 -> LCE03 LCE02 -> PCE02 LCE03 -> PCE03 LCE04 -> PCE01 Old output: $ tail -n 1 /proc/gpu0/lce_for_pce* ==> /proc/gpu0/lce_for_pce0 <== 0xf ==> /proc/gpu0/lce_for_pce1 <== 0x4 ==> /proc/gpu0/lce_for_pce2 <== 0x2 ==> /proc/gpu0/lce_for_pce3 <== 0x3 $ tail -n 1 /proc/gpu1/shared_lce_for_grce* ==> /proc/gpu0/shared_lce_for_grce0 <== 0x4 ==> /proc/gpu0/shared_lce_for_grce1 <== 0x3 Specifically: - Add `copy_topology` API - Remove `shared_lce_for_grce#` and `lce_for_pce#` APIs - Move logic from `nvdebug_entry.c` to `copy_topology_procfs.c` - Do not print PCE or Shared LCE configuration if flagged absent - Refer to LCE0 and LCE1 as GRCE0 and GRCE1 - Print by LCE ID, which is move helpful when attempting to trace how a given copy runlist maps to a physical copy engine. - Document two errata with CE registers Tested working on Pascal Integrated, Pascal, Volta Integrated Volta, Turing, and Ampere Integrated on Linux 4.9 through 5.10.
Diffstat (limited to 'include/os/linux/nvhost_priv.h')
0 files changed, 0 insertions, 0 deletions
id='n94' href='#n94'>949596979899

/* compile with 
rm liblagrcv.a
gcc -c lagrcv.cpp
ar rc liblagrcv.a lagrcv.o
ranlib liblagrcv.a
mex7 calcTextureMex.cc -L/home/ikkjin/LagrMatlab/opencv/matlab -llagrcv -I/home/ikkjin/LagrMatlab/opencv/matlab/
*/

#include "mex.h"
#include "lagrcv.h"
#include <stdio.h>
#include <math.h>

#ifndef MAX_LEVEL
#	define MAX_LEVEL 5
#endif
// TODO: add number of corners parameter
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
  // usage: [newFeaturePnt validFlag ] = 
  //   calcOptFlowPyrLKMex(Ipyr, IdxPyr, IdyPyr, Jpyr, featurePnt, winSize, accuracy_th, max_iter)
  // Ipyr, IdxPyr, IdyPyr, Jpyr: levelx1 size cell.
  // featurePnt 2xn int
  // winSize c_level int
  // c_xx c_xy c_yy: image size double*
  // image must be double

  
  const mxArray* imgArray;
  int* imdims;
  const int *curImgDims;
  const int *nFeatures;
  //double **iP, **iDxP, **iDyP, **jP; 
  double *iP[MAX_LEVEL], *iDxP[MAX_LEVEL], *iDyP[MAX_LEVEL], *jP[MAX_LEVEL];
  double *fPnt, *newFPnt; 
  char* valid;
  double accuracy_th;
  int winSize, max_iter;
  const int *cellDims = mxGetDimensions(prhs[0]);

  if (nrhs > 6) {
  	accuracy_th=(double)mxGetScalar(prhs[6]);
  	max_iter=(int)mxGetScalar(prhs[7]);
  }
	
  winSize = (int)mxGetScalar(prhs[5]);
  fPnt=(double*)mxGetPr(prhs[4]);
  nFeatures=mxGetDimensions(prhs[4]);

  imdims=(int*)malloc(sizeof(int)*cellDims[0]*2);
  //iP=(double**)malloc(sizeof(double*)*cellDims[0]);
  //iDxP=(double**)malloc(sizeof(double*)*cellDims[0]);
  //iDyP=(double**)malloc(sizeof(double*)*cellDims[0]);
  //jP=(double**)malloc(sizeof(double*)*cellDims[0]);

  for(int i=0; i<cellDims[0]; i++){
        //imgArray=mxGetCell(prhs[0],i);
  	//curImgDims = mxGetDimensions(imgArray);
  	curImgDims = mxGetDimensions(mxGetCell(prhs[0],i));
  	imdims[i*2+0]= curImgDims[0];
  	imdims[i*2+1]= curImgDims[1];
  	//imdims[i][1] = curImgDims[1];

  	iP[i]= (double*)mxGetPr(mxGetCell(prhs[0],i));
  	iDxP[i]= (double*)mxGetPr(mxGetCell(prhs[1],i));
  	iDyP[i]= (double*)mxGetPr(mxGetCell(prhs[2],i));
  	jP[i]= (double*)mxGetPr(mxGetCell(prhs[3],i));
  }

  plhs[0] = mxCreateNumericMatrix(nFeatures[0], nFeatures[1], mxDOUBLE_CLASS, mxREAL);
  plhs[1] = mxCreateNumericMatrix(1, nFeatures[1], mxUINT8_CLASS, mxREAL);

  newFPnt = (double*)mxGetPr(plhs[0]);
  valid = (char*)mxGetPr(plhs[1]);

  //idx convert from matlab to c
  for(int i=0; i<nFeatures[1]; i++){
	fPnt[i*2]=fPnt[i*2]-1;
	fPnt[i*2+1]=fPnt[i*2+1]-1;
	valid[i]=1;
  }
  if(nrhs>6){
	calcPyrLKTrack( iP, iDxP, iDyP, jP, imdims, cellDims[0], fPnt, nFeatures[1], winSize, 
	 newFPnt, valid, accuracy_th, max_iter); 
  }else{	
  	calcPyrLKTrack( iP, iDxP, iDyP, jP, imdims, cellDims[0], fPnt, nFeatures[1], winSize,
	 newFPnt, valid); 
  }
  //idx convert from matlab to c
  for(int i=0; i<nFeatures[1]*2; i++){
	fPnt[i]=fPnt[i]+1;
  	newFPnt[i]=newFPnt[i]+1;
  }
  free(imdims);
  //free(iP);
  //free(iDxP);
  //free(iDyP);
  //free(jP);
}