YARN-9270. Minor cleanup in TestFpgaDiscoverer. Contributed by Peter Bacsko.
This commit is contained in:
parent
7dc0ecc446
commit
56f1e131ec
@ -64,6 +64,8 @@ public class FpgaResourceHandlerImpl implements ResourceHandler {
|
|||||||
|
|
||||||
private final CGroupsHandler cGroupsHandler;
|
private final CGroupsHandler cGroupsHandler;
|
||||||
|
|
||||||
|
private final FpgaDiscoverer fpgaDiscoverer;
|
||||||
|
|
||||||
public static final String EXCLUDED_FPGAS_CLI_OPTION = "--excluded_fpgas";
|
public static final String EXCLUDED_FPGAS_CLI_OPTION = "--excluded_fpgas";
|
||||||
public static final String CONTAINER_ID_CLI_OPTION = "--container_id";
|
public static final String CONTAINER_ID_CLI_OPTION = "--container_id";
|
||||||
private PrivilegedOperationExecutor privilegedOperationExecutor;
|
private PrivilegedOperationExecutor privilegedOperationExecutor;
|
||||||
@ -72,10 +74,11 @@ public class FpgaResourceHandlerImpl implements ResourceHandler {
|
|||||||
public FpgaResourceHandlerImpl(Context nmContext,
|
public FpgaResourceHandlerImpl(Context nmContext,
|
||||||
CGroupsHandler cGroupsHandler,
|
CGroupsHandler cGroupsHandler,
|
||||||
PrivilegedOperationExecutor privilegedOperationExecutor,
|
PrivilegedOperationExecutor privilegedOperationExecutor,
|
||||||
AbstractFpgaVendorPlugin plugin) {
|
AbstractFpgaVendorPlugin plugin,
|
||||||
|
FpgaDiscoverer fpgaDiscoverer) {
|
||||||
this.allocator = new FpgaResourceAllocator(nmContext);
|
this.allocator = new FpgaResourceAllocator(nmContext);
|
||||||
this.vendorPlugin = plugin;
|
this.vendorPlugin = plugin;
|
||||||
FpgaDiscoverer.getInstance().setResourceHanderPlugin(vendorPlugin);
|
this.fpgaDiscoverer = fpgaDiscoverer;
|
||||||
this.cGroupsHandler = cGroupsHandler;
|
this.cGroupsHandler = cGroupsHandler;
|
||||||
this.privilegedOperationExecutor = privilegedOperationExecutor;
|
this.privilegedOperationExecutor = privilegedOperationExecutor;
|
||||||
}
|
}
|
||||||
@ -99,8 +102,7 @@ public class FpgaResourceHandlerImpl implements ResourceHandler {
|
|||||||
}
|
}
|
||||||
LOG.info("FPGA Plugin bootstrap success.");
|
LOG.info("FPGA Plugin bootstrap success.");
|
||||||
// Get avialable devices minor numbers from toolchain or static configuration
|
// Get avialable devices minor numbers from toolchain or static configuration
|
||||||
List<FpgaResourceAllocator.FpgaDevice> fpgaDeviceList =
|
List<FpgaDevice> fpgaDeviceList = fpgaDiscoverer.discover();
|
||||||
FpgaDiscoverer.getInstance().discover();
|
|
||||||
allocator.addFpgaDevices(vendorPlugin.getFpgaType(), fpgaDeviceList);
|
allocator.addFpgaDevices(vendorPlugin.getFpgaType(), fpgaDeviceList);
|
||||||
this.cGroupsHandler.initializeCGroupController(
|
this.cGroupsHandler.initializeCGroupController(
|
||||||
CGroupsHandler.CGroupController.DEVICES);
|
CGroupsHandler.CGroupController.DEVICES);
|
||||||
@ -183,7 +185,7 @@ public class FpgaResourceHandlerImpl implements ResourceHandler {
|
|||||||
" if you want YARN to program the device");
|
" if you want YARN to program the device");
|
||||||
} else {
|
} else {
|
||||||
LOG.info("IP file path:" + ipFilePath);
|
LOG.info("IP file path:" + ipFilePath);
|
||||||
List<FpgaResourceAllocator.FpgaDevice> allowed = allocation.getAllowed();
|
List<FpgaDevice> allowed = allocation.getAllowed();
|
||||||
String majorMinorNumber;
|
String majorMinorNumber;
|
||||||
for (int i = 0; i < allowed.size(); i++) {
|
for (int i = 0; i < allowed.size(); i++) {
|
||||||
FpgaDevice device = allowed.get(i);
|
FpgaDevice device = allowed.get(i);
|
||||||
|
@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator;
|
||||||
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator.FpgaDevice;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.AoclOutputBasedDiscoveryStrategy;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.AoclOutputBasedDiscoveryStrategy;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.FPGADiscoveryStrategy;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.FPGADiscoveryStrategy;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.ScriptBasedFPGADiscoveryStrategy;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.discovery.ScriptBasedFPGADiscoveryStrategy;
|
||||||
@ -49,12 +50,8 @@ public class FpgaDiscoverer {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(
|
private static final Logger LOG = LoggerFactory.getLogger(
|
||||||
FpgaDiscoverer.class);
|
FpgaDiscoverer.class);
|
||||||
|
|
||||||
private static FpgaDiscoverer instance;
|
|
||||||
|
|
||||||
private Configuration conf = null;
|
private Configuration conf = null;
|
||||||
|
|
||||||
private AbstractFpgaVendorPlugin plugin = null;
|
private AbstractFpgaVendorPlugin plugin = null;
|
||||||
|
|
||||||
private List<FpgaResourceAllocator.FpgaDevice> currentFpgaInfo = null;
|
private List<FpgaResourceAllocator.FpgaDevice> currentFpgaInfo = null;
|
||||||
|
|
||||||
private Function<String, Optional<String>> scriptRunner = this::runScript;
|
private Function<String, Optional<String>> scriptRunner = this::runScript;
|
||||||
@ -62,36 +59,17 @@ public class FpgaDiscoverer {
|
|||||||
// shell command timeout
|
// shell command timeout
|
||||||
public static final int MAX_EXEC_TIMEOUT_MS = 10 * 1000;
|
public static final int MAX_EXEC_TIMEOUT_MS = 10 * 1000;
|
||||||
|
|
||||||
static {
|
|
||||||
instance = new FpgaDiscoverer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FpgaDiscoverer getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setScriptRunner(Function<String, Optional<String>> scriptRunner) {
|
void setScriptRunner(Function<String, Optional<String>> scriptRunner) {
|
||||||
this.scriptRunner = scriptRunner;
|
this.scriptRunner = scriptRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static void reset() {
|
|
||||||
instance = new FpgaDiscoverer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public static FpgaDiscoverer setInstance(FpgaDiscoverer newInstance) {
|
|
||||||
instance = newInstance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setConf(Configuration configuration) {
|
public void setConf(Configuration configuration) {
|
||||||
this.conf = configuration;
|
this.conf = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FpgaResourceAllocator.FpgaDevice> getCurrentFpgaInfo() {
|
public List<FpgaDevice> getCurrentFpgaInfo() {
|
||||||
return currentFpgaInfo;
|
return currentFpgaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +97,9 @@ public class FpgaDiscoverer {
|
|||||||
* @return the list of FPGA devices
|
* @return the list of FPGA devices
|
||||||
* @throws ResourceHandlerException if there's any error during discovery
|
* @throws ResourceHandlerException if there's any error during discovery
|
||||||
**/
|
**/
|
||||||
public List<FpgaResourceAllocator.FpgaDevice> discover()
|
public List<FpgaDevice> discover()
|
||||||
throws ResourceHandlerException {
|
throws ResourceHandlerException {
|
||||||
List<FpgaResourceAllocator.FpgaDevice> list;
|
List<FpgaDevice> list;
|
||||||
String allowed = this.conf.get(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES);
|
String allowed = this.conf.get(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES);
|
||||||
|
|
||||||
String availableDevices = conf.get(
|
String availableDevices = conf.get(
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga;
|
||||||
|
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.api.records.ResourceInformation.FPGA_URI;
|
import static org.apache.hadoop.yarn.api.records.ResourceInformation.FPGA_URI;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -30,22 +29,28 @@ import org.apache.hadoop.yarn.api.records.Resource;
|
|||||||
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator.FpgaDevice;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.NodeResourceUpdaterPlugin;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.NodeResourceUpdaterPlugin;
|
||||||
import org.apache.hadoop.yarn.util.resource.ResourceUtils;
|
import org.apache.hadoop.yarn.util.resource.ResourceUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class FpgaNodeResourceUpdateHandler extends NodeResourceUpdaterPlugin {
|
public class FpgaNodeResourceUpdateHandler extends NodeResourceUpdaterPlugin {
|
||||||
|
private final FpgaDiscoverer fpgaDiscoverer;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(
|
private static final Logger LOG = LoggerFactory.getLogger(
|
||||||
FpgaNodeResourceUpdateHandler.class);
|
FpgaNodeResourceUpdateHandler.class);
|
||||||
|
|
||||||
|
public FpgaNodeResourceUpdateHandler(FpgaDiscoverer fpgaDiscoverer) {
|
||||||
|
this.fpgaDiscoverer = fpgaDiscoverer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateConfiguredResource(Resource res) throws YarnException {
|
public void updateConfiguredResource(Resource res) throws YarnException {
|
||||||
LOG.info("Initializing configured FPGA resources for the NodeManager.");
|
LOG.info("Initializing configured FPGA resources for the NodeManager.");
|
||||||
List<FpgaResourceAllocator.FpgaDevice> list = FpgaDiscoverer.getInstance().getCurrentFpgaInfo();
|
List<FpgaDevice> list = fpgaDiscoverer.getCurrentFpgaInfo();
|
||||||
List<Integer> minors = new LinkedList<>();
|
List<Integer> minors = new LinkedList<>();
|
||||||
for (FpgaResourceAllocator.FpgaDevice device : list) {
|
for (FpgaDevice device : list) {
|
||||||
minors.add(device.getMinor());
|
minors.add(device.getMinor());
|
||||||
}
|
}
|
||||||
if (minors.isEmpty()) {
|
if (minors.isEmpty()) {
|
||||||
|
@ -44,6 +44,7 @@ public class FpgaResourcePlugin implements ResourcePlugin {
|
|||||||
|
|
||||||
private AbstractFpgaVendorPlugin vendorPlugin = null;
|
private AbstractFpgaVendorPlugin vendorPlugin = null;
|
||||||
private FpgaNodeResourceUpdateHandler fpgaNodeResourceUpdateHandler = null;
|
private FpgaNodeResourceUpdateHandler fpgaNodeResourceUpdateHandler = null;
|
||||||
|
private FpgaDiscoverer fpgaDiscoverer;
|
||||||
|
|
||||||
private AbstractFpgaVendorPlugin createFpgaVendorPlugin(Configuration conf) {
|
private AbstractFpgaVendorPlugin createFpgaVendorPlugin(Configuration conf) {
|
||||||
String vendorPluginClass = conf.get(YarnConfiguration.NM_FPGA_VENDOR_PLUGIN,
|
String vendorPluginClass = conf.get(YarnConfiguration.NM_FPGA_VENDOR_PLUGIN,
|
||||||
@ -68,9 +69,11 @@ public class FpgaResourcePlugin implements ResourcePlugin {
|
|||||||
public void initialize(Context context) throws YarnException {
|
public void initialize(Context context) throws YarnException {
|
||||||
// Get vendor plugin from configuration
|
// Get vendor plugin from configuration
|
||||||
this.vendorPlugin = createFpgaVendorPlugin(context.getConf());
|
this.vendorPlugin = createFpgaVendorPlugin(context.getConf());
|
||||||
FpgaDiscoverer.getInstance().setResourceHanderPlugin(vendorPlugin);
|
fpgaDiscoverer = new FpgaDiscoverer();
|
||||||
FpgaDiscoverer.getInstance().initialize(context.getConf());
|
fpgaDiscoverer.setResourceHanderPlugin(vendorPlugin);
|
||||||
fpgaNodeResourceUpdateHandler = new FpgaNodeResourceUpdateHandler();
|
fpgaDiscoverer.initialize(context.getConf());
|
||||||
|
fpgaNodeResourceUpdateHandler =
|
||||||
|
new FpgaNodeResourceUpdateHandler(fpgaDiscoverer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,7 +82,8 @@ public class FpgaResourcePlugin implements ResourcePlugin {
|
|||||||
PrivilegedOperationExecutor privilegedOperationExecutor) {
|
PrivilegedOperationExecutor privilegedOperationExecutor) {
|
||||||
if (fpgaResourceHandler == null) {
|
if (fpgaResourceHandler == null) {
|
||||||
fpgaResourceHandler = new FpgaResourceHandlerImpl(nmContext,
|
fpgaResourceHandler = new FpgaResourceHandlerImpl(nmContext,
|
||||||
cGroupsHandler, privilegedOperationExecutor, vendorPlugin);
|
cGroupsHandler, privilegedOperationExecutor, vendorPlugin,
|
||||||
|
fpgaDiscoverer);
|
||||||
}
|
}
|
||||||
return fpgaResourceHandler;
|
return fpgaResourceHandler;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
|||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ResourceMappings;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ResourceMappings;
|
||||||
@ -91,16 +92,18 @@ public class TestFpgaResourceHandler {
|
|||||||
private ConcurrentHashMap<ContainerId, Container> runningContainersMap;
|
private ConcurrentHashMap<ContainerId, Container> runningContainersMap;
|
||||||
private IntelFpgaOpenclPlugin mockVendorPlugin;
|
private IntelFpgaOpenclPlugin mockVendorPlugin;
|
||||||
private List<FpgaDevice> deviceList;
|
private List<FpgaDevice> deviceList;
|
||||||
|
private FpgaDiscoverer fpgaDiscoverer;
|
||||||
private static final String vendorType = "IntelOpenCL";
|
private static final String vendorType = "IntelOpenCL";
|
||||||
private File dummyAocx;
|
private File dummyAocx;
|
||||||
|
|
||||||
private String getTestParentFolder() {
|
private String getTestParentFolder() {
|
||||||
File f = new File("target/temp/" + TestFpgaResourceHandler.class.getName());
|
File f = new File("target/temp/" +
|
||||||
|
TestFpgaResourceHandler.class.getName());
|
||||||
return f.getAbsolutePath();
|
return f.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException, YarnException {
|
||||||
CustomResourceTypesConfigurationProvider.
|
CustomResourceTypesConfigurationProvider.
|
||||||
initResourceTypes(ResourceInformation.FPGA_URI);
|
initResourceTypes(ResourceInformation.FPGA_URI);
|
||||||
configuration = new YarnConfiguration();
|
configuration = new YarnConfiguration();
|
||||||
@ -116,13 +119,16 @@ public class TestFpgaResourceHandler {
|
|||||||
}
|
}
|
||||||
String aocxPath = getTestParentFolder() + "/test.aocx";
|
String aocxPath = getTestParentFolder() + "/test.aocx";
|
||||||
mockVendorPlugin = mockPlugin(vendorType, deviceList, aocxPath);
|
mockVendorPlugin = mockPlugin(vendorType, deviceList, aocxPath);
|
||||||
FpgaDiscoverer.getInstance().setConf(configuration);
|
fpgaDiscoverer = new FpgaDiscoverer();
|
||||||
|
fpgaDiscoverer.setResourceHanderPlugin(mockVendorPlugin);
|
||||||
|
fpgaDiscoverer.initialize(configuration);
|
||||||
when(mockContext.getNMStateStore()).thenReturn(mockNMStateStore);
|
when(mockContext.getNMStateStore()).thenReturn(mockNMStateStore);
|
||||||
runningContainersMap = new ConcurrentHashMap<>();
|
runningContainersMap = new ConcurrentHashMap<>();
|
||||||
when(mockContext.getContainers()).thenReturn(runningContainersMap);
|
when(mockContext.getContainers()).thenReturn(runningContainersMap);
|
||||||
|
|
||||||
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
||||||
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin);
|
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
|
||||||
|
fpgaDiscoverer);
|
||||||
|
|
||||||
dummyAocx = new File(aocxPath);
|
dummyAocx = new File(aocxPath);
|
||||||
Files.createParentDirs(dummyAocx);
|
Files.createParentDirs(dummyAocx);
|
||||||
@ -143,7 +149,8 @@ public class TestFpgaResourceHandler {
|
|||||||
String allowed = "auto";
|
String allowed = "auto";
|
||||||
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
||||||
fpgaResourceHandler.bootstrap(configuration);
|
fpgaResourceHandler.bootstrap(configuration);
|
||||||
verify(mockVendorPlugin, times(1)).initPlugin(configuration);
|
// initPlugin() was also called in setup()
|
||||||
|
verify(mockVendorPlugin, times(2)).initPlugin(configuration);
|
||||||
verify(mockCGroupsHandler, times(1)).initializeCGroupController(
|
verify(mockCGroupsHandler, times(1)).initializeCGroupController(
|
||||||
CGroupsHandler.CGroupController.DEVICES);
|
CGroupsHandler.CGroupController.DEVICES);
|
||||||
Assert.assertEquals(5, fpgaResourceHandler.getFpgaAllocator()
|
Assert.assertEquals(5, fpgaResourceHandler.getFpgaAllocator()
|
||||||
@ -152,7 +159,8 @@ public class TestFpgaResourceHandler {
|
|||||||
.getAllowedFpga().size());
|
.getAllowedFpga().size());
|
||||||
// Case 2. subset of devices
|
// Case 2. subset of devices
|
||||||
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
||||||
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin);
|
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
|
||||||
|
fpgaDiscoverer);
|
||||||
allowed = "0,1,2";
|
allowed = "0,1,2";
|
||||||
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
||||||
fpgaResourceHandler.bootstrap(configuration);
|
fpgaResourceHandler.bootstrap(configuration);
|
||||||
@ -174,7 +182,8 @@ public class TestFpgaResourceHandler {
|
|||||||
|
|
||||||
// Case 3. User configuration contains invalid minor device number
|
// Case 3. User configuration contains invalid minor device number
|
||||||
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
||||||
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin);
|
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
|
||||||
|
fpgaDiscoverer);
|
||||||
allowed = "0,1,7";
|
allowed = "0,1,7";
|
||||||
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
|
||||||
fpgaResourceHandler.bootstrap(configuration);
|
fpgaResourceHandler.bootstrap(configuration);
|
||||||
@ -509,7 +518,8 @@ public class TestFpgaResourceHandler {
|
|||||||
mockVendorPlugin =
|
mockVendorPlugin =
|
||||||
mockPlugin(vendorType, deviceList, dummyAocx.getAbsolutePath());
|
mockPlugin(vendorType, deviceList, dummyAocx.getAbsolutePath());
|
||||||
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
|
||||||
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin);
|
mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
|
||||||
|
fpgaDiscoverer);
|
||||||
|
|
||||||
fpgaResourceHandler.bootstrap(configuration);
|
fpgaResourceHandler.bootstrap(configuration);
|
||||||
fpgaResourceHandler.preStart(mockContainer(0, 1, "GEMM"));
|
fpgaResourceHandler.preStart(mockContainer(0, 1, "GEMM"));
|
||||||
|
@ -28,8 +28,6 @@ import static org.mockito.Mockito.when;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,6 +39,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator.FpgaDevice;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.fpga.FpgaResourceAllocator.FpgaDevice;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -50,6 +49,11 @@ public class TestFpgaDiscoverer {
|
|||||||
@Rule
|
@Rule
|
||||||
public ExpectedException expected = ExpectedException.none();
|
public ExpectedException expected = ExpectedException.none();
|
||||||
|
|
||||||
|
private File fakeBinary;
|
||||||
|
private IntelFpgaOpenclPlugin openclPlugin;
|
||||||
|
private Configuration conf;
|
||||||
|
private FpgaDiscoverer fpgaDiscoverer;
|
||||||
|
|
||||||
private String getTestParentFolder() {
|
private String getTestParentFolder() {
|
||||||
File f = new File("target/temp/" + TestFpgaDiscoverer.class.getName());
|
File f = new File("target/temp/" + TestFpgaDiscoverer.class.getName());
|
||||||
return f.getAbsolutePath();
|
return f.getAbsolutePath();
|
||||||
@ -65,110 +69,97 @@ public class TestFpgaDiscoverer {
|
|||||||
File f = new File(folder);
|
File f = new File(folder);
|
||||||
FileUtils.deleteDirectory(f);
|
FileUtils.deleteDirectory(f);
|
||||||
f.mkdirs();
|
f.mkdirs();
|
||||||
FpgaDiscoverer.reset();
|
|
||||||
|
conf = new Configuration();
|
||||||
|
|
||||||
|
openclPlugin = new IntelFpgaOpenclPlugin();
|
||||||
|
openclPlugin.initPlugin(conf);
|
||||||
|
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
||||||
|
|
||||||
|
fpgaDiscoverer = new FpgaDiscoverer();
|
||||||
|
fpgaDiscoverer.setResourceHanderPlugin(openclPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A dirty hack to modify the env of the current JVM itself - Dirty, but
|
@After
|
||||||
// should be okay for testing.
|
public void afterTest() {
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
if (fakeBinary != null) {
|
||||||
private static void setNewEnvironmentHack(Map<String, String> newenv)
|
fakeBinary.delete();
|
||||||
throws Exception {
|
|
||||||
try {
|
|
||||||
Class<?> cl = Class.forName("java.lang.ProcessEnvironment");
|
|
||||||
Field field = cl.getDeclaredField("theEnvironment");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Map<String, String> env = (Map<String, String>) field.get(null);
|
|
||||||
env.clear();
|
|
||||||
env.putAll(newenv);
|
|
||||||
Field ciField = cl.getDeclaredField("theCaseInsensitiveEnvironment");
|
|
||||||
ciField.setAccessible(true);
|
|
||||||
Map<String, String> cienv = (Map<String, String>) ciField.get(null);
|
|
||||||
cienv.clear();
|
|
||||||
cienv.putAll(newenv);
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
Class[] classes = Collections.class.getDeclaredClasses();
|
|
||||||
Map<String, String> env = System.getenv();
|
|
||||||
for (Class cl : classes) {
|
|
||||||
if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
|
|
||||||
Field field = cl.getDeclaredField("m");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Object obj = field.get(env);
|
|
||||||
Map<String, String> map = (Map<String, String>) obj;
|
|
||||||
map.clear();
|
|
||||||
map.putAll(newenv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLinuxFpgaResourceDiscoverPluginConfig() throws Exception {
|
public void testExecutablePathWithoutExplicitConfig()
|
||||||
Configuration conf = new Configuration(false);
|
throws YarnException {
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
|
||||||
// because FPGA discoverer is a singleton, we use setPlugin to make
|
|
||||||
// FpgaDiscoverer.getInstance().diagnose() work in openclPlugin.initPlugin()
|
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
// Case 1. No configuration set for binary(no environment "ALTERAOCLSDKROOT" set)
|
|
||||||
assertEquals("No configuration(no environment ALTERAOCLSDKROOT set)" +
|
assertEquals("No configuration(no environment ALTERAOCLSDKROOT set)" +
|
||||||
" should return just a single binary name",
|
" should return just a single binary name",
|
||||||
"aocl", openclPlugin.getPathToExecutable());
|
"aocl", openclPlugin.getPathToExecutable());
|
||||||
|
}
|
||||||
|
|
||||||
// Case 2. With correct configuration and file exists
|
@Test
|
||||||
File fakeBinary = new File(getTestParentFolder() + "/aocl");
|
public void testExecutablePathWithCorrectConfig()
|
||||||
conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, getTestParentFolder() + "/aocl");
|
throws IOException, YarnException {
|
||||||
|
fakeBinary = new File(getTestParentFolder() + "/aocl");
|
||||||
|
conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC,
|
||||||
|
getTestParentFolder() + "/aocl");
|
||||||
touchFile(fakeBinary);
|
touchFile(fakeBinary);
|
||||||
discoverer.initialize(conf);
|
|
||||||
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
|
||||||
assertEquals("Correct configuration should return user setting",
|
assertEquals("Correct configuration should return user setting",
|
||||||
getTestParentFolder() + "/aocl", openclPlugin.getPathToExecutable());
|
getTestParentFolder() + "/aocl", openclPlugin.getPathToExecutable());
|
||||||
|
}
|
||||||
|
|
||||||
// Case 3. With correct configuration but file doesn't exists. Use default
|
@Test
|
||||||
fakeBinary.delete();
|
public void testExecutablePathWhenFileDoesNotExist()
|
||||||
discoverer.initialize(conf);
|
throws YarnException {
|
||||||
assertEquals("Should return just a single binary name",
|
conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC,
|
||||||
|
getTestParentFolder() + "/aocl");
|
||||||
|
|
||||||
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
|
||||||
|
assertEquals("File doesn't exists - expected a single binary name",
|
||||||
"aocl", openclPlugin.getPathToExecutable());
|
"aocl", openclPlugin.getPathToExecutable());
|
||||||
|
}
|
||||||
|
|
||||||
// Case 4. Set a empty value
|
@Test
|
||||||
|
public void testExecutablePathWhenFileIsEmpty()
|
||||||
|
throws YarnException {
|
||||||
conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, "");
|
conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, "");
|
||||||
discoverer.initialize(conf);
|
|
||||||
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
|
||||||
assertEquals("configuration with empty string value, should use aocl",
|
assertEquals("configuration with empty string value, should use aocl",
|
||||||
"aocl", openclPlugin.getPathToExecutable());
|
"aocl", openclPlugin.getPathToExecutable());
|
||||||
|
}
|
||||||
|
|
||||||
// Case 5. No configuration set for binary, but set environment "ALTERAOCLSDKROOT"
|
@Test
|
||||||
// we load the default configuration to start with
|
public void testExecutablePathWithSdkRootSet()
|
||||||
conf = new Configuration(true);
|
throws IOException, YarnException {
|
||||||
fakeBinary = new File(getTestParentFolder() + "/bin/aocl");
|
fakeBinary = new File(getTestParentFolder() + "/bin/aocl");
|
||||||
fakeBinary.getParentFile().mkdirs();
|
fakeBinary.getParentFile().mkdirs();
|
||||||
touchFile(fakeBinary);
|
touchFile(fakeBinary);
|
||||||
Map<String, String> newEnv = new HashMap<String, String>();
|
Map<String, String> newEnv = new HashMap<String, String>();
|
||||||
newEnv.put("ALTERAOCLSDKROOT", getTestParentFolder());
|
newEnv.put("ALTERAOCLSDKROOT", getTestParentFolder());
|
||||||
setNewEnvironmentHack(newEnv);
|
openclPlugin.setEnvProvider(s -> {
|
||||||
discoverer.initialize(conf);
|
return newEnv.get(s); });
|
||||||
|
|
||||||
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
|
||||||
assertEquals("No configuration but with environment ALTERAOCLSDKROOT set",
|
assertEquals("No configuration but with environment ALTERAOCLSDKROOT set",
|
||||||
getTestParentFolder() + "/bin/aocl", openclPlugin.getPathToExecutable());
|
getTestParentFolder() + "/bin/aocl", openclPlugin.getPathToExecutable());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDiscoveryWhenAvailableDevicesDefined()
|
public void testDiscoveryWhenAvailableDevicesDefined()
|
||||||
throws YarnException {
|
throws YarnException {
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
||||||
"acl0/243:0,acl1/244:1");
|
"acl0/243:0,acl1/244:1");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
List<FpgaDevice> devices = fpgaDiscoverer.discover();
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
List<FpgaDevice> devices = discoverer.discover();
|
|
||||||
assertEquals("Number of devices", 2, devices.size());
|
assertEquals("Number of devices", 2, devices.size());
|
||||||
FpgaDevice device0 = devices.get(0);
|
FpgaDevice device0 = devices.get(0);
|
||||||
FpgaDevice device1 = devices.get(1);
|
FpgaDevice device1 = devices.get(1);
|
||||||
@ -188,18 +179,11 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("No FPGA devices were specified");
|
expected.expectMessage("No FPGA devices were specified");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
||||||
"");
|
"");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
fpgaDiscoverer.discover();
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
discoverer.discover();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -208,37 +192,24 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("Illegal device specification string");
|
expected.expectMessage("Illegal device specification string");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
|
||||||
"illegal/243:0,acl1/244=1");
|
"illegal/243:0,acl1/244=1");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
fpgaDiscoverer.discover();
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
discoverer.discover();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDiscoveryWhenExternalScriptDefined()
|
public void testDiscoveryWhenExternalScriptDefined()
|
||||||
throws YarnException {
|
throws YarnException {
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
||||||
"/dummy/script");
|
"/dummy/script");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.setScriptRunner(s -> {
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
discoverer.setScriptRunner(s -> {
|
|
||||||
return Optional.of("acl0/243:0,acl1/244:1"); });
|
return Optional.of("acl0/243:0,acl1/244:1"); });
|
||||||
|
fpgaDiscoverer.initialize(conf);
|
||||||
|
List<FpgaDevice> devices = fpgaDiscoverer.discover();
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
List<FpgaDevice> devices = discoverer.discover();
|
|
||||||
assertEquals("Number of devices", 2, devices.size());
|
assertEquals("Number of devices", 2, devices.size());
|
||||||
FpgaDevice device0 = devices.get(0);
|
FpgaDevice device0 = devices.get(0);
|
||||||
FpgaDevice device1 = devices.get(1);
|
FpgaDevice device1 = devices.get(1);
|
||||||
@ -258,20 +229,14 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("No FPGA devices were specified");
|
expected.expectMessage("No FPGA devices were specified");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
||||||
"/dummy/script");
|
"/dummy/script");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.setScriptRunner(s -> {
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
discoverer.setScriptRunner(s -> {
|
|
||||||
return Optional.of(""); });
|
return Optional.of(""); });
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.discover();
|
fpgaDiscoverer.discover();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -280,20 +245,14 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("Unable to run external script");
|
expected.expectMessage("Unable to run external script");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
||||||
"/dummy/script");
|
"/dummy/script");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.setScriptRunner(s -> {
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
discoverer.setScriptRunner(s -> {
|
|
||||||
return Optional.empty(); });
|
return Optional.empty(); });
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.discover();
|
fpgaDiscoverer.discover();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -302,17 +261,10 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("Unable to run external script");
|
expected.expectMessage("Unable to run external script");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT, "");
|
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT, "");
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
fpgaDiscoverer.discover();
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
discoverer.discover();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -323,21 +275,14 @@ public class TestFpgaDiscoverer {
|
|||||||
expected.expect(ResourceHandlerException.class);
|
expected.expect(ResourceHandlerException.class);
|
||||||
expected.expectMessage("Unable to run external script");
|
expected.expectMessage("Unable to run external script");
|
||||||
|
|
||||||
Configuration conf = new Configuration(false);
|
|
||||||
fakeScript = new File(getTestParentFolder() + "/fakeScript");
|
fakeScript = new File(getTestParentFolder() + "/fakeScript");
|
||||||
touchFile(fakeScript);
|
touchFile(fakeScript);
|
||||||
fakeScript.setExecutable(false);
|
fakeScript.setExecutable(false);
|
||||||
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
conf.set(YarnConfiguration.NM_FPGA_DEVICE_DISCOVERY_SCRIPT,
|
||||||
fakeScript.getAbsolutePath());
|
fakeScript.getAbsolutePath());
|
||||||
FpgaDiscoverer discoverer = FpgaDiscoverer.getInstance();
|
|
||||||
|
|
||||||
IntelFpgaOpenclPlugin openclPlugin = new IntelFpgaOpenclPlugin();
|
fpgaDiscoverer.initialize(conf);
|
||||||
discoverer.setResourceHanderPlugin(openclPlugin);
|
fpgaDiscoverer.discover();
|
||||||
openclPlugin.initPlugin(conf);
|
|
||||||
openclPlugin.setInnerShellExecutor(mockPuginShell());
|
|
||||||
|
|
||||||
discoverer.initialize(conf);
|
|
||||||
discoverer.discover();
|
|
||||||
} finally {
|
} finally {
|
||||||
fakeScript.delete();
|
fakeScript.delete();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user