help with .sln file with Visual Studio 2008 and acml Blas

Open forum for general discussions relating to PLASMA.

help with .sln file with Visual Studio 2008 and acml Blas

Postby andy » Wed Dec 09, 2009 1:47 am

Hi,

I'm trying to use the AMD math libraries for BLAS (version 4.3.0) combined with the PLASMA library. I've included my compiler and linker settings along with the error output from the compiler. The source is also included at the bottom.

I am trying to build a simple console application on windows xp using Visual studio v 2008. I'd like to make a solution (.sln file) rather than use a makefile. I've studied the example makefile and tried to duplicate it but no success. I've tried many variations of link and compile options. In my latest attempt the compiler settings are:

/Od /I "..\..\Plasma\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MT /Yu"stdafx.h" /Fp"Debug\TestPLASMA.pch" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

and the latest link options are:

/OUT:"D:\Andy\CCProjects\TestPLASMA\Debug\TestPLASMA.exe" /INCREMENTAL /NOLOGO /LIBPATH:"../../Plasma/lib" /LIBPATH:"../../AMD/acml4.3.0/ifort32/lib" /MANIFEST /MANIFESTFILE:"Debug\TestPLASMA.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"MSVCRT.lib" /NODEFAULTLIB:"MSVCRTd.lib" /DEBUG /PDB:"D:\Andy\CCProjects\TestPLASMA\Debug\TestPLASMA.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT libacml.lib libmmd.lib plasma.lib coreblas.lib cblas.lib corelapack.lib libirc.lib libmmt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

the compile errors are:

1>------ Build started: Project: TestPLASMA, Configuration: Debug Win32 ------
1>Linking...
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libacml.lib(acmlmallocc.obj) : warning LNK4217: locally defined symbol _malloc imported in function _acmlmallocc_
1>libacml.lib(acmlcpuid.obj) : warning LNK4217: locally defined symbol _malloc imported in function _acmlcpuid
1>libacml.lib(acmlmallocc.obj) : warning LNK4217: locally defined symbol _free imported in function _acmlfreec_
1>libacml.lib(acmlcpuid.obj) : warning LNK4049: locally defined symbol _free imported
1>libacml.lib(acmlcpuid.obj) : warning LNK4217: locally defined symbol _strncmp imported in function _GetCacheInfo
1>libacml.lib(acmlcpuid.obj) : warning LNK4217: locally defined symbol _fprintf imported in function _PrintTLBTYPE
1>libacml.lib(acmlcpuid.obj) : warning LNK4217: locally defined symbol _printf imported in function _PrintTLBTYPE
1>TestPLASMA.obj : error LNK2019: unresolved external symbol _dlarnv referenced in function _wmain
1>TestPLASMA.obj : error LNK2019: unresolved external symbol _dlange referenced in function "int __cdecl check_solution(int,int,int,double *,int,double *,double *,int)" (?check_solution@@YAHHHHPANH00H@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>D:\Andy\CCProjects\TestPLASMA\Debug\TestPLASMA.exe : fatal error LNK1120: 4 unresolved externals
1>Build log was saved at "file://d:\Andy\CCProjects\TestPLASMA\Debug\BuildLog.htm"
1>TestPLASMA - 5 error(s), 9 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Can you help me?

Possibly a simple .sln file with the steps taken to create it would be most helpful. It would be nice if that was in the installation.

Thanks,
Andrew Roberts

============================================================================
============================================================================
My source file is copied from your an in the install. Here it is:
====================================
// TestPLASMA.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cblas.h>
#include <plasma.h>
#include "../src/lapack.h"
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
int check_solution(int, int, int, double*, int, double*, double*, int);
int IONE=1;
int ISEED[4] = {0,0,0,1}; /* initial seed for dlarnv() */
int _tmain(int argc, _TCHAR* argv[])
{
//example copied from example_dgels.c
int cores = 2;
int M = 15;
int N = 10;
int LDA = 15;
int NRHS = 5;
int LDB = 15;
int K = min(M, N);
int info;
int info_solution;
int i,j;
int LDAxN = LDA*N;
int LDBxNRHS = LDB*NRHS;
double *A1 = (double *)malloc(LDA*N*sizeof(double));
double *A2 = (double *)malloc(LDA*N*sizeof(double));
double *B1 = (double *)malloc(LDB*NRHS*sizeof(double));
double *B2 = (double *)malloc(LDB*NRHS*sizeof(double));
double *T;
/* Check if unable to allocate memory */
if ((!A1)||(!A2)||(!B1)||(!B2)){
printf("Out of Memory \n ");
exit(0);
}
/* Plasma Initialization */
PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);
/* Allocate T */
PLASMA_Alloc_Workspace_dgels(M, N, &T);
/* Initialize A1 and A2 */
dlarnv(&IONE, ISEED, &LDAxN, A1);
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
A2[LDA*j+i] = A1[LDA*j+i] ;
/* Initialize B1 and B2 */
dlarnv(&IONE, ISEED, &LDBxNRHS, B1);
for (i = 0; i < M; i++)
for (j = 0; j < NRHS; j++)
B2[LDB*j+i] = B1[LDB*j+i] ;
/* PLASMA DGELS */
info = PLASMA_dgels(PlasmaNoTrans, M, N, NRHS, A2, LDA, T, B2, LDB);
/* Check the solution */
info_solution = check_solution(M, N, NRHS, A1, LDA, B1, B2, LDB);
if ((info_solution != 0)|(info != 0))
printf("-- Error in DGELS example ! \n");
else
printf("-- Run of DGELS example successful ! \n");
free(A1); free(A2); free(B1); free(B2); free(T);
PLASMA_Finalize();
exit(0);
return 0;
}
/*--------------------------------------------------------------
* Check the solution
*/
int check_solution(int M, int N, int NRHS, double *A1, int LDA, double *B1, double *B2, int LDB)
{
int info_solution;
double Rnorm, Anorm, Xnorm, Bnorm;
char norm='I';
double alpha, beta;
double *work = (double *)malloc(max(M, N)* sizeof(double));
double eps;
eps = dlamch("Epsilon");
alpha = 1.0;
beta = -1.0;
Anorm = dlange(&norm, &M, &N, A1, &LDA, work);
Xnorm = dlange(&norm, &M, &NRHS, B2, &LDB, work);
Bnorm = dlange(&norm, &N, &NRHS, B1, &LDB, work);
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, NRHS, N, (alpha), A1, LDA, B2, LDB, (beta), B1, LDB);
if (M >= N) {
double *Residual = (double *)malloc(M*NRHS*sizeof(double));
memset((void*)Residual, 0, M*NRHS*sizeof(double));
cblas_dgemm(CblasColMajor, CblasTrans, CblasNoTrans, N, NRHS, M, (alpha), A1, LDA, B1, LDB, (beta), Residual, M);
Rnorm = dlange(&norm, &M, &NRHS, Residual, &M, work);
free(Residual);
}
else {
double *Residual = (double *)malloc(N*NRHS*sizeof(double));
memset((void*)Residual, 0, N*NRHS*sizeof(double));
cblas_dgemm(CblasColMajor, CblasTrans, CblasNoTrans, N, NRHS, M, (alpha), A1, LDA, B1, LDB, (beta), Residual, N);
Rnorm = dlange(&norm, &N, &NRHS, Residual, &N, work);
free(Residual);
}
printf("============\n");
printf("Checking the Residual of the solution \n");
printf("-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||)_oo.N.eps) = %e \n",Rnorm/((Anorm*Xnorm+Bnorm)*N*eps));
if (isnan(Rnorm / ((Anorm * Xnorm + Bnorm) * N * eps)) || (Rnorm / ((Anorm * Xnorm + Bnorm) * N * eps) > 10.0) ) {
printf("-- The solution is suspicious ! \n");
info_solution = 1;
}
else {
printf("-- The solution is CORRECT ! \n");
info_solution= 0 ;
}
free(work);
return info_solution;
}
andy
 
Posts: 4
Joined: Sat Sep 26, 2009 12:34 am

Re: help with .sln file with Visual Studio 2008 and acml Blas

Postby yarkhan » Thu Dec 10, 2009 1:16 pm

Hi,
I have been able to compile your test program using a MS Visual Studio solution file, and I am including some of the details here.

FIrstly, a few comments on your email.
- The warnings that you get are expected; PLASMA is compiled as a static library, so some system calls seem are included both via PLASMA and via the ACML library. This is why the /FORCE flag is needed, otherwise MSVS refuses to link code with multiple definitions.
- The header "lapack.h" contains the conversion allowing the C interface to call Fortran routines, but you need to specify "/DUPCASE" or "/DADD_" to tell it what the conversion should be for your compiler. In this case, "/DUPPER" was required to correctly find "dlange" and "dlarnv".
- I needed to statically link the library, so either "/MT" or "/MTd" needed to be used (rather than the standard "/MD" or "/MDd")

For the Debug build, the command lines generated are
Compile: /Od /I "C:\Users\yarkhan\Documents\TESTING\PLASMA\include" /D "UPCASE" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt
Linker: /OUT:"C:\Users\yarkhan\Documents\TESTING\PLASMA\testPLASMA\testPLASMA\Debug\testPLASMA.exe" /NOLOGO /LIBPATH:"C:\Users\yarkhan\Documents\TESTING\PLASMA\lib" /LIBPATH:"C:\AMD\acml4.3.0\ifort32\lib" /MANIFEST /MANIFESTFILE:"Debug\testPLASMA.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"MSVCRT.LIB" /NODEFAULTLIB:"MSVCRTD.LIB" /DEBUG /PDB:"c:\Users\yarkhan\Documents\TESTING\PLASMA\testPLASMA\testPLASMA\Debug\testPLASMA.pdb" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT plasma.lib coreblas.lib cblas.lib corelapack.lib libacml.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

For the Release build
Compile: /O2 /Oi /GL /I "C:\Users\yarkhan\Documents\TESTING\PLASMA\include" /D "UPCASE" /D "_MBCS" /FD /EHsc /MT /Gy /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt
Linker: /OUT:"C:\Users\yarkhan\Documents\TESTING\PLASMA\testPLASMA\testPLASMA\Release\testPLASMA.exe" /NOLOGO /LIBPATH:"C:\Users\yarkhan\Documents\TESTING\PLASMA\lib" /LIBPATH:"C:\AMD\acml4.3.0\ifort32\lib" /MANIFEST /MANIFESTFILE:"Release\testPLASMA.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"MSVCRT.LIB" /DEBUG /PDB:"c:\Users\yarkhan\Documents\TESTING\PLASMA\testPLASMA\testPLASMA\Release\testPLASMA.pdb" /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT plasma.lib coreblas.lib cblas.lib corelapack.lib libacml.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

You will naturally need to fix the paths in the above examples.

In your code, I had to make a couple of small adjustments,
Comment out the following line
//#include "stdafx.h"
And change the interface to main so it looks like this
int main(int argc, char* argv[])

I hope this helps you. Please let us know if you have more problems or any other feedback.
Regards,
Asim YarKhan



This is the vcproj file that contains the customization that I made to the project preferences.
testPLASMA.vcproj

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="testPLASMA"
ProjectGUID="{6ADFF650-5CDC-47CC-A049-9FBA59BE919A}"
RootNamespace="testPLASMA"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="C:\Users\yarkhan\Documents\TESTING\PLASMA\include"
PreprocessorDefinitions="UPCASE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="plasma.lib coreblas.lib cblas.lib corelapack.lib libacml.lib"
AdditionalLibraryDirectories="C:\Users\yarkhan\Documents\TESTING\PLASMA\lib;C:\AMD\acml4.3.0\ifort32\lib"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames="MSVCRT.LIB;MSVCRTD.LIB"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="C:\Users\yarkhan\Documents\TESTING\PLASMA\include"
PreprocessorDefinitions="UPCASE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="plasma.lib coreblas.lib cblas.lib corelapack.lib libacml.lib"
AdditionalLibraryDirectories="C:\Users\yarkhan\Documents\TESTING\PLASMA\lib;C:\AMD\acml4.3.0\ifort32\lib"
IgnoreDefaultLibraryNames="MSVCRT.LIB"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\testPLASMA.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
yarkhan
 
Posts: 15
Joined: Thu Oct 01, 2009 10:38 am

Re: help with .sln file with Visual Studio 2008 and acml Blas

Postby andy » Sat Dec 19, 2009 4:52 pm

Thank you Asim!

I was able to compile the example using your .vcproj as a base and successfully run it. I'm excited to move on!

Thanks again,
Andy
andy
 
Posts: 4
Joined: Sat Sep 26, 2009 12:34 am


Return to User discussion

Who is online

Users browsing this forum: No registered users and 1 guest