Skip to content

Commit

Permalink
Fix build with C++11 (pytorch#223)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#223

^

(Note: this ignores all push blocking failures!)

Reviewed By: dskhudia

Differential Revision: D19131462

fbshipit-source-id: 6bf8305099fb1a694612aa70ee0ee8ac65ca744d
  • Loading branch information
efiks authored and jspark1105 committed Mar 21, 2020
1 parent 4b330a8 commit 2b55dd9
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,29 @@ bool fbgemmEnvAvx512_256Enabled() {
return val == "true" || val == "1";
}

std::unordered_map<inst_set_t, std::unordered_set<inst_set_t>> isaSupportMap = {
{inst_set_t::anyarch, {inst_set_t::anyarch}},
{inst_set_t::avx2, {inst_set_t::avx2, inst_set_t::anyarch}},
{inst_set_t::avx512,
{inst_set_t::avx512, inst_set_t::avx512_ymm, inst_set_t::avx2}},
{inst_set_t::avx512_ymm,
{inst_set_t::avx512, inst_set_t::avx512_ymm, inst_set_t::avx2}},
{inst_set_t::avx512_vnni,
// This is require for build by older compilers GCC 5.4 and C++11
struct inst_set_t_hash {
std::size_t operator()(inst_set_t t) const {
return static_cast<std::size_t>(t);
}
};

std::unordered_map<
inst_set_t,
std::unordered_set<inst_set_t, inst_set_t_hash>,
inst_set_t_hash>
isaSupportMap = {
{inst_set_t::anyarch, {inst_set_t::anyarch}},
{inst_set_t::avx2, {inst_set_t::avx2, inst_set_t::anyarch}},
{inst_set_t::avx512,
{inst_set_t::avx512, inst_set_t::avx512_ymm, inst_set_t::avx2}},
{inst_set_t::avx512_ymm,
{inst_set_t::avx512, inst_set_t::avx512_ymm, inst_set_t::avx2}},
{inst_set_t::avx512_vnni,
inst_set_t::avx512,
inst_set_t::avx512_ymm,
inst_set_t::avx2}},
{inst_set_t::avx512_vnni,
inst_set_t::avx512,
inst_set_t::avx512_ymm,
inst_set_t::avx2}},
};

} // namespace
Expand Down Expand Up @@ -320,8 +331,9 @@ inst_set_t fbgemmInstructionSet() {
return detected_isa;
}
const auto supported_isa = isaSupportMap.find(detected_isa);
assert(supported_isa != isaSupportMap.end()
&& "Detected ISA can't be located in Supported ISA map");
assert(
supported_isa != isaSupportMap.end() &&
"Detected ISA can't be located in Supported ISA map");
if (supported_isa == isaSupportMap.end()) {
return detected_isa;
}
Expand Down

0 comments on commit 2b55dd9

Please sign in to comment.