Skip to content

Commit

Permalink
check group for mcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
brucefan1983 committed Aug 23, 2023
1 parent d039835 commit e23d295
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main_gpumd/run.cu
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void Run::parse_one_keyword(std::vector<std::string>& tokens)
} else if (strcmp(param[0], "electron_stop") == 0) {
electron_stop.parse(param, num_param, atom.number_of_atoms, number_of_types);
} else if (strcmp(param[0], "mc") == 0) {
mc.parse_mc(param, num_param, group);
mc.parse_mc(param, num_param, group, atom.cpu_type);
} else if (strcmp(param[0], "run") == 0) {
parse_run(param, num_param);
} else {
Expand Down
21 changes: 20 additions & 1 deletion src/mc/mc.cu
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void MC::compute(int step, int num_steps, Atom& atom, Box& box)
}
}

void MC::parse_mc(const char** param, int num_param, std::vector<Group>& groups)
void MC::parse_mc(
const char** param, int num_param, std::vector<Group>& groups, std::vector<int>& cpu_type)
{
if (num_param < 6) {
PRINT_INPUT_ERROR("mc should have at least 5 parameters.\n");
Expand Down Expand Up @@ -113,6 +114,24 @@ void MC::parse_mc(const char** param, int num_param, std::vector<Group>& groups)
if (group_id >= groups[grouping_method].number) {
PRINT_INPUT_ERROR("Group ID should < number of groups.");
}

bool has_multi_types = false;
int type0 = 0;
for (int k = 0; k < groups[grouping_method].cpu_size[group_id]; ++k) {
int n =
groups[grouping_method].cpu_contents[groups[grouping_method].cpu_size_sum[group_id] + k];
if (k == 0) {
type0 = cpu_type[n];
} else {
if (cpu_type[n] != type0) {
has_multi_types = true;
break;
}
}
}
if (!has_multi_types) {
PRINT_INPUT_ERROR("Must have more than one atom type in the specified group.");
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/mc/mc.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public:
void finalize(void);
void compute(int step, int num_steps, Atom& atom, Box& box);

void parse_mc(const char** param, int num_param, std::vector<Group>& group);
void parse_mc(
const char** param, int num_param, std::vector<Group>& group, std::vector<int>& cpu_type);

private:
bool do_mcmd = false;
Expand Down

0 comments on commit e23d295

Please sign in to comment.