sheet3
This commit is contained in:
parent
0b93cbcdd3
commit
56614805cf
12 changed files with 4496 additions and 0 deletions
6
sheet3/7/.vscode/settings.json
vendored
Normal file
6
sheet3/7/.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"ostream": "cpp",
|
||||||
|
"iostream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
0
sheet3/7/.vscode/settings.json:Zone - Kopie.Identifier
vendored
Normal file
0
sheet3/7/.vscode/settings.json:Zone - Kopie.Identifier
vendored
Normal file
0
sheet3/7/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier
vendored
Normal file
0
sheet3/7/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier
vendored
Normal file
0
sheet3/7/.vscode/settings.json:Zone.Identifier
vendored
Normal file
0
sheet3/7/.vscode/settings.json:Zone.Identifier
vendored
Normal file
BIN
sheet3/7/5main
Executable file
BIN
sheet3/7/5main
Executable file
Binary file not shown.
2563
sheet3/7/Doxyfile
Normal file
2563
sheet3/7/Doxyfile
Normal file
File diff suppressed because it is too large
Load diff
33
sheet3/7/Makefile
Normal file
33
sheet3/7/Makefile
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#
|
||||||
|
# use GNU-Compiler tools
|
||||||
|
COMPILER=GCC_
|
||||||
|
# alternatively from the shell
|
||||||
|
# export COMPILER=GCC_
|
||||||
|
# or, alternatively from the shell
|
||||||
|
# make COMPILER=GCC_
|
||||||
|
|
||||||
|
# use Intel compilers
|
||||||
|
#COMPILER=ICC_
|
||||||
|
|
||||||
|
# use PGI compilers
|
||||||
|
# COMPILER=PGI_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES = main.cpp
|
||||||
|
OBJECTS = $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
PROGRAM = main.${COMPILER}
|
||||||
|
|
||||||
|
# uncomment the next to lines for debugging and detailed performance analysis
|
||||||
|
CXXFLAGS += -g
|
||||||
|
LINKFLAGS += -g
|
||||||
|
# do not use -pg with PGI compilers
|
||||||
|
|
||||||
|
ifndef COMPILER
|
||||||
|
COMPILER=GCC_
|
||||||
|
endif
|
||||||
|
|
||||||
|
include ../${COMPILER}default.mk
|
||||||
|
$(PROGRAM): $(OBJECTS)
|
||||||
|
$(CXX) $(CXXFLAGS) $(OBJECTS) -llapacke -lopenblas -o $(PROGRAM)
|
||||||
BIN
sheet3/7/benchmark.o
Normal file
BIN
sheet3/7/benchmark.o
Normal file
Binary file not shown.
BIN
sheet3/7/main
Executable file
BIN
sheet3/7/main
Executable file
Binary file not shown.
68
sheet3/7/main.cpp
Normal file
68
sheet3/7/main.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include <cassert>
|
||||||
|
#include <chrono> // timing
|
||||||
|
#include <cmath> // sqrt()
|
||||||
|
#include <cstdlib> // atoi()
|
||||||
|
#include <cstring> // strncmp()
|
||||||
|
#include <ctime>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <lapacke.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace std::chrono; // timing
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
unsigned int n= 10;
|
||||||
|
unsigned int nhrs = 1;
|
||||||
|
|
||||||
|
vector<double> M(n*n,4.0);
|
||||||
|
|
||||||
|
for(unsigned int i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
for(unsigned int j=0; j<n; j++)
|
||||||
|
{
|
||||||
|
if(i!=j)
|
||||||
|
{
|
||||||
|
double diff = i-j;
|
||||||
|
M[i*n+j] = 1.0/(diff*diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vector<int> ipiv(n); //pivots
|
||||||
|
LAPACKE_dgetrf(LAPACK_ROW_MAJOR,n,n, M.data(),n,ipiv.data()); //M=PLU
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int runtimes[] = {1,2,4,8,16,32};
|
||||||
|
|
||||||
|
for(unsigned int i=0; i < 6;i++)
|
||||||
|
{
|
||||||
|
nhrs = runtimes[i];
|
||||||
|
vector<double> b(n*nhrs,0.0);
|
||||||
|
for (unsigned int j=0; j<n; j++)
|
||||||
|
{
|
||||||
|
for (unsigned int k=0; k<nhrs; k++)
|
||||||
|
{
|
||||||
|
b[j*nhrs+k] = j*nhrs+k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LAPACKE_dgetrs(LAPACK_ROW_MAJOR,'N',n,nhrs,M.data(),n,ipiv.data(),b.data(),nhrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
BIN
sheet3/7/mylib.o
Normal file
BIN
sheet3/7/mylib.o
Normal file
Binary file not shown.
1826
sheet3/7/small_Doxyfile
Normal file
1826
sheet3/7/small_Doxyfile
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue