Skip to content

Commit

Permalink
symmetrize() is applied to CUDA solvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
shinmorino committed Jun 24, 2018
1 parent 81befec commit 500f95c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions sqaodc/cuda/CUDADenseGraphAnnealer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ void CUDADenseGraphAnnealer<real>::setQUBO(const HostMatrix &W, sq::OptimizeMeth
om_ = om;

DeviceMatrix *dW = devStream_->tempDeviceMatrix<real>(W.dim(), __func__);
DeviceMatrix *dWsym = devStream_->tempDeviceMatrix<real>(W.dim(), __func__);
devCopy_(dW, W);
devCopy_.clearPadding(dW);
devFormulas_.devMath.symmetrize(dWsym, *dW);
if (om == sq::optMaximize)
devFormulas_.devMath.scale(dW, -1., *dW);
devFormulas_.calculateHamiltonian(&d_h_, &d_J_, &d_c_, *dW);
devFormulas_.devMath.scale(dWsym, -1., *dWsym);
devFormulas_.calculateHamiltonian(&d_h_, &d_J_, &d_c_, *dWsym);
devStream_->synchronize();

setState(solProblemSet);
Expand Down
4 changes: 3 additions & 1 deletion sqaodc/cuda/CUDADenseGraphBFSearcher.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#include "CUDADenseGraphBFSearcher.h"
#include <sqaodc/common/internal/ShapeChecker.h>
#include <sqaodc/cpu/SharedFormulas.h>
#include "Device.h"
#include <cmath>
#include <float.h>
#include <algorithm>
#include <limits>

namespace sqint = sqaod_internal;
namespace sqcpu = sqaod_cpu;
using namespace sqaod_cuda;

template<class real>
Expand Down Expand Up @@ -54,7 +56,7 @@ void CUDADenseGraphBFSearcher<real>::setQUBO(const Matrix &W, sq::OptimizeMethod
throwErrorIf(63 < W.rows, "N must be smaller than 64, N=%d.", W.rows);

N_ = W.rows;
W_ = W;
W_ = sqcpu::symmetrize(W);
om_ = om;
if (om_ == sq::optMaximize)
W_ *= real(-1.);
Expand Down

0 comments on commit 500f95c

Please sign in to comment.