Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
893b4d33
Commit
893b4d33
authored
12 years ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
Fixing line endings.
parent
62837524
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SimpleTests/MatrixTests/MatMult.cpp
+193
-193
193 additions, 193 deletions
SimpleTests/MatrixTests/MatMult.cpp
scripts/cmake/cmake/FindBLAS.cmake
+462
-462
462 additions, 462 deletions
scripts/cmake/cmake/FindBLAS.cmake
with
655 additions
and
655 deletions
SimpleTests/MatrixTests/MatMult.cpp
+
193
−
193
View file @
893b4d33
/**
/**
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net)
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net)
* Distributed under a Modified BSD License.
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* See accompanying file LICENSE.txt or
* http://www.opengeosys.net/LICENSE.txt
* http://www.opengeosys.net/LICENSE.txt
*
*
* \file MatMult.cpp
* \file MatMult.cpp
*
*
* Created on 2012-01-03 by Thomas Fischer
* Created on 2012-01-03 by Thomas Fischer
*/
*/
#include
<fstream>
#include
<fstream>
#include
<iostream>
#include
<iostream>
#include
<cmath>
#include
<cmath>
#include
<limits>
#include
<limits>
#include
<cstdlib>
#include
<cstdlib>
#include
"sparse.h"
#include
"sparse.h"
#include
"LinAlg/Sparse/CRSMatrix.h"
#include
"LinAlg/Sparse/CRSMatrix.h"
#include
"LinAlg/Sparse/CRSMatrixOpenMP.h"
#include
"LinAlg/Sparse/CRSMatrixOpenMP.h"
#include
"LinAlg/Sparse/CRSMatrixPThreads.h"
#include
"LinAlg/Sparse/CRSMatrixPThreads.h"
// BaseLib
// BaseLib
#include
"RunTime.h"
#include
"RunTime.h"
#include
"CPUTime.h"
#include
"CPUTime.h"
// BaseLib/logog
// BaseLib/logog
#include
"logog.hpp"
#include
"logog.hpp"
#include
"formatter.hpp"
#include
"formatter.hpp"
// BaseLib/tclap
// BaseLib/tclap
#include
"tclap/CmdLine.h"
#include
"tclap/CmdLine.h"
#ifdef UNIX
#ifdef UNIX
#include
<sys/unistd.h>
#include
<sys/unistd.h>
#endif
#endif
#ifdef OGS_BUILD_INFO
#ifdef OGS_BUILD_INFO
#include
"BuildInfo.h"
#include
"BuildInfo.h"
#endif
#endif
#ifdef _OPENMP
#ifdef _OPENMP
#include
<omp.h>
#include
<omp.h>
#endif
#endif
/**
/**
* new formatter for logog
* new formatter for logog
*/
*/
class
FormatterCustom
:
public
logog
::
FormatterGCC
class
FormatterCustom
:
public
logog
::
FormatterGCC
{
{
virtual
TOPIC_FLAGS
GetTopicFlags
(
const
logog
::
Topic
&
topic
)
virtual
TOPIC_FLAGS
GetTopicFlags
(
const
logog
::
Topic
&
topic
)
{
{
return
(
Formatter
::
GetTopicFlags
(
topic
)
&
return
(
Formatter
::
GetTopicFlags
(
topic
)
&
~
(
TOPIC_FILE_NAME_FLAG
|
TOPIC_LINE_NUMBER_FLAG
));
~
(
TOPIC_FILE_NAME_FLAG
|
TOPIC_LINE_NUMBER_FLAG
));
}
}
};
};
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
LOGOG_INITIALIZE
();
LOGOG_INITIALIZE
();
TCLAP
::
CmdLine
cmd
(
"Simple matrix vector multiplication test"
,
' '
,
"0.1"
);
TCLAP
::
CmdLine
cmd
(
"Simple matrix vector multiplication test"
,
' '
,
"0.1"
);
// Define a value argument and add it to the command line.
// Define a value argument and add it to the command line.
// A value arg defines a flag and a type of value that it expects,
// A value arg defines a flag and a type of value that it expects,
// such as "-m matrix".
// such as "-m matrix".
TCLAP
::
ValueArg
<
std
::
string
>
matrix_arg
(
"m"
,
"matrix"
,
"input matrix file"
,
true
,
""
,
"string"
);
TCLAP
::
ValueArg
<
std
::
string
>
matrix_arg
(
"m"
,
"matrix"
,
"input matrix file"
,
true
,
""
,
"string"
);
// Add the argument mesh_arg to the CmdLine object. The CmdLine object
// Add the argument mesh_arg to the CmdLine object. The CmdLine object
// uses this Arg to parse the command line.
// uses this Arg to parse the command line.
cmd
.
add
(
matrix_arg
);
cmd
.
add
(
matrix_arg
);
TCLAP
::
ValueArg
<
unsigned
>
n_cores_arg
(
"p"
,
"number-cores"
,
"number of cores to use"
,
false
,
1
,
"number"
);
TCLAP
::
ValueArg
<
unsigned
>
n_cores_arg
(
"p"
,
"number-cores"
,
"number of cores to use"
,
false
,
1
,
"number"
);
cmd
.
add
(
n_cores_arg
);
cmd
.
add
(
n_cores_arg
);
TCLAP
::
ValueArg
<
unsigned
>
n_mults_arg
(
"n"
,
"number-of-multiplications"
,
"number of multiplications to perform"
,
true
,
10
,
"number"
);
TCLAP
::
ValueArg
<
unsigned
>
n_mults_arg
(
"n"
,
"number-of-multiplications"
,
"number of multiplications to perform"
,
true
,
10
,
"number"
);
cmd
.
add
(
n_mults_arg
);
cmd
.
add
(
n_mults_arg
);
TCLAP
::
ValueArg
<
std
::
string
>
output_arg
(
"o"
,
"output"
,
"output file"
,
false
,
""
,
"string"
);
TCLAP
::
ValueArg
<
std
::
string
>
output_arg
(
"o"
,
"output"
,
"output file"
,
false
,
""
,
"string"
);
cmd
.
add
(
output_arg
);
cmd
.
add
(
output_arg
);
TCLAP
::
ValueArg
<
unsigned
>
verbosity_arg
(
"v"
,
"verbose"
,
"level of verbosity [0 very low information, 1 much information]"
,
false
,
0
,
"string"
);
TCLAP
::
ValueArg
<
unsigned
>
verbosity_arg
(
"v"
,
"verbose"
,
"level of verbosity [0 very low information, 1 much information]"
,
false
,
0
,
"string"
);
cmd
.
add
(
verbosity_arg
);
cmd
.
add
(
verbosity_arg
);
cmd
.
parse
(
argc
,
argv
);
cmd
.
parse
(
argc
,
argv
);
// read the number of multiplication to execute
// read the number of multiplication to execute
unsigned
n_mults
(
n_mults_arg
.
getValue
());
unsigned
n_mults
(
n_mults_arg
.
getValue
());
std
::
string
fname_mat
(
matrix_arg
.
getValue
());
std
::
string
fname_mat
(
matrix_arg
.
getValue
());
FormatterCustom
*
custom_format
(
new
FormatterCustom
);
FormatterCustom
*
custom_format
(
new
FormatterCustom
);
logog
::
Cout
*
logogCout
(
new
logog
::
Cout
);
logog
::
Cout
*
logogCout
(
new
logog
::
Cout
);
logogCout
->
SetFormatter
(
*
custom_format
);
logogCout
->
SetFormatter
(
*
custom_format
);
logog
::
LogFile
*
logog_file
(
NULL
);
logog
::
LogFile
*
logog_file
(
NULL
);
if
(
!
output_arg
.
getValue
().
empty
())
{
if
(
!
output_arg
.
getValue
().
empty
())
{
logog_file
=
new
logog
::
LogFile
(
output_arg
.
getValue
().
c_str
());
logog_file
=
new
logog
::
LogFile
(
output_arg
.
getValue
().
c_str
());
logog_file
->
SetFormatter
(
*
custom_format
);
logog_file
->
SetFormatter
(
*
custom_format
);
}
}
// read number of threads
// read number of threads
unsigned
n_threads
(
n_cores_arg
.
getValue
());
unsigned
n_threads
(
n_cores_arg
.
getValue
());
#ifdef OGS_BUILD_INFO
#ifdef OGS_BUILD_INFO
INFO
(
"%s was build with compiler %s"
,
argv
[
0
],
CMAKE_CXX_COMPILER
);
INFO
(
"%s was build with compiler %s"
,
argv
[
0
],
CMAKE_CXX_COMPILER
);
#ifdef NDEBUG
#ifdef NDEBUG
INFO
(
"CXX_FLAGS: %s %s"
,
CMAKE_CXX_FLAGS
,
CMAKE_CXX_FLAGS_RELEASE
);
INFO
(
"CXX_FLAGS: %s %s"
,
CMAKE_CXX_FLAGS
,
CMAKE_CXX_FLAGS_RELEASE
);
#else
#else
INFO
(
"CXX_FLAGS: %s %s"
,
CMAKE_CXX_FLAGS
,
CMAKE_CXX_FLAGS_DEBUG
);
INFO
(
"CXX_FLAGS: %s %s"
,
CMAKE_CXX_FLAGS
,
CMAKE_CXX_FLAGS_DEBUG
);
#endif
#endif
#endif
#endif
#ifdef UNIX
#ifdef UNIX
const
int
max_host_name_len
(
255
);
const
int
max_host_name_len
(
255
);
char
*
hostname
(
new
char
[
max_host_name_len
]);
char
*
hostname
(
new
char
[
max_host_name_len
]);
if
(
gethostname
(
hostname
,
max_host_name_len
)
==
0
)
if
(
gethostname
(
hostname
,
max_host_name_len
)
==
0
)
INFO
(
"hostname: %s"
,
hostname
);
INFO
(
"hostname: %s"
,
hostname
);
delete
[]
host_name_len
;
delete
[]
host_name_len
;
#endif
#endif
// *** reading matrix in crs format from file
// *** reading matrix in crs format from file
std
::
ifstream
in
(
fname_mat
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
ifstream
in
(
fname_mat
.
c_str
(),
std
::
ios
::
in
|
std
::
ios
::
binary
);
double
*
A
(
NULL
);
double
*
A
(
NULL
);
unsigned
*
iA
(
NULL
),
*
jA
(
NULL
),
n
;
unsigned
*
iA
(
NULL
),
*
jA
(
NULL
),
n
;
if
(
in
)
{
if
(
in
)
{
INFO
(
"reading matrix from %s ..."
,
fname_mat
.
c_str
());
INFO
(
"reading matrix from %s ..."
,
fname_mat
.
c_str
());
BaseLib
::
RunTime
timer
;
BaseLib
::
RunTime
timer
;
timer
.
start
();
timer
.
start
();
CS_read
(
in
,
n
,
iA
,
jA
,
A
);
CS_read
(
in
,
n
,
iA
,
jA
,
A
);
timer
.
stop
();
timer
.
stop
();
INFO
(
"
\t
- took %e s"
,
timer
.
elapsed
());
INFO
(
"
\t
- took %e s"
,
timer
.
elapsed
());
}
else
{
}
else
{
ERR
(
"error reading matrix from %s"
,
fname_mat
.
c_str
());
ERR
(
"error reading matrix from %s"
,
fname_mat
.
c_str
());
return
-
1
;
return
-
1
;
}
}
unsigned
nnz
(
iA
[
n
]);
unsigned
nnz
(
iA
[
n
]);
INFO
(
"
\t
Parameters read: n=%d, nnz=%d"
,
n
,
nnz
);
INFO
(
"
\t
Parameters read: n=%d, nnz=%d"
,
n
,
nnz
);
#ifdef _OPENMP
#ifdef _OPENMP
omp_set_num_threads
(
n_threads
);
omp_set_num_threads
(
n_threads
);
unsigned
*
mat_entries_per_core
(
new
unsigned
[
n_threads
]);
unsigned
*
mat_entries_per_core
(
new
unsigned
[
n_threads
]);
for
(
unsigned
k
(
0
);
k
<
n_threads
;
k
++
)
{
for
(
unsigned
k
(
0
);
k
<
n_threads
;
k
++
)
{
mat_entries_per_core
[
k
]
=
0
;
mat_entries_per_core
[
k
]
=
0
;
}
}
OPENMP_LOOP_TYPE
i
;
OPENMP_LOOP_TYPE
i
;
{
{
#pragma omp parallel for
#pragma omp parallel for
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
mat_entries_per_core
[
omp_get_thread_num
()]
+=
iA
[
i
+
1
]
-
iA
[
i
];
mat_entries_per_core
[
omp_get_thread_num
()]
+=
iA
[
i
+
1
]
-
iA
[
i
];
}
}
}
}
INFO
(
"*** work per core ***"
);
INFO
(
"*** work per core ***"
);
for
(
unsigned
k
(
0
);
k
<
n_threads
;
k
++
)
{
for
(
unsigned
k
(
0
);
k
<
n_threads
;
k
++
)
{
INFO
(
"
\t
%d
\t
%d"
,
k
,
mat_entries_per_core
[
k
]);
INFO
(
"
\t
%d
\t
%d"
,
k
,
mat_entries_per_core
[
k
]);
}
}
#endif
#endif
#ifdef _OPENMP
#ifdef _OPENMP
omp_set_num_threads
(
n_threads
);
omp_set_num_threads
(
n_threads
);
MathLib
::
CRSMatrixOpenMP
<
double
,
unsigned
>
mat
(
n
,
iA
,
jA
,
A
);
MathLib
::
CRSMatrixOpenMP
<
double
,
unsigned
>
mat
(
n
,
iA
,
jA
,
A
);
#else
#else
MathLib
::
CRSMatrix
<
double
,
unsigned
>
mat
(
n
,
iA
,
jA
,
A
);
MathLib
::
CRSMatrix
<
double
,
unsigned
>
mat
(
n
,
iA
,
jA
,
A
);
#endif
#endif
double
*
x
(
new
double
[
n
]);
double
*
x
(
new
double
[
n
]);
double
*
y
(
new
double
[
n
]);
double
*
y
(
new
double
[
n
]);
for
(
unsigned
k
(
0
);
k
<
n
;
++
k
)
for
(
unsigned
k
(
0
);
k
<
n
;
++
k
)
x
[
k
]
=
1.0
;
x
[
k
]
=
1.0
;
INFO
(
"*** %d matrix vector multiplications (MVM) with Toms amuxCRS (%d threads) ..."
,
n_mults
,
n_threads
);
INFO
(
"*** %d matrix vector multiplications (MVM) with Toms amuxCRS (%d threads) ..."
,
n_mults
,
n_threads
);
BaseLib
::
RunTime
run_timer
;
BaseLib
::
RunTime
run_timer
;
BaseLib
::
CPUTime
cpu_timer
;
BaseLib
::
CPUTime
cpu_timer
;
run_timer
.
start
();
run_timer
.
start
();
cpu_timer
.
start
();
cpu_timer
.
start
();
for
(
size_t
k
(
0
);
k
<
n_mults
;
k
++
)
{
for
(
size_t
k
(
0
);
k
<
n_mults
;
k
++
)
{
mat
.
amux
(
1.0
,
x
,
y
);
mat
.
amux
(
1.0
,
x
,
y
);
}
}
cpu_timer
.
stop
();
cpu_timer
.
stop
();
run_timer
.
stop
();
run_timer
.
stop
();
INFO
(
"
\t
[MVM] - took %e sec cpu time, %e sec run time"
,
cpu_timer
.
elapsed
(),
run_timer
.
elapsed
());
INFO
(
"
\t
[MVM] - took %e sec cpu time, %e sec run time"
,
cpu_timer
.
elapsed
(),
run_timer
.
elapsed
());
delete
[]
x
;
delete
[]
x
;
delete
[]
y
;
delete
[]
y
;
delete
custom_format
;
delete
custom_format
;
delete
logogCout
;
delete
logogCout
;
delete
logog_file
;
delete
logog_file
;
LOGOG_SHUTDOWN
();
LOGOG_SHUTDOWN
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
scripts/cmake/cmake/FindBLAS.cmake
+
462
−
462
View file @
893b4d33
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment