Skip to content

Commit

Permalink
corrected definition of amrex Table2D
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh-s-sawant committed Aug 27, 2024
1 parent 56b92ab commit 3f61854
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions scripts/negf_cpp/math_libraries/Source/GlobalFuncs.H
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Define_Table2D (U& Tab2D_data, V val)

auto const& Tab2D = Tab2D_data.table();

for (int i = tlo[0]; i < thi[0]; ++i)
for (int i = tlo[0]; i <= thi[0]; ++i)
{
for (int j = tlo[1]; j < thi[1]; ++j) //slow access
for (int j = tlo[1]; j <= thi[1]; ++j) //slow access
{
ComplexType new_val(val.real()*(j+1), val.imag()*(j+1));

Expand All @@ -38,9 +38,9 @@ SetVal_Table2D (U& Tab2D_data, V val)

auto const& Tab2D = Tab2D_data.table();

for (int i = tlo[0]; i < thi[0]; ++i)
for (int i = tlo[0]; i <= thi[0]; ++i)
{
for (int j = tlo[1]; j < thi[1]; ++j) //slow access
for (int j = tlo[1]; j <= thi[1]; ++j) //slow access
{
Tab2D(i,j) = val;
}
Expand All @@ -56,9 +56,9 @@ void Print_Table2D(const U& Tab2D_data, const std::string tablename="")
auto const& Tab2D = Tab2D_data.table();

std::cout << "\nPrinting Table: " << tablename << "\n";
for (int i = tlo[0]; i < thi[0]; ++i)
for (int i = tlo[0]; i <= thi[0]; ++i)
{
for (int j = tlo[1]; j < thi[1]; ++j) //slow access
for (int j = tlo[1]; j <= thi[1]; ++j) //slow access
{
std::cout << std::setw(12) << std::setprecision(6) << std::fixed
<< Tab2D(i,j).real() << " + "
Expand Down
6 changes: 3 additions & 3 deletions scripts/negf_cpp/math_libraries/Source/MathLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ void MathLib::MatrixMatrixMultiply(ComplexType* d_C,

cublasStatus_t status =cublasZgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N,
A_rows, B_cols, A_cols, &alpha,
reinterpret_cast<const cuDoubleComplex*>(d_A), A_rows+1,
reinterpret_cast<const cuDoubleComplex*>(d_B), A_cols+1, &beta,
reinterpret_cast<cuDoubleComplex*>(d_C), A_rows+1);
reinterpret_cast<const cuDoubleComplex*>(d_A), A_rows,
reinterpret_cast<const cuDoubleComplex*>(d_B), A_cols, &beta,
reinterpret_cast<cuDoubleComplex*>(d_C), A_rows);
checkCudaErrors(status);

checkCudaErrors(cublasDestroy(handle));
Expand Down
14 changes: 7 additions & 7 deletions scripts/negf_cpp/math_libraries/Source/Tests/Test_MM_Mul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Test_MM_Mul::Test_MM_Mul(int a_rows, int a_cols, int b_cols, const std::vector<i
void
Test_MM_Mul:: Define()
{
h_A_data.resize({0,0},{A_rows, A_cols},The_Pinned_Arena());
d_A_data.resize({0,0},{A_rows, A_cols},The_Arena());
h_B_data.resize({0,0},{A_cols, B_cols},The_Pinned_Arena());
d_B_data.resize({0,0},{A_cols, B_cols},The_Arena());
h_C_data.resize({0,0},{A_rows, B_cols},The_Pinned_Arena());
d_C_data.resize({0,0},{A_rows, B_cols},The_Arena());
h_A_data.resize({0,0},{A_rows-1, A_cols-1},The_Pinned_Arena());
d_A_data.resize({0,0},{A_rows-1, A_cols-1},The_Arena());
h_B_data.resize({0,0},{A_cols-1, B_cols-1},The_Pinned_Arena());
d_B_data.resize({0,0},{A_cols-1, B_cols-1},The_Arena());
h_C_data.resize({0,0},{A_rows-1, B_cols-1},The_Pinned_Arena());
d_C_data.resize({0,0},{A_rows-1, B_cols-1},The_Arena());
}


Expand Down Expand Up @@ -48,7 +48,7 @@ Test_MM_Mul:: Print_Input()

//Usage Error: In the forloop we should be using (i < dim_A[0]*dim_A[1])
//But currently we need to add a buffer of 1 unit size to print properly!
for(int i=0; i<(A_rows+1)*A_cols; ++i)
for(int i=0; i< A_rows*A_cols; ++i)
{
amrex::Print() << i << " "<< *(h_A.p+i) << "\n";
}
Expand Down

0 comments on commit 3f61854

Please sign in to comment.