Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-24 02:12:49

0001 #include "catch.hpp"
0002 
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0005 
0006 #include <fmt/format.h>
0007 
0008 #include <iostream>
0009 #include <string_view>
0010 
0011 static constexpr auto s_tag = "[ProcessAcceleratorCUDA]";
0012 
0013 namespace {
0014   std::string makeConfig(std::string_view cpu, std::string_view cuda, std::string_view accelerator) {
0015     return fmt::format(
0016         R"_(import FWCore.ParameterSet.Config as cms
0017 
0018 process = cms.Process("TEST")
0019 process.options.accelerators = [{}]
0020 
0021 process.load("HeterogeneousCore.CUDACore.ProcessAcceleratorCUDA_cfi")
0022 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import *
0023 
0024 process.s = SwitchProducerCUDA(
0025    cpu = {},
0026    cuda = {}
0027 )
0028 process.p = cms.Path(process.s)
0029 )_",
0030         accelerator,
0031         cpu,
0032         cuda);
0033   }
0034 }  // namespace
0035 
0036 TEST_CASE("Configuration", s_tag) {
0037   const std::string test1{"cms.EDProducer('IntProducer', ivalue = cms.int32(1))"};
0038   const std::string test2{"cms.EDProducer('ManyIntProducer', ivalue = cms.int32(2), values = cms.VPSet())"};
0039 
0040   const std::string baseConfig_auto = makeConfig(test1, test2, "'*'");
0041   const std::string baseConfig_cpu = makeConfig(test1, test2, "'cpu'");
0042   const std::string baseConfig_cuda = makeConfig(test1, test2, "'gpu-nvidia'");
0043 
0044   SECTION("Configuration hash is not changed") {
0045     auto pset_auto = edm::readConfig(baseConfig_auto);
0046     auto pset_cpu = edm::readConfig(baseConfig_cpu);
0047     auto pset_cuda = edm::readConfig(baseConfig_cuda);
0048     pset_auto->registerIt();
0049     pset_cpu->registerIt();
0050     pset_cuda->registerIt();
0051     REQUIRE(pset_auto->id() == pset_cpu->id());
0052     REQUIRE(pset_auto->id() == pset_cuda->id());
0053   }
0054 }