forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
206 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerCPU_cfi import testCUDAProducerCPU as _testCUDAProducerCPU | ||
prod1CPU = _testCUDAProducerCPU.clone() |
4 changes: 4 additions & 0 deletions
4
HeterogeneousCore/CUDATest/python/prod1CUDADeviceFilter_cfi.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDACore.cudaDeviceChooserFilter_cfi import cudaDeviceChooserFilter as _cudaDeviceChooserFilter | ||
prod1CUDADeviceFilter = _cudaDeviceChooserFilter.clone() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPUFirst_cfi import testCUDAProducerGPUFirst as _testCUDAProducerGPUFirst | ||
prod1CUDA = _testCUDAProducerGPUFirst.clone(src = "prod1CUDADeviceFilter") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPUtoCPU_cfi import testCUDAProducerGPUtoCPU as _testCUDAProducerGPUtoCPU | ||
prod1FromCUDA = _testCUDAProducerGPUtoCPU.clone(src = "prod1CUDA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.prod1CUDADeviceFilter_cfi import prod1CUDADeviceFilter | ||
from HeterogeneousCore.CUDATest.prod1CPU_cfi import prod1CPU | ||
from HeterogeneousCore.CUDATest.prod1CUDA_cfi import prod1CUDA | ||
from HeterogeneousCore.CUDATest.prod1FromCUDA_cfi import prod1FromCUDA | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerFallback_cfi import testCUDAProducerFallback as _testCUDAProducerFallback | ||
|
||
prod1 = _testCUDAProducerFallback.clone(src = ["prod1CUDA", "prod1CPU"]) | ||
|
||
prod1PathCUDA = cms.Path( | ||
prod1CUDADeviceFilter + | ||
prod1CUDA | ||
) | ||
prod1PathCPU = cms.Path( | ||
~prod1CUDADeviceFilter + | ||
prod1CPU | ||
) | ||
|
||
prod1Task = cms.Task( | ||
prod1FromCUDA, prod1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerCPU_cfi import testCUDAProducerCPU as _testCUDAProducerCPU | ||
prod5CPU = _testCUDAProducerCPU.clone() |
4 changes: 4 additions & 0 deletions
4
HeterogeneousCore/CUDATest/python/prod5CUDADeviceFilter_cfi.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDACore.cudaDeviceChooserFilter_cfi import cudaDeviceChooserFilter as _cudaDeviceChooserFilter | ||
prod5CUDADeviceFilter = _cudaDeviceChooserFilter.clone() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPUFirst_cfi import testCUDAProducerGPUFirst as _testCUDAProducerGPUFirst | ||
prod5CUDA = _testCUDAProducerGPUFirst.clone(src = "prod5CUDADeviceFilter") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerFallback_cfi import testCUDAProducerFallback as _testCUDAProducerFallback | ||
prod5Fallback = _testCUDAProducerFallback.clone() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPUtoCPU_cfi import testCUDAProducerGPUtoCPU as _testCUDAProducerGPUtoCPU | ||
prod5FromCUDA = _testCUDAProducerGPUtoCPU.clone(src = "pro56CUDA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.prod5CUDADeviceFilter_cfi import prod5CUDADeviceFilter | ||
|
||
# The prod6 is the final, (legacy) CPU-only product name, and the | ||
# prod6Task is the Task containing all modules. The function itself | ||
# sets up everything else. | ||
from HeterogeneousCore.CUDATest.setupHeterogeneous import setupCUDA | ||
(prod5, prod5Task) = setupCUDA("prod5", prod5CUDADeviceFilter, globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerCPU_cfi import testCUDAProducerCPU as _testCUDAProducerCPU | ||
prod6CPU = _testCUDAProducerCPU.clone(src = "prod5CPU") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPU_cfi import testCUDAProducerGPU as _testCUDAProducerGPU | ||
prod6CUDA = _testCUDAProducerGPU.clone(src = "prod5CUDA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerFallback_cfi import testCUDAProducerFallback as _testCUDAProducerFallback | ||
prod6Fallback = _testCUDAProducerFallback.clone() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.testCUDAProducerGPUtoCPU_cfi import testCUDAProducerGPUtoCPU as _testCUDAProducerGPUtoCPU | ||
prod6FromCUDA = _testCUDAProducerGPUtoCPU.clone(src = "prod6CUDA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from HeterogeneousCore.CUDATest.prod5CUDADeviceFilter_cfi import prod5CUDADeviceFilter | ||
|
||
# The prod6 is the final, (legacy) CPU-only product name, and the | ||
# prod6Task is the Task containing all modules. The function itself | ||
# sets up everything else. | ||
from HeterogeneousCore.CUDATest.setupHeterogeneous import setupHeterogeneous | ||
(prod6, prod6Task) = setupHeterogeneous("prod6", ["CUDA", "CPU"], {"CUDA": prod5CUDADeviceFilter}, globals()) |
101 changes: 101 additions & 0 deletions
101
HeterogeneousCore/CUDATest/python/setupHeterogeneous.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# Prototype of the function | ||
import importlib | ||
def setupHeterogeneous(prefix, deviceTypes, deviceFilters, modDict, | ||
package=None, transferModuleNames={}, fallbackModuleName=None): | ||
""" | ||
Mandatory parameters: | ||
prefix -- common prefix of the CPU, CUDA, etc producers | ||
deviceTypes -- list of strings for the device types | ||
deviceFilters -- dict of non-CPU device types to device filter modules | ||
modDict -- globals() | ||
Optional parameters: | ||
package -- Package of the modules (default None signals to use the current package) | ||
transferModuleName -- Dictionary for names of the device->CPU modules to be loaded and inserted in modDict (if the dictionary does not contain a key 'prefix', a default value of 'prefix+'From<device>' will be used) | ||
fallbackModuleName -- Name of the devices+CPU product fallback producer to be loaded (default None means prefix+'Fallback') | ||
Returns a pair of | ||
- something which looks like an EDProducer picking the product from devices+CPU | ||
- Task containing all the added modules | ||
""" | ||
path = "" | ||
if package is None: | ||
pkgs = __name__.split(".") | ||
if len(pkgs) > 1: | ||
path = ".".join(pkgs[:-1])+"." | ||
else: | ||
path = package+"." | ||
|
||
# Per-device producers | ||
for dt in deviceTypes: | ||
modName = prefix+dt | ||
pkg = importlib.import_module(path+modName+"_cfi") | ||
mod = getattr(pkg, modName) | ||
modDict[modName] = mod | ||
|
||
# device->CPU | ||
for dt in deviceTypes: | ||
if dt == "CPU": | ||
continue | ||
transferModName = transferModuleNames.get(dt, prefix+"From"+dt) | ||
|
||
transferModPath = path+transferModName+"_cfi" | ||
transferModPkg = importlib.import_module(transferModPath) | ||
transferMod = getattr(transferModPkg, transferModName).clone(src=prefix+dt) | ||
modDict[transferModName] = transferMod | ||
|
||
# Fallback | ||
if fallbackModuleName is None: | ||
fallbackModName = prefix+"Fallback" | ||
else: | ||
fallbackModName = fallbackModuleName | ||
fallbackModPath = path+fallbackModName+"_cfi" | ||
fallbackModPkg = importlib.import_module(fallbackModPath) | ||
def _from(s): | ||
if s == "CPU": | ||
return s | ||
return "From"+s | ||
fallback = getattr(fallbackModPkg, fallbackModName).clone(src=[prefix+_from(dt) for dt in deviceTypes]) | ||
|
||
# Paths | ||
tmp = {} | ||
for dt in deviceTypes: | ||
tmp[dt] = cms.Path() | ||
|
||
for dt in deviceTypes: | ||
p = cms.Path() | ||
|
||
# Add inverted filters until the current device type is found, then insert filter and stop | ||
# For [CUDA, FPGA, CPU] results in | ||
# CUDA: CUDAFilter | ||
# FPGA: ~CUDAFilter + FPGAFilter | ||
# CPU: ~CUDAFilter + ~FPGAFilter | ||
for dt2 in deviceTypes: | ||
if dt2 == "CPU": | ||
continue | ||
filt = deviceFilters[dt2] | ||
if dt2 == dt: | ||
p += filt | ||
break | ||
else: | ||
p += ~filt | ||
|
||
# Finally add the producer of the type | ||
p += modDict[prefix+dt] | ||
|
||
modDict[prefix+"Path"+dt] = p | ||
|
||
# Task | ||
task = cms.Task(transferMod, fallback) | ||
|
||
return (fallback, task) | ||
|
||
def setupCUDA(prefix, deviceFilter, modDict, | ||
package=None, transferModule=None, **kwargs): | ||
transfer = {} | ||
if transferModule is not None: | ||
transfer["CUDA"] = transferModule | ||
return setupHeterogeneous(prefix, ["CUDA", "CPU"], {"CUDA": deviceFilter}, modDict, | ||
package, transfer, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters