- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response. I got it running. But just FYI, I had trial versions of MS VS 2010 Pro amd Intel Parallel Studio XE 2011 installed on my home system and I did not see the Intel Performance Libraries option under Configuration properties as shown in the user's guide. But when I got to my office system (which has the full license, it showed up and everything worked well after that). But I encountered a different problem this time. I was asked to evaluate the PARDISO solver. We have input matrices in the coordinate format and I need to convert them to csr format. I used the mkl_dcsrcoo routine but I get a access violation writing locationerror (hexadecimal address). I'm trying to read input from an external text file which has a 5x5 sparse matrix. I'm using a program that reads a matrix in coordinate formatfrom an external input file for a different purpose and I commented out the section of code that I do not need below. The additional include files simply help with the reading. Without the mkl_dcsrcoo routine alone, and removing the comments - the program works just fine. (Also on a side note, for nowI have explicitly given the number of nonzeros and the size but it is supposed to get them from the external file. Also, when I try to simply print the acsr matrix, the first three values are correct and the rest are huge negative values). the program is as follows:
// TestLUSolver.cpp : Defines the entry point for the console application.
//
#include
# include
#include
#include
#include "mkl_spblas.h"
#include "mkl_types.h"
#include "SolveLinear.h"
#include "../Utility/Utility.h"
#include "../IOFiles/DataFile.h"
using namespace std;
int main( int argc, char* argv[] )
{
// Write the header
cout << endl;
cout << "--------------------------------------------------------------------------" << endl;
cout << " " << endl;
cout << " Nexant (C) 2012 " << endl;
cout << " " << endl;
cout << " Linear Solver Test " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "--------------------------------------------------------------------------" << endl;
cout << endl;
MKL_INT info, nnz, m = 5;
nnz = 13;
MKL_INT job [8] = { 1, 1, 1, 0, 1, 0, 0, 0 };
MKL_INT *ia = new int [m+1];
MKL_INT *ja = new int [nnz];
MKL_INT *ir = new int [nnz];
MKL_INT *jc = new int [nnz];
double *acoo = new double [nnz];
double *acsr = new double [nnz];
//string m_DataFileName; // Input file name
// Assign the file name
//m_DataFileName = Utility::SetFileName( "G2_circuit.mtx", "C:\\TestLUSolver" );
const char *m_DataFileName = "C:\\TestLUSolver\\smalltest.mtx";
cout << " Start reading matrix A " << endl;
double start_read = time(0);
//Read the data
DataFile *m_DataFile;
// Create an object to handle the input file
m_DataFile = new DataFile( m_DataFileName );
// Read the file into a buffer and break it into records
string *srec = 0;
string *ssrec;
string *sfield;
long retcode = m_DataFile->Read();
if ( retcode == -1 )
{
delete m_DataFile;
m_DataFile = 0;
return( 0 );
}
// Get the first record
srec = m_DataFile->MoveToNextLine( );
// Break the current record into sub-records
retcode = m_DataFile->BreakCurrentLine( );
// Get the next sub-record
ssrec = m_DataFile->MoveToNextSubRecord( );
// Break the current sub-record into fields
retcode = m_DataFile->BreakCurrentSubRecord( );
//Read Number of Rows
sfield = m_DataFile->MoveToNextField( );
long m_NRows = Utility::string2long(*sfield);
// long m_NumberEquation = Utility::string2long(*sfield);
//Read Number of Columns
sfield = m_DataFile->MoveToNextField( );
long m_NColumns = Utility::string2long(*sfield);
//Read Number of nonzeros
sfield = m_DataFile->MoveToNextField( );
long offDiagElements = Utility::string2long(*sfield);
/*
long offDiagFactors = 20*offDiagElements;
long sparseOverlayIndex = 130;
long maxBuses = m_NRows + m_NColumns;
long maxNumEquation = maxBuses;*/
/*
// Definition of size elements needed by the sparse Linear solver
long maxBranches = maxLines + maxTrafos + maxZeroImpBranches + maxSeriesReact;
long offDiagElements = maxBranches + 2*maxTrafos + maxGenerators + maxRegBusVolt + maxStatVars;
long maxNumEquation = maxBuses + maxTrafos + maxGenerators + maxStatVars;
// Definition of Network Elements dimensions
long maxGenerators = 2500;
long maxLines = 7000;
long maxTrafos = 2100;
long maxRegBusVolt = 4400;
long maxStatVars = 100;
long maxSeriesReact = 100;
long maxZeroImpBranches = 250; */
/*// Definition of Linear Equation parameters
long * m_Row;
long * m_Column;
double * m_DiagonalValues;
double * m_UpperDiagValues;
double * m_LowerDiagValues;
double * m_RightHandSide;
double * m_SolutionVector;
long m_NumberOffDiagonal;*/
// Definition of an example: number of Equations can not be larger than maxNumEquation and number of off diagonal elements
// can not be greater than offDiagFactors
/*
m_NumberOffDiagonal = offDiagElements;
m_Row = new long [ offDiagFactors ];
m_Column = new long [ offDiagFactors ];
m_DiagonalValues = new double [ m_NRows ]; // or we can use m_DiagonalValues = new double
m_LowerDiagValues = new double [ offDiagFactors ];
m_UpperDiagValues = new double [ offDiagFactors ];*/
long k = 0;
do
{
// Get the first recodr record
srec = m_DataFile->MoveToNextLine( );
if ( *srec == "#" )
break;
// Break the current record into sub-records
retcode = m_DataFile->BreakCurrentLine( );
// Get the next sub-record
ssrec = m_DataFile->MoveToNextSubRecord( );
// Break the current sub-record into fields
retcode = m_DataFile->BreakCurrentSubRecord( );
//Read the row index
sfield = m_DataFile->MoveToNextField( );
long row = Utility::string2long(*sfield);
//Read the column index
sfield = m_DataFile->MoveToNextField( );
long column = Utility::string2long(*sfield);
//Read the value
sfield = m_DataFile->MoveToNextField( );
double value = Utility::string2double(*sfield);
// Adding dummy values for use in format conversion
if ( row == column )
{
// m_DiagonalValues[row-1] = value;
acoo
acsr
ir
jc
ja
}
else if (row < column)
{
// m_LowerDiagValues
// m_UpperDiagValues
acoo
acsr
//m_Row
// m_Column
ir
jc
ja
k = k + 1;
}
/* else
{
m_LowerDiagValues
m_UpperDiagValues
m_Row
//acoo
m_Column
//ir
//jc
//ja
k = k + 1;
} */
} while ( true );
for (int z = 0; z <13; z++)
cout << acoo
mkl_dcsrcoo (job, &m, acsr, ja, ia, &nnz, acoo, ir, jc, &info);
/*
m_RightHandSide = new double [ m_NRows ];
for ( long i=0;i
m_RightHandSide = 1;
m_NumberOffDiagonal = k;
cout << " Finish reading matrix A " << endl;
double end_read = time (0);
double elapsed_read = end_read - start_read;
cout << "Time taken to read was " << elapsed_read << "seconds" << endl;
cout << " Start x = A/b calculation " << endl;
double start_solve = time (0);
// Construction and Calling method to the Linear solver Wrapper, it retrieves the solution vector
SolveLinear *m_SolveLinear = new SolveLinear();
m_SolutionVector = m_SolveLinear -> Calculate( m_Row, m_Column, m_NRows, m_NumberOffDiagonal,
m_DiagonalValues, m_LowerDiagValues, m_UpperDiagValues, m_RightHandSide ,
maxNumEquation, maxBuses, offDiagFactors, sparseOverlayIndex );
cout << " Finish x = A/b calculation " << endl;
double end_solve = time (0);
double elapsed_solve = end_solve - start_solve;
cout << "Time taken to solve was " << elapsed_solve << "seconds" << endl;
cout << " Start saving the solution " << endl;
double start_output = time (0);
// Open the output file
fstream output;
string outFilename = "solution.dat";
string outPath ="C:\\Users\\smonsingh\\Desktop";
bool outStat = Utility::OpenFile( outFilename,
outPath,
output,
IOS::out );
// Check if the debug file can be opened
if ( outStat )
{
for (long i=0; i
{
// Write to the file
output << m_SolutionVector << endl;
}
// Close the file
output.close();
}
cout << " Finish saving the solution " << endl;
double end_output = time (0);
double elapsed_output = end_output - start_output;
cout << "Time taken to print the solution was " << elapsed_output << "seconds" << endl;
// Delete the dynamic vectors
if ( m_Row )
delete [] m_Row;
if ( m_Column )
delete [] m_Column;
if ( m_DiagonalValues )
delete [] m_DiagonalValues;
if ( m_UpperDiagValues )
delete [] m_UpperDiagValues;
if ( m_LowerDiagValues )
delete [] m_LowerDiagValues;
if ( m_RightHandSide )
delete [] m_RightHandSide;
if ( m_SolutionVector )
delete [] m_SolutionVector;
if ( m_DataFile )
delete m_DataFile;
delete m_SolveLinear;*/
system ("PAUSE");
return 0;
}
// SolveLinear *m_SolveLinear = new SolveLinear();
//
// m_SolveLinear ->Populate();
// m_SolveLinear ->Calculate();
// delete m_SolveLinear;
// return 0;
I inserted the commented section as well just to show you the exact program I'm trying to run. Could you please help me out with this? I know I have sufficient memory and access priveleges.
Thanks,
Sunil

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page