Bug Summary

File:OMCompiler/Compiler/runtime/./HpcOmSchedulerExt.cpp
Warning:line 79, column 5
Value stored to 'returnval' is never read

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1#include "TaskGraphResultsCmp.h"
2#include "omc_config.h"
3#include <iostream>
4
5#if USE_PATOH0
6#include "patoh.h"
7#endif
8
9#if USE_METIS1
10#include "metis.h"
11#endif
12
13using namespace std;
14
15
16
17void* HpcOmSchedulerExtImpl__readScheduleFromGraphMl(const char *filename)
18{
19 void *res = mmc_mk_nil()((void*)((char*)(&(mmc_nil).header) + 3));
20 std::string errorMsg = std::string("");
21 Graph g;
22 GraphMLParser parser;
23
24 if (!GraphMLParser::CheckIfFileExists(filename))
25 {
26 std::cerr << "File " << filename << " not found" << std::endl;
27 errorMsg = "File '";
28 errorMsg += std::string(filename);
29 errorMsg += "' does not exist";
30 res = mmc_mk_cons(mmc_mk_scon(errorMsg.c_str()), mmc_mk_nil()((void*)((char*)(&(mmc_nil).header) + 3)));
31 return res;
32 }
33
34 parser.ParseGraph(&g, filename,NodeComparator(&NodeComparator::CompareNodeNamesInt), &errorMsg);
35
36 std::list<Node*> sortedNodeList = std::list<Node*>(g.nodes.begin(), g.nodes.end());
37 sortedNodeList.sort(NodeComparator(&NodeComparator::CompareNodeTaskIdsInt));
38
39 for (std::list<Node*>::iterator iter = sortedNodeList.begin(); iter != sortedNodeList.end(); iter++) {
40 //std::cerr << "Node " << (*iter)->taskId << " th " << atoi((*iter)->threadId.substr(3).c_str()) << std::endl;
41
42 if((*iter)->threadId.size() < 3)
43 continue;
44 res = mmc_mk_cons(mmc_mk_icon(atoi((*iter)->threadId.substr(3).c_str())), res);
45 }
46 return res;
47}
48
49#if USE_METIS1
50void* HpcOmSchedulerExtImpl__scheduleMetis(int* xadj, int* adjncy, int* vwgt, int* adjwgt, int xadjCount, int adjncyCount, int nparts)
51{
52 void *res = mmc_mk_nil()((void*)((char*)(&(mmc_nil).header) + 3));
53 int nvert=xadjCount-1;
54 idx_t met_nvtxs=xadjCount-1;
55 idx_t met_ncon=1;
56 //double * part=new double[nvert];
57 idx_t * met_xadj=new idx_t[nvert+1]; //={0,2,5,8,11,13,16,20,24,28,31,33,36,39,42,44};
58 idx_t * met_adjncy=new idx_t[xadj[nvert]];//={1,5,0,2,6,1,3,7,2,4,8,3,9,0,6,10,1,5,7,11,2,6,8,12,3,7,9,13,4,8,14,5,11,6,10,12,2,7,11,13,8,12,14,9,13};
59 idx_t * met_vwgt=new idx_t[nvert]; //={0,2,5,8,11,13,16,20,24,28,31,33,36,39,42,44};
60 idx_t * met_adjwgt=new idx_t[xadj[nvert]];
61 idx_t met_objval;
62 idx_t * met_part=new idx_t[nvert];
63 idx_t met_nparts=nparts;
64 int returnval;
65
66 for(int i=0; i<nvert; i++) {
67 met_xadj[i]=xadj[i];
68 met_vwgt[i]=vwgt[i];
69// cout<<met_xadj[i]<<" "<<met_vwgt[i]<<endl;
70 }
71 met_xadj[nvert]=xadj[nvert];
72// cout<<"test: "<<met_xadj[nvert+4]<<endl;
73 for(int i=0; i<xadj[nvert]; i++) {
74 met_adjncy[i]=adjncy[i];
75 met_adjwgt[i]=adjwgt[i];
76// cout<<met_adjncy[i]<<" "<<met_adjwgt[i]<<endl;
77 }
78 int * result=new int[nvert];
79 returnval=METIS_PartGraphKway(&met_nvtxs,&met_ncon,met_xadj,met_adjncy,met_vwgt,NULL__null,met_adjwgt,&met_nparts,NULL__null,NULL__null,NULL__null,&met_objval,met_part);
Value stored to 'returnval' is never read
80 for(int i=nvert-1; i>=0; i--) {
81 result[i]=met_part[i]+1;
82 res = mmc_mk_cons(mmc_mk_icon(result[i]),res);
83 }
84 delete[] met_xadj;
85 delete[] met_adjncy;
86 delete[] met_vwgt;
87 delete[] met_adjwgt;
88 delete[] met_part;
89 return res;
90}
91#elif USE_PATOH0
92void* HpcOmSchedulerExtImpl__scheduleMetis(int* vwgts, int* eptr, int* eint, int* hewgts, int vwgtsNelts, int eptrNelts, int nparts)
93{
94 void *res = mmc_mk_nil()((void*)((char*)(&(mmc_nil).header) + 3));
95 int * result=new int[vwgtsNelts];
96 PaToH_Parameters args;
97 int c, n, nconst, cut, *partweights;
98 PaToH_Initialize_Parameters(&args, PATOH_CONPART, PATOH_SUGPARAM_DEFAULT);
99 args._k = nparts;
100 partweights = new int[nparts];
101 PaToH_Alloc(&args, vwgtsNelts, eptrNelts-1, 1, vwgts, NULL__null, eptr, eint);
102 PaToH_Part(&args, vwgtsNelts, eptrNelts-1, 1, 0, vwgts, NULL__null,eptr, eint, NULL__null, result, partweights, &cut);
103 PaToH_Free();
104
105
106 for(int i=vwgtsNelts-1; i>=0; i--) {
107 res = mmc_mk_cons(mmc_mk_icon(result[i]+1),res);
108 }
109 cout<<endl;
110 delete [] result;
111 delete [] partweights;
112 return res;
113}
114#else
115void* HpcOmSchedulerExtImpl__scheduleMetis(int* vwgts, int* eptr, int* eint, int* hewgts, int vwgtsNelts, int eptrNelts, int nparts)
116{
117 std::cerr<<"OpenModelica was not compiled with PATOH or METIS."<<std::endl;
118 return mmc_mk_nil()((void*)((char*)(&(mmc_nil).header) + 3));
119}
120#endif