Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Aland, Sebastian
amdis
Commits
80399a40
Commit
80399a40
authored
Nov 22, 2010
by
Naumann, Andreas
Browse files
first plugin approach for umfpack
parent
5d4f9830
Changes
4
Hide whitespace changes
Inline
Side-by-side
AMDiS/plugins/CMakeLists.txt
0 → 100644
View file @
80399a40
project
(
amdis-plugins
)
cmake_minimum_required
(
VERSION 2.8
)
include_directories
(
../src/ ../lib/mtl4/ ../lib/UMFPACK/Include ../lib/AMD/Include ../lib/UFconfig/
)
link_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../
${
CMAKE_CURRENT_SOURCE_DIR
}
/../lib/UMFPACK/Lib/
${
CMAKE_CURRENT_SOURCE_DIR
}
/../lib/AMD/Lib/
)
add_library
(
amdis-umfpack SHARED src/umfpack.cpp
)
target_link_libraries
(
amdis-umfpack umfpack amd blas
)
add_executable
(
use src/use.cpp
)
target_link_libraries
(
use dl amdis boost_iostreams boost_system
)
#amdis was compiled with openmp -> needed openmp for the application also.
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fopenmp"
)
AMDiS/plugins/src/PluginProvider.h
0 → 100644
View file @
80399a40
#ifndef PLUGINPROVER_H
#define PLUGINPROVER_H
#include
"dlfcn.h"
#include
<string>
using
namespace
std
;
namespace
AMDiS
{
template
<
typename
DesiredCreator
>
struct
PluginProvider
{
typedef
DesiredCreator
*
Creator
();
typedef
void
Remover
(
DesiredCreator
*
);
string
createName
;
string
removeName
;
Remover
*
remover
;
PluginProvider
(
string
c
,
string
r
)
:
createName
(
c
),
removeName
(
r
),
remover
(
NULL
)
{}
enum
Error
{
NOLIBRARY
,
NOCREATOR
,
NOREMOVER
};
struct
Exception
{
Error
e
;
string
message
;
Exception
(
Error
e
,
string
m
)
:
e
(
e
),
message
(
m
)
{}
};
DesiredCreator
*
create
(
string
libname
)
{
void
*
library
=
dlopen
(
libname
.
c_str
(),
RTLD_LAZY
);
if
(
library
==
NULL
)
{
throw
Exception
(
NOLIBRARY
,
dlerror
());
}
dlerror
();
Creator
*
creator
=
(
Creator
*
)
(
dlsym
(
library
,
createName
.
c_str
()));
if
(
creator
==
NULL
)
{
throw
Exception
(
NOCREATOR
,
dlerror
());
}
remover
=
(
Remover
*
)
(
dlsym
(
library
,
removeName
.
c_str
()));
if
(
remover
==
NULL
)
{
throw
Exception
(
NOREMOVER
,
dlerror
());
}
DesiredCreator
*
creatingCreator
=
creator
();
return
creatingCreator
;
}
void
remove
(
DesiredCreator
*
dc
)
{
if
(
remover
==
NULL
)
{
throw
Exception
(
NOREMOVER
,
"the remover was not set
\n
"
);
}
remover
(
dc
);
}
};
//typedef OEMSolverCreator* createSolverCreator();
//typedef void removeSolverCreator(OEMSolverCreator*);
struct
SolverPluginProvider
:
PluginProvider
<
OEMSolverCreator
>
{
SolverPluginProvider
()
:
PluginProvider
<
OEMSolverCreator
>
(
"createSolverCreator"
,
"removeSolverCreator"
)
{}
};
}
#endif
AMDiS/plugins/src/umfpack.cpp
0 → 100644
View file @
80399a40
#define HAVE_UMFPACK
#define MTL_HAS_UMFPACK
#include
"AMDiS.h"
#include
"UmfPackSolver.h"
using
namespace
AMDiS
;
extern
"C"
OEMSolverCreator
*
createSolverCreator
()
{
return
new
UmfPackSolver
::
Creator
();
}
extern
"C"
void
removeSolverCreator
(
OEMSolverCreator
*
p
)
{
delete
p
;
}
AMDiS/plugins/src/use.cpp
0 → 100644
View file @
80399a40
#include
"AMDiS.h"
#include
"dlfcn.h"
#include
"PluginProvider.h"
#include
<iostream>
using
namespace
AMDiS
;
using
namespace
std
;
//typedef OEMSolverCreator* Creator();
//typedef void Remover(OEMSolverCreator*);
int
main
(
int
argc
,
char
**
argv
)
{
/* void* umfpackLib=dlopen("./libamdis-umfpack.so", RTLD_LAZY);
if (!umfpackLib) {
cerr << "Cannot load library: " << dlerror() << '\n';
return 1;
}
dlerror();
Creator* creator=(Creator*) (dlsym(umfpackLib, "createSolverCreator"));
if(creator == NULL) {
cerr << "could not load the create function in libumfpack.so \n";
return 2;
}
Remover* remover=(Remover* )(dlsym(umfpackLib, "removeSolverCreator"));
if( remover == NULL) {
cerr << "could not load the remove function in libumfpack.so \n";
return 3;
}
OEMSolverCreator* theCreator=creator();
*/
SolverPluginProvider
spp
;
OEMSolver
*
theSolver
(
NULL
);
try
{
OEMSolverCreator
*
theCreator
=
spp
.
create
(
"./libamdis-umfpack.so"
);
theCreator
->
setName
(
"umfpack"
);
theSolver
=
theCreator
->
create
();
// remover(theCreator);
spp
.
remove
(
theCreator
);
}
catch
(
SolverPluginProvider
::
Exception
e
)
{
std
::
cerr
<<
"could not load the umfpack solver: "
<<
e
.
message
<<
"
\n
"
;
return
1
;
}
mtl
::
matrix
::
compressed2D
<
double
>
testMatrix
(
10
,
10
);
mtl
::
matrix
::
diagonal_setup
(
testMatrix
,
5.0
);
mtl
::
vector
::
dense_vector
<
double
>
b
(
10
);
b
=
4.0
;
mtl
::
vector
::
dense_vector
<
double
>
x
(
10
);
x
=
0.0
;
theSolver
->
solveSystem
(
testMatrix
,
x
,
b
);
delete
theSolver
;
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment