<commit_before>-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(..., package.seeall)

local engine    = require("core.app")
local timer     = require("core.timer")
local lib       = require("core.lib")
local pci       = require("lib.hardware.pci")
local LoadGen   = require("apps.intel.loadgen").LoadGen
local Intel82599 = require("apps.intel.intel_app").Intel82599

local function is_device_suitable (pcidev, patterns)
   if not pcidev.usable or pcidev.driver ~= 'apps.intel.intel_app' then
      return false
   end
   if #patterns == 0 then
      return true
   end
   for _, pattern in ipairs(patterns) do
      if pci.qualified(pcidev.pciaddress):gmatch(pattern)() then
         return true
      end
   end
end

function run_loadgen (c, patterns, opts)
   assert(type(opts) == "table")
   local use_loadgen = opts.loop == nil or opts.loop
   local nics = 0
   pci.scan_devices()
   for _,device in ipairs(pci.devices) do
      if is_device_suitable(device, patterns) then
         nics = nics + 1
         local name = "nic"..nics
         if use_loadgen then
            config.app(c, name, LoadGen, device.pciaddress)
         else
            config.app(c, name, Intel82599, {pciaddr = device.pciaddress})
         end
         config.link(c, "source."..tostring(nics).."->"..name..".input")
      end
   end
   assert(nics > 0, "<PCI> matches no suitable devices.")
   engine.busywait = true
   engine.configure(c)

   if opts.loop then
      local fn = function ()<commit_msg>Properly configure link for Intel82599<commit_after>-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(..., package.seeall)

local engine    = require("core.app")
local timer     = require("core.timer")
local lib       = require("core.lib")
local pci       = require("lib.hardware.pci")
local LoadGen   = require("apps.intel.loadgen").LoadGen
local Intel82599 = require("apps.intel.intel_app").Intel82599

local function is_device_suitable (pcidev, patterns)
   if not pcidev.usable or pcidev.driver ~= 'apps.intel.intel_app' then
      return false
   end
   if #patterns == 0 then
      return true
   end
   for _, pattern in ipairs(patterns) do
      if pci.qualified(pcidev.pciaddress):gmatch(pattern)() then
         return true
      end
   end
end

function run_loadgen (c, patterns, opts)
   assert(type(opts) == "table")
   local use_loadgen = opts.loop == nil or opts.loop
   local nics = 0
   pci.scan_devices()
   for _,device in ipairs(pci.devices) do
      if is_device_suitable(device, patterns) then
         nics = nics + 1
         local name = "nic"..nics
         if use_loadgen then
            config.app(c, name, LoadGen, device.pciaddress)
            config.link(c, "source."..tostring(nics).."->"..name..".input")
         else
            config.app(c, name, Intel82599, {pciaddr = device.pciaddress})
            config.link(c, "source."..tostring(nics).."->"..name..".rx")
         end
      end
   end
   assert(nics > 0, "<PCI> matches no suitable devices.")
   engine.busywait = true
   engine.configure(c)

   if opts.loop then
      local fn = function ()
{'fraction_non_alphanumeric': 0.1193271977150111, 'fraction_numerical': 0.014915899714376388, 'mean_word_length': 2.690866510538642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1449411', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1000, 'n_words': 278}