[Openmp-dev] Experimental SPIR-V back-end using OpenCL 2.1

Marcio Machado Pereira via Openmp-dev openmp-dev at lists.llvm.org
Thu Nov 2 15:21:54 PDT 2017


Thanks again Daniel.
Now I have successfully completed the build!

Kind regards,
Marcio


On Thu, Nov 2, 2017 at 2:09 PM, Daniel Schürmann <
daniel.schuermann at campus.tu-berlin.de> wrote:

> Seems like your clang and llvm still don't fit together.
> However, I rebased my clang fork, so please just force pull. The master
> branch is correct.
> Or you can try these instructions:
> git clone --recursive git at github.com:thewilsonator/llvm.git
> git checkout compute
> git remote add upstream git at github.com:llvm-mirror/llvm.git
> git pull upstream master
> cd tools
> git clone git at github.com:daniel-schuermann/clang.git
> (not necessary at the moment, but might be from time to time:
> git remote add upstream git at github.com:llvm-mirror/clang.git
> git pull upstream master
> )
>
> Hope that works for you!
>
> Kind regards,
> Daniel
>
>
>
> On 11/02/2017 02:22 PM, Marcio Machado Pereira wrote:
>
> Thanks so much for the feedback Daniel!
>
> In fact, I was not in the correct llvm branch. I changed it to the
> computer branch and also I cloned the  https://github.com/
> thewilsonator/llvm-target-spirv.git into llvm/lib/target/SPIRV folder. Is
> that correct? I could not figure out which is the correct branch for your
> clang. So I kept the master branch, making sure that it is updated (via git
> pull) and I started the build process again. Now I have the error below. Do
> I still have sync issues between the tools? Thanks in advance.
>
> Marcio
>
>
> [ 78%] Building CXX object tools/clang/lib/CodeGen/
> CMakeFiles/clangCodeGen.dir/CGBuiltin.cpp.o
> /Users/marcio/clang-spirv/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp:9769:37:
> error:
>       no member named 'nvvm_wmma_load_a_f16_col_stride' in namespace
>       'llvm::Intrinsic'
>       IID = isColMajor ? Intrinsic::nvvm_wmma_load_a_f16_col_stride
>                          ~~~~~~~~~~~^
> /Users/marcio/clang-spirv/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp:9770:37:
> error:
>       no member named 'nvvm_wmma_load_a_f16_row_stride' in namespace
>       'llvm::Intrinsic'
>                        : Intrinsic::nvvm_wmma_load_a_f16_row_stride;
>                          ~~~~~~~~~~~^
> /Users/marcio/clang-spirv/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp:9774:37:
> error:
>       no member named 'nvvm_wmma_load_b_f16_col_stride' in namespace
>       'llvm::Intrinsic'
>       IID = isColMajor ? Intrinsic::nvvm_wmma_load_b_f16_col_stride
>                          ~~~~~~~~~~~^
> ...
>
>
> On Wed, Nov 1, 2017 at 2:19 PM, Schürmann, Daniel <
> daniel.schuermann at campus.tu-berlin.de> wrote:
>
>> Hi Marcio,
>>
>>
>>
>> thanks for your interest!
>>
>> The compilation errors you get seem to result from LLVM and Clang being
>> out of sync.
>>
>> Please stash your changes and
>> make sure, you are on the llvm compute branch from thewilsonator,
>>
>> (make sure, you also cloned the recursive subproject in target/spirv)
>>
>> remote add and pull/merge upstream.
>>
>> Do the same with my clang fork.
>> Delete your build folder and try again 😊
>>
>>
>>
>> If this still doesn’t work, please let me know and I will look tomorrow
>> what is wrong.
>>
>>
>>
>> Kind regards,
>>
>> Daniel
>>
>>
>>
>> *Von: *Marcio Machado Pereira via Openmp-dev <openmp-dev at lists.llvm.org>
>> *Gesendet: *Mittwoch, 1. November 2017 16:20
>> *An: *openmp-dev at lists.llvm.org
>> *Betreff: *Re: [Openmp-dev] Experimental SPIR-V back-end using OpenCL 2.1
>>
>>
>> Dear Daniel,
>>
>> I was very interested in getting to know your work. I realized that a
>> visual inspection is not enough, so I decided to build the tools to inspect
>> how you are generating code for spir-v. I downloaded clang, llvm and openmp
>> indicated by you in the email and start the build process. It happened that
>> in this process I encountered a series of inconsistencies, and differences
>> in functions signature, etc. I tried to solve them by modifying some of the
>> files I set out below. This allowed me to continue a little, but as the
>> changes started to require more meaningful changes, I decided to write to
>> you counting with your help. I'm sorry if the email is large but I tried to
>> describe the problems and solution alternatives I used. To facilitate your
>> analysis, I used the git diff tool that explains my modifications. At the
>> end of the text, I put the final result of the make process in two
>> situations (for 1 thread and 4 threads). I would greatly appreciate
>> feedback from you to complete this build process.
>>
>> Follow the informations:
>>
>> ==============================================
>> file clang/utils/TableGen/ClangAttrEmitter.cpp
>> ==============================================
>>
>> $ git diff utils/TableGen/ClangAttrEmitter.cpp
>> diff --git a/utils/TableGen/ClangAttrEmitter.cpp
>> b/utils/TableGen/ClangAttrEmitter.cpp
>> index effabcc..39ae476 100644
>> --- a/utils/TableGen/ClangAttrEmitter.cpp
>> +++ b/utils/TableGen/ClangAttrEmitter.cpp
>> @@ -41,6 +41,7 @@
>>  #include <vector>
>>
>>  using namespace llvm;
>> +using namespace detail;
>>
>>  namespace {
>>
>> @@ -733,20 +734,23 @@ namespace {
>>    };
>>
>>    // Unique the enums, but maintain the original declaration ordering.
>> -  std::vector<StringRef>
>> -  uniqueEnumsInOrder(const std::vector<StringRef> &enums) {
>> -    std::vector<StringRef> uniques;
>> -    SmallDenseSet<StringRef, 8> unique_set;
>> +  std::vector<std::string>
>> +  uniqueEnumsInOrder(const std::vector<std::string> &enums) {
>> +    std::vector<std::string> uniques;
>> +    std::set<std::string> unique_set(enums.begin(), enums.end());
>>      for (const auto &i : enums) {
>> -      if (unique_set.insert(i).second)
>> +      std::set<std::string>::iterator set_i = unique_set.find(i);
>> +      if (set_i != unique_set.end()) {
>>          uniques.push_back(i);
>> +        unique_set.erase(set_i);
>> +      }
>>      }
>>      return uniques;
>>    }
>>
>>    class EnumArgument : public Argument {
>>      std::string type;
>> -    std::vector<StringRef> values, enums, uniques;
>> +    std::vector<std::string> values, enums, uniques;
>>
>>    public:
>>      EnumArgument(const Record &Arg, StringRef Attr)
>> @@ -866,7 +870,7 @@ namespace {
>>
>>    class VariadicEnumArgument: public VariadicArgument {
>>      std::string type, QualifiedTypeName;
>> -    std::vector<StringRef> values, enums, uniques;
>> +    std::vector<std::string> values, enums, uniques;
>>
>>    protected:
>>      void writeValueImpl(raw_ostream &OS) const override {
>> @@ -2624,7 +2628,7 @@ void EmitClangAttrPCHWrite(RecordKeeper &Records,
>> raw_ostream &OS) {
>>  // append a unique suffix to distinguish this set of target checks from
>> other
>>  // TargetSpecificAttr records.
>>  static void GenerateTargetSpecificAttrChecks(const Record *R,
>> -                                             std::vector<StringRef>
>> &Arches,
>> +                                             std::vector<std::string>
>> &Arches,
>>                                               std::string &Test,
>>                                               std::string *FnName) {
>>    // It is assumed that there will be an llvm::Triple object
>> @@ -2649,9 +2653,9 @@ static void GenerateTargetSpecificAttrChecks(const
>> Record *R,
>>      // We know that there was at least one arch test, so we need to and
>> in the
>>      // OS tests.
>>      Test += " && (";
>> -    std::vector<StringRef> OSes = R->getValueAsListOfStrings("OSes");
>> +    std::vector<std::string> OSes = R->getValueAsListOfStrings("OSes");
>>      for (auto I = OSes.begin(), E = OSes.end(); I != E; ++I) {
>> -      StringRef Part = *I;
>> +      std::string Part = *I;
>>
>>        Test += "T.getOS() == llvm::Triple::";
>>        Test += Part;
>> @@ -2666,9 +2670,9 @@ static void GenerateTargetSpecificAttrChecks(const
>> Record *R,
>>    // If one or more CXX ABIs are specified, check those as well.
>>    if (!R->isValueUnset("CXXABIs")) {
>>      Test += " && (";
>> -    std::vector<StringRef> CXXABIs = R->getValueAsListOfStrings("CX
>> XABIs");
>> +    std::vector<std::string> CXXABIs = R->getValueAsListOfStrings("CX
>> XABIs");
>>      for (auto I = CXXABIs.begin(), E = CXXABIs.end(); I != E; ++I) {
>> -      StringRef Part = *I;
>> +      std::string Part = *I;
>>        Test += "Target.getCXXABI().getKind() == TargetCXXABI::";
>>        Test += Part;
>>        if (I + 1 != E)
>> @@ -2708,7 +2712,7 @@ static void GenerateHasAttrSpellingStringSwitch(
>>      std::string Test;
>>      if (Attr->isSubClassOf("TargetSpecificAttr")) {
>>        const Record *R = Attr->getValueAsDef("Target");
>> -      std::vector<StringRef> Arches = R->getValueAsListOfStrings("Ar
>> ches");
>> +      std::vector<std::string> Arches = R->getValueAsListOfStrings("Ar
>> ches");
>>        GenerateTargetSpecificAttrChecks(R, Arches, Test, nullptr);
>>
>>        // If this is the C++11 variety, also add in the LangOpts test.
>> @@ -3360,7 +3364,7 @@ static std::string GenerateTargetRequirements(const
>> Record &Attr,
>>
>>    // Get the list of architectures to be tested for.
>>    const Record *R = Attr.getValueAsDef("Target");
>> -  std::vector<StringRef> Arches = R->getValueAsListOfStrings("Arches");
>> +  std::vector<std::string> Arches = R->getValueAsListOfStrings("Ar
>> ches");
>>    if (Arches.empty()) {
>>      PrintError(Attr.getLoc(), "Empty list of target architectures for a "
>>                                "target-specific attr");
>> @@ -3377,7 +3381,7 @@ static std::string GenerateTargetRequirements(const
>> Record &Attr,
>>      const StringRef APK = Attr.getValueAsString("ParseKind");
>>      for (const auto &I : Dupes) {
>>        if (I.first == APK) {
>> -        std::vector<StringRef> DA =
>> +        std::vector<std::string> DA =
>>              I.second->getValueAsDef("Target")->getValueAsListOfStrings(
>>                  "Arches");
>>          Arches.insert(Arches.end(), DA.begin(), DA.end());
>> @@ -3899,20 +3903,20 @@ void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper
>> &Records,
>>      std::vector<Record *> Subjects =
>>          SubjectObj->getValueAsListOfDefs("Subjects");
>>      OS << " (";
>> -    for (const auto &Subject : llvm::enumerate(Subjects)) {
>> -      if (Subject.index())
>> +    for (auto Subject : enumerate(Subjects)) {
>> +      if (Subject.Index)
>>          OS << ", ";
>>        PragmaClangAttributeSupport::RuleOrAggregateRuleSet &RuleSet =
>> -          Support.SubjectsToRules.find(Subject.value())->getSecond();
>> +          Support.SubjectsToRules.find(Subject.Value)->getSecond();
>>        if (RuleSet.isRule()) {
>>          OS << RuleSet.getRule().getEnumValueName();
>>          continue;
>>        }
>>        OS << "(";
>> -      for (const auto &Rule : llvm::enumerate(RuleSet.getAggregateRuleSet()))
>> {
>> -        if (Rule.index())
>> +      for (auto Rule : enumerate(RuleSet.getAggregateRuleSet())) {
>> +        if (Rule.Index)
>>            OS << ", ";
>> -        OS << Rule.value().getEnumValueName();
>> +        OS << Rule.Value.getEnumValueName();
>>        }
>>        OS << ")";
>>      }
>>
>> =====================================================
>> File clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
>> =====================================================
>>
>> $ git diff utils/TableGen/ClangDiagnosticsEmitter.cpp
>> diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp
>> b/utils/TableGen/ClangDiagnosticsEmitter.cpp
>> index d9d99e0..32f5317 100644
>> --- a/utils/TableGen/ClangDiagnosticsEmitter.cpp
>> +++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp
>> @@ -1278,7 +1278,7 @@ void EmitClangDiagDocs(RecordKeeper &Records,
>> raw_ostream &OS) {
>>                       GroupInfo.SubGroups.size() == 1;
>>
>>      writeHeader(((IsRemarkGroup ? "-R" : "-W") +
>> -                    G->getValueAsString("GroupName")).str(),
>> +                    G->getValueAsString("GroupName")),
>>                  OS);
>>
>>      if (!IsSynonym) {
>>
>> ===================================================
>> File clang/utils/TableGen/ClangOptionDocEmitter.cpp
>> ===================================================
>>
>> $ git diff utils/TableGen/ClangOptionDocEmitter.cpp
>> diff --git a/utils/TableGen/ClangOptionDocEmitter.cpp
>> b/utils/TableGen/ClangOptionDocEmitter.cpp
>> index 5931451..7e6566c 100644
>> --- a/utils/TableGen/ClangOptionDocEmitter.cpp
>> +++ b/utils/TableGen/ClangOptionDocEmitter.cpp
>> @@ -229,7 +229,7 @@ std::string getRSTStringWithTextFallback(const
>> Record *R, StringRef Primary,
>>  }
>>
>>  void emitOptionWithArgs(StringRef Prefix, const Record *Option,
>> -                        ArrayRef<StringRef> Args, raw_ostream &OS) {
>> +                        ArrayRef<std::string> Args, raw_ostream &OS) {
>>    OS << Prefix << escapeRST(Option->getValueAsString("Name"));
>>
>>    std::pair<StringRef, StringRef> Separators =
>> @@ -261,7 +261,7 @@ void emitOptionName(StringRef Prefix, const Record
>> *Option, raw_ostream &OS) {
>>      }
>>    }
>>
>> -  emitOptionWithArgs(Prefix, Option, std::vector<StringRef>(Args.begin(),
>> Args.end()), OS);
>> +  emitOptionWithArgs(Prefix, Option, std::vector<std::string>(Args.begin(),
>> Args.end()), OS);
>>
>>    auto AliasArgs = Option->getValueAsListOfStrings("AliasArgs");
>>    if (!AliasArgs.empty()) {
>> @@ -311,7 +311,7 @@ void emitOption(const DocumentedOption &Option, const
>> Record *DocInfo,
>>    forEachOptionName(Option, DocInfo, [&](const Record *Option) {
>>      for (auto &Prefix : Option->getValueAsListOfStrings("Prefixes"))
>>        SphinxOptionIDs.push_back(
>> -          getSphinxOptionID((Prefix + Option->getValueAsString("Name
>> ")).str()));
>> +          getSphinxOptionID((Prefix + Option->getValueAsString("Name
>> "))));
>>    });
>>    assert(!SphinxOptionIDs.empty() && "no flags for option");
>>    static std::map<std::string, int> NextSuffix;
>>
>> =================================================
>> file llvm/include/llvm/Support/SpecialCaseList.h:
>> =================================================
>>
>> $ git diff include/llvm/Support/SpecialCaseList.h
>> diff --git a/include/llvm/Support/SpecialCaseList.h
>> b/include/llvm/Support/SpecialCaseList.h
>> index ce693c5..dc8532c 100644
>> --- a/include/llvm/Support/SpecialCaseList.h
>> +++ b/include/llvm/Support/SpecialCaseList.h
>> @@ -82,12 +82,14 @@ public:
>>    bool inSection(StringRef Section, StringRef Query,
>>                   StringRef Category = StringRef()) const;
>>
>> -private:
>> +
>> +protected:
>>    SpecialCaseList(SpecialCaseList const &) = delete;
>>    SpecialCaseList &operator=(SpecialCaseList const &) = delete;
>>
>>    struct Entry;
>> -  StringMap<StringMap<Entry>> Entries;
>> +  using SectionEntries = StringMap<StringMap<Entry>>;
>> +  SectionEntries Entries;
>>    StringMap<StringMap<std::string>> Regexps;
>>    bool IsCompiled;
>>
>>
>>
>>
>> =================
>> Last compilation:
>> =================
>>
>> $make
>> ...
>> Scanning dependencies of target clangBasic
>> [ 68%] Building CXX object tools/clang/lib/Basic/CMakeFil
>> es/clangBasic.dir/SanitizerBlacklist.cpp.o
>> [ 68%] Building CXX object tools/clang/lib/Basic/CMakeFil
>> es/clangBasic.dir/SanitizerSpecialCaseList.cpp.o
>> /Users/marcio/clang-spirv/llvm/tools/clang/lib/Basic/SanitizerSpecialCaseList.cpp:23:13:
>> error:
>>       no member named 'createInternal' in 'clang::SanitizerSpecialCaseLi
>> st'
>>   if (SSCL->createInternal(Paths, Error)) {
>>       ~~~~  ^
>> /Users/marcio/clang-spirv/llvm/tools/clang/lib/Basic/SanitizerSpecialCaseList.cpp:39:18:
>> error:
>>       use of undeclared identifier 'Sections'; did you mean 'inSection'?
>>   for (auto &S : Sections) {
>>                  ^~~~~~~~
>>                  inSection
>> /Users/marcio/clang-spirv/llvm/tools/clang/include/clang/
>> Basic/SanitizerSpecialCaseList.h:34:8: note:
>>       'inSection' declared here
>>   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
>>        ^
>> /Users/marcio/clang-spirv/llvm/tools/clang/lib/Basic/SanitizerSpecialCaseList.cpp:39:18:
>> error:
>>       reference to non-static member function must be called
>>   for (auto &S : Sections) {
>>                  ^~~~~~~~
>> /Users/marcio/clang-spirv/llvm/tools/clang/lib/Basic/SanitizerSpecialCaseList.cpp:60:62:
>> error:
>>       too many arguments to function call, expected at most 3, have 4
>>         SpecialCaseList::inSection(S.Entries, Prefix, Query, Category))
>>         ~~~~~~~~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~
>> /Users/marcio/clang-spirv/llvm/include/llvm/Support/SpecialCaseList.h:82:3:
>> note:
>>       'inSection' declared here
>>   bool inSection(StringRef Section, StringRef Query,
>>   ^
>> 4 errors generated.
>> make[2]: *** [tools/clang/lib/Basic/CMakeFiles/clangBasic.dir/SanitizerSpecialCaseList.cpp.o]
>> Error 1
>> make[1]: *** [tools/clang/lib/Basic/CMakeFiles/clangBasic.dir/all] Error
>> 2
>> make: *** [all] Error 2
>>
>>
>> $make -j4
>> ...
>> [ 12%] Updating AttributesCompatFunc.inc...
>> [ 12%] Built target AttributeCompatFuncTableGen
>> /Users/marcio/clang-spirv/llvm/tools/clang/include/clang/Driver/Options.td:514:57:
>> [ 12%] Updating Attributes.gen...
>> error: Couldn't find class 'Values'
>>   HelpText<"OpenCL language standard to compile for.">,
>> Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0">;
>>                                                         ^
>> make[2]: *** [tools/clang/include/clang/Driver/Options.inc.tmp] Error 1
>> make[1]: *** [tools/clang/include/clang/Driver/CMakeFiles/ClangDriverOptions.dir/all]
>> Error 2
>> make[1]: *** Waiting for unfinished jobs....
>> [ 12%] Updating Intrinsics.gen...
>> [ 12%] Built target intrinsics_gen
>> [ 12%] Built target llvm-mcmarkup
>> [ 12%] Built target llvm-cxxfilt
>> make: *** [all] Error 2
>>
>> Cheers,
>> Marcio
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20171102/abf9dbcf/attachment-0001.html>


More information about the Openmp-dev mailing list