void CudaOutliner::setKernelParams(int dimension, SgStatement* func_call_stmt, SgScopeStatement* scope) { /* dim3 threads(chunksizeX, chunksizeY); int numBlocksX = n/ chunksizeX; int numBlocksY = n/ (chunksizeY*numRows); dim3 grid(numBlocksX, numBlocksY); */ SgInitializedName* arg1 = buildInitializedName(SgName("BLOCKDIM_X"), buildIntType()); SgInitializedName* arg2 = buildInitializedName(SgName("BLOCKDIM_Y"), buildIntType()); SgType* dim3_t = buildOpaqueType("dim3", scope); SgExprListExp* exprList = buildExprListExp(); //appendArg(exprList, arg1); //ppendArg(exprList, arg2); SgFunctionParameterList * paraList = buildFunctionParameterList(); appendArg(paraList, arg1); appendArg(paraList, arg2); SgMemberFunctionDeclaration * funcdecl = buildNondefiningMemberFunctionDeclaration ("threads", dim3_t, paraList); SgConstructorInitializer* constr = new SgConstructorInitializer(funcdecl, exprList, dim3_t, false, false, false, false ); string dimBlock = MintTools::generateBlockDimName(func_call_stmt); SgVariableDeclaration * dim_blocks_var_decl = buildVariableDeclaration(dimBlock, dim3_t, constr); /* string dimGrid = generateGridDimName(func_call_stmt); SgVariableDeclaration * dim_grid_var_decl = buildVariableDeclaration(dimGrid, dim3_t); */ cout<< dim_blocks_var_decl->unparseToString ()<< endl ; }
/* * Discover this function's kernel interface, including I/O and functions * needed. */ void FunctionInterface::analyze() { string msg = "Analyzing function " + NAME(function); DEBUG(TOOL, msg); status = IN_PROGRESS; //Add inputs to our list SgInitializedNamePtrList inputs = function->get_parameterList()->get_args(); SgInitializedNamePtrList::const_iterator inputIt; for(inputIt = inputs.begin(); inputIt != inputs.end(); inputIt++) { msg = "\tfound input " + NAME(*inputIt); DEBUG(TOOL, msg); addInput(*inputIt); FunctionTraversal::checkVariableType((*inputIt)->get_type(), this); } //Add return value to our list (denoted by special marker name "__retval__") SgType* returnType = function->get_orig_return_type(); if(!isSgTypeVoid(returnType)) { msg = "\tfound output of type " + get_name(returnType); DEBUG(TOOL, msg); SgInitializedName* returnVal = buildInitializedName(RETVAL_NAME, returnType); addOutput(returnVal); FunctionTraversal::checkVariableType(returnType, this); } //Traverse function FunctionTraversal ft(this); ft.traverse(function, preorder); //Incorporate sub-calls //TODO do side-effect checking here for sub-calls? set<FunctionInterface*>::const_iterator funcIt; for(funcIt = calledFunctions.begin(); funcIt != calledFunctions.end(); funcIt++) { if((*funcIt)->getStatus() == NOT_ANALYZED) (*funcIt)->analyze(); combineGlobalInputs((*funcIt)->getGlobalInputs()); combineGlobalOutputs((*funcIt)->getGlobalOutputs()); combineCalledFunctions((*funcIt)->getCalledFunctions()); } status = ANALYZED; }
//! Creates an SgInitializedName. static SgInitializedName * createInitName (const string& name, SgType* type, SgDeclarationStatement* decl, SgScopeStatement* scope, SgInitializer* init = 0) { SgName sg_name (name.c_str ()); // DQ (2/24/2009): Added assertion. ROSE_ASSERT(name.empty() == false); SgInitializedName* new_name = buildInitializedName (sg_name, type); ROSE_ASSERT (new_name); // Insert symbol if (scope) { SgVariableSymbol* new_sym = new SgVariableSymbol (new_name); scope->insert_symbol (sg_name, new_sym); } return new_name; }