Skip to content

Commit

Permalink
trying some solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Feb 7, 2025
1 parent fda5971 commit 245a3be
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 149 deletions.
55 changes: 45 additions & 10 deletions plugins/openACC/DistanceACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,40 @@ class Distance : public Colvar {
typedef MultiColvarTemplateGPU<Distance> DistanceGPU;
PLUMED_REGISTER_ACTION(DistanceGPU,"DISTANCE_GPU_VECTOR")

namespace {

struct tmp {

tmp() {
unsigned t = 73;
printf("t: %d\n",t);

// #pragma acc parallel loop gang //private(myinput)
#pragma acc parallel loop reduction(+:t) copy(t)
for(unsigned i=0; i<10000; i++) {
// mode +=i;
// auto myval = MultiValue(ncomponents, nderivatives, natoms);
// myinput.task_index = partialTaskList[i];
t+=i;
// runTask(partialTaskList[i], mode, myval );

// Transfer the data to the values
// if( !ismatrix ) transferToValue( partialTaskList[i], myval );

// Clear the value
// myval.clearAll();
}


printf("%d\n",t);
}


};

tmp t;
}

void Distance::registerKeywords( Keywords& keys ) {
Colvar::registerKeywords( keys );
keys.setDisplayName("DISTANCE");
Expand All @@ -163,6 +197,7 @@ void Distance::registerKeywords( Keywords& keys ) {
keys.setValueDescription("scalar/vector","the DISTANCE between this pair of atoms");
}


Distance::Distance(const ActionOptions&ao):
PLUMED_COLVAR_INIT(ao),
components(false),
Expand Down Expand Up @@ -286,23 +321,23 @@ void Distance::calculate() {
// }
}
void Distance::calculateCV( const ColvarInput& cvin, std::vector<double>& vals,
std::vector<std::vector<Vector>>& derivs, std::vector<Tensor>& virial ) {
std::vector<std::vector<Vector>>& derivs, std::vector<Tensor>& virial ) {
Vector distance=delta(cvin.pos[0],cvin.pos[1]);
const double value=distance.modulo();
const double invvalue=1.0/value;

// if(cvin.mode==1) {
derivs[0][0] = Vector(-1,0,0);
derivs[0][1] = Vector(+1,0,0);
vals[0] = distance[0];
derivs[0][0] = Vector(-1,0,0);
derivs[0][1] = Vector(+1,0,0);
vals[0] = distance[0];

derivs[1][0] = Vector(0,-1,0);
derivs[1][1] = Vector(0,+1,0);
vals[1] = distance[1];
derivs[1][0] = Vector(0,-1,0);
derivs[1][1] = Vector(0,+1,0);
vals[1] = distance[1];

derivs[2][0] = Vector(0,0,-1);
derivs[2][1] = Vector(0,0,+1);
vals[2] = distance[2];
derivs[2][0] = Vector(0,0,-1);
derivs[2][1] = Vector(0,0,+1);
vals[2] = distance[2];
// setBoxDerivativesNoPbc( cvin.pos, derivs, virial );
// } else if(cvin.mode==2) {
// Vector d=cvin.pbc.realToScaled(distance);
Expand Down
6 changes: 3 additions & 3 deletions plugins/openACC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DEPDIR := .deps
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
NVCXX = nvc++
# ACCFLAGS=-acc -acc=gpu -gpu=cc75 -gpu=managed
ACCFLAGS=-acc -acc=gpu -gpu=cc75
ACCFLAGS=-acc -acc=gpu -gpu=cc75 -gpu=debug
# ACCFLAGS=-acc -acc=multicore
# NVCCCFLAGS = $(ACCFLAGS) --c++17 -Minfo=all -fast -Werror --diag_suppress probable_guiding_friend
NVCCCFLAGS = $(ACCFLAGS) --c++17 -fast --diag_suppress probable_guiding_friend
Expand All @@ -29,7 +29,7 @@ all: ACC.$(SOEXT)


main: main.cpp
$(NVCXX) -O3 $(ACCFLAGS) -o $@ $<
$(NVCXX) -O3 $(ACCFLAGS) -o $@ $< -ldl

$(DEPDIR): ; @mkdir -p $@

Expand All @@ -44,7 +44,7 @@ include $(wildcard $(DEPFILES))

ACC.$(SOEXT): $(OBJS)
@echo Linking $@
$(NVCXX) $(NVCCLDFLAGS) $(ADDCLDFLAGS) -shared -Wl,-soname,"$(notdir $@)" $(NVCCDYNAMIC_LIBS) $(PLUMED_KERNEL) -o $@ $<
$(NVCXX) $(NVCCLDFLAGS) $(ADDCLDFLAGS) -shared -Wl,-soname,"$(notdir $@)" -o $@ $< $(NVCCDYNAMIC_LIBS) $(PLUMED_KERNEL)

clean:
@rm -fv $(ACCOBJS) $(OBJS) ACC.$(SOEXT)
Expand Down
3 changes: 1 addition & 2 deletions plugins/openACC/MultiColvarTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ ColvarInput::ColvarInput( const unsigned& m, const std::vector<Vector>& p, const
//pbc(box),
pos(p),
mass(w),
charges(q)
{
charges(q) {
}

ColvarInput ColvarInput::createColvarInput( const unsigned& m, const std::vector<Vector>& p, const Colvar* colv ) {
Expand Down
Loading

0 comments on commit 245a3be

Please sign in to comment.