Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU support #88

Open
wants to merge 5 commits into
base: mlSearcher
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions VSharp.API/VSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public IEnumerable<FileInfo> Results()

public static class TestGenerator
{
private class Reporter: IReporter
private class Reporter : IReporter
{
private readonly UnitTests _unitTests;
private readonly bool _isQuiet;
Expand All @@ -124,7 +124,7 @@ public Reporter(UnitTests unitTests, bool isQuiet)

public void ReportFinished(UnitTest unitTest) => _unitTests.GenerateTest(unitTest);
public void ReportException(UnitTest unitTest) => _unitTests.GenerateError(unitTest);
public void ReportIIE(InsufficientInformationException iie) {}
public void ReportIIE(InsufficientInformationException iie) { }

public void ReportInternalFail(Method? method, Exception exn)
{
Expand Down Expand Up @@ -179,7 +179,7 @@ private static Statistics StartExploration(
explorationMode: explorationMode.NewTestCoverageMode(
coverageZone,
options.Timeout > 0 ? searchMode.NewFairMode(baseSearchMode) : baseSearchMode

),
recThreshold: options.RecursionThreshold,
solverTimeout: options.SolverTimeout,
Expand All @@ -191,8 +191,11 @@ private static Statistics StartExploration(
stopOnCoverageAchieved: 100,
randomSeed: options.RandomSeed,
stepsLimit: options.StepsLimit,
aiAgentTrainingOptions: options.AIAgentTrainingOptions == null ? FSharpOption<AIAgentTrainingOptions>.None :FSharpOption<AIAgentTrainingOptions>.Some(options.AIAgentTrainingOptions),
pathToModel: options.PathToModel == null ? FSharpOption<string>.None : FSharpOption<string>.Some(options.PathToModel));
aiAgentTrainingOptions: options.AIAgentTrainingOptions == null ? FSharpOption<AIAgentTrainingOptions>.None : FSharpOption<AIAgentTrainingOptions>.Some(options.AIAgentTrainingOptions),
pathToModel: options.PathToModel == null ? FSharpOption<string>.None : FSharpOption<string>.Some(options.PathToModel),
useGPU: options.UseGPU == null ? FSharpOption<bool>.None : FSharpOption<bool>.Some(options.UseGPU),
optimize: options.Optimize == null ? FSharpOption<bool>.None : FSharpOption<bool>.Some(options.Optimize)
);

var fuzzerOptions =
new FuzzerOptions(
Expand Down Expand Up @@ -326,7 +329,7 @@ private static int CheckCoverage(
public static Statistics Cover(MethodBase method, VSharpOptions options = new())
{
AssemblyManager.LoadCopy(method.Module.Assembly);
var methods = new List<MethodBase> {method};
var methods = new List<MethodBase> { method };
var statistics = StartExploration(methods, coverageZone.MethodZone, options);

if (options.RenderTests)
Expand Down
10 changes: 9 additions & 1 deletion VSharp.API/VSharpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public readonly record struct VSharpOptions
public readonly uint StepsLimit = DefaultStepsLimit;
public readonly AIAgentTrainingOptions AIAgentTrainingOptions = null;
public readonly string PathToModel = DefaultPathToModel;
public readonly bool UseGPU = false;
public readonly bool Optimize = false;

/// <summary>
/// Symbolic virtual machine options.
Expand All @@ -133,6 +135,8 @@ public readonly record struct VSharpOptions
/// <param name="stepsLimit">Number of symbolic machine steps to stop execution after. Zero value means no limit.</param>
/// <param name="aiAgentTrainingOptions">Settings for AI searcher training.</param>
/// <param name="pathToModel">Path to ONNX file with model to use in AI searcher.</param>
/// <param name="useGPU">Specifies whether the ONNX execution session should use a CUDA-enabled GPU.</param>
/// <param name="optimize">Enabling options like parallel execution and various graph transformations to enhance performance of ONNX.</param>
public VSharpOptions(
int timeout = DefaultTimeout,
int solverTimeout = DefaultSolverTimeout,
Expand All @@ -147,7 +151,9 @@ public VSharpOptions(
int randomSeed = DefaultRandomSeed,
uint stepsLimit = DefaultStepsLimit,
AIAgentTrainingOptions aiAgentTrainingOptions = null,
string pathToModel = DefaultPathToModel)
string pathToModel = DefaultPathToModel,
bool useGPU = false,
bool optimize = false)
{
Timeout = timeout;
SolverTimeout = solverTimeout;
Expand All @@ -163,6 +169,8 @@ public VSharpOptions(
StepsLimit = stepsLimit;
AIAgentTrainingOptions = aiAgentTrainingOptions;
PathToModel = pathToModel;
UseGPU = useGPU;
Optimize = optimize;
}

/// <summary>
Expand Down
Loading