diff --git a/src/Bridges/Bridges.jl b/src/Bridges/Bridges.jl index 4fd65842e2..133faec998 100644 --- a/src/Bridges/Bridges.jl +++ b/src/Bridges/Bridges.jl @@ -142,8 +142,6 @@ MOI.is_copyable(::ListOfNonstandardBridges) = false MOI.get_fallback(model::MOI.ModelLike, ::ListOfNonstandardBridges) = Type[] -include("precompile.jl") - function _test_structural_identical( a::MOI.ModelLike, b::MOI.ModelLike; diff --git a/src/Bridges/precompile.jl b/src/Bridges/precompile.jl deleted file mode 100644 index fd35e3fa7b..0000000000 --- a/src/Bridges/precompile.jl +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -function _precompile_() - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - Base.precompile( - full_bridge_optimizer, - (MOI.AbstractOptimizer, Type{Float64}), - ) - Base.precompile( - unbridged_function, - (LazyBridgeOptimizer, MOI.AbstractScalarFunction), - ) # time: 0.1381832 - return -end - -_precompile_() diff --git a/src/MathOptInterface.jl b/src/MathOptInterface.jl index 99f6b9d505..5ccb5625dc 100644 --- a/src/MathOptInterface.jl +++ b/src/MathOptInterface.jl @@ -376,8 +376,6 @@ include("FileFormats/FileFormats.jl") include("instantiate.jl") -_precompile_() - """ IndexMap() diff --git a/src/Nonlinear/ReverseAD/ReverseAD.jl b/src/Nonlinear/ReverseAD/ReverseAD.jl index 4b9a9e1311..c874f3e7f7 100644 --- a/src/Nonlinear/ReverseAD/ReverseAD.jl +++ b/src/Nonlinear/ReverseAD/ReverseAD.jl @@ -39,6 +39,4 @@ include("reverse_mode.jl") include("forward_over_reverse.jl") include("mathoptinterface_api.jl") -include("precompile.jl") - end # module diff --git a/src/Nonlinear/ReverseAD/precompile.jl b/src/Nonlinear/ReverseAD/precompile.jl deleted file mode 100644 index bda7b08158..0000000000 --- a/src/Nonlinear/ReverseAD/precompile.jl +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -function _precompile_() - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - Base.precompile( - Tuple{ - typeof(MOI.eval_hessian_objective), - NLPEvaluator, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - Vector{Float64}, - }, - ) - Base.precompile( - Tuple{ - typeof(MOI.eval_hessian_constraint), - NLPEvaluator, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - Vector{Float64}, - Int64, - }, - ) - Base.precompile( - Tuple{ - typeof(MOI.eval_hessian_lagrangian), - NLPEvaluator, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - Vector{Float64}, - Float64, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - }, - ) - Base.precompile( - Tuple{ - typeof(MOI.eval_objective_gradient), - NLPEvaluator, - Vector{Float64}, - Vector{Float64}, - }, - ) - Base.precompile(Tuple{typeof(MOI.initialize),NLPEvaluator,Vector{Symbol}}) - Base.precompile(Tuple{typeof(MOI.features_available),NLPEvaluator}) - Base.precompile( - Tuple{ - typeof(MOI.eval_constraint_jacobian), - NLPEvaluator, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - Vector{Float64}, - }, - ) - Base.precompile( - Tuple{ - typeof(MOI.eval_constraint), - NLPEvaluator, - SubArray{Float64,1,Vector{Float64},Tuple{UnitRange{Int64}},true}, - Vector{Float64}, - }, - ) - Base.precompile(Tuple{typeof(MOI.hessian_objective_structure),NLPEvaluator}) - Base.precompile( - Tuple{typeof(MOI.hessian_constraint_structure),NLPEvaluator,Int64}, - ) - Base.precompile( - Tuple{typeof(MOI.hessian_lagrangian_structure),NLPEvaluator}, - ) - Base.precompile(Tuple{typeof(MOI.jacobian_structure),NLPEvaluator}) - Base.precompile( - Tuple{typeof(MOI.eval_objective),NLPEvaluator,Vector{Float64}}, - ) - return -end - -_precompile_() diff --git a/src/Utilities/Utilities.jl b/src/Utilities/Utilities.jl index d494a6cb18..ae11f0f308 100644 --- a/src/Utilities/Utilities.jl +++ b/src/Utilities/Utilities.jl @@ -72,7 +72,4 @@ include("set_dot.jl") include("distance_to_set.jl") -include("precompile.jl") -_precompile_() - end # module diff --git a/src/Utilities/precompile.jl b/src/Utilities/precompile.jl deleted file mode 100644 index 49ec673460..0000000000 --- a/src/Utilities/precompile.jl +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2017: Miles Lubin and contributors -# Copyright (c) 2017: Google Inc. -# -# Use of this source code is governed by an MIT-style license that can be found -# in the LICENSE.md file or at https://opensource.org/licenses/MIT. - -function _precompile_() - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - T = Float64 - scalar_sets = ( - MOI.LessThan{T}, - MOI.GreaterThan{T}, - MOI.EqualTo{T}, - MOI.Interval{T}, - MOI.Integer, - MOI.ZeroOne, - MOI.Semiinteger{T}, - MOI.Semicontinuous{T}, - ) - scalar_functions = ( - MOI.VariableIndex, - MOI.ScalarAffineFunction{T}, - MOI.ScalarQuadraticFunction{T}, - ) - vector_sets = ( - MOI.Nonnegatives, - MOI.Nonpositives, - MOI.Zeros, - MOI.Reals, - MOI.SecondOrderCone, - MOI.RotatedSecondOrderCone, - MOI.PositiveSemidefiniteConeSquare, - MOI.PositiveSemidefiniteConeTriangle, - ) - vector_functions = ( - MOI.VectorOfVariables, - MOI.VectorAffineFunction{T}, - MOI.VectorQuadraticFunction{T}, - ) - constraints = vcat( - [(F, S) for F in scalar_functions, S in scalar_sets], - [(F, S) for F in vector_functions, S in vector_sets], - ) - MOI.precompile_model(UniversalFallback{Model{T}}, constraints) - MOI.precompile_model( - CachingOptimizer{MOI.AbstractOptimizer,UniversalFallback{Model{T}}}, - constraints, - ) - Base.precompile(UniversalFallback, (Model{T},)) - return -end diff --git a/src/precompile.jl b/src/precompile.jl index 59240b1dfc..ee4df50bbb 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -5,99 +5,16 @@ # in the LICENSE.md file or at https://opensource.org/licenses/MIT. function precompile_constraint(model, F, S) - Base.precompile(get, (model, ListOfConstraintIndices{F,S})) - Base.precompile(get, (model, ListOfConstraintAttributesSet{F,S})) - Base.precompile(get, (model, ConstraintSet, ConstraintIndex{F,S})) - Base.precompile(get, (model, ConstraintSet, Vector{ConstraintIndex{F,S}})) - Base.precompile(set, (model, ConstraintSet, ConstraintIndex{F,S}, S)) - - Base.precompile(get, (model, ConstraintFunction, ConstraintIndex{F,S})) - Base.precompile(set, (model, ConstraintFunction, ConstraintIndex{F,S}, F)) - Base.precompile( - get, - (model, ConstraintFunction, Vector{ConstraintIndex{F,S}}), - ) - - Base.precompile(get, (model, ConstraintDual, ConstraintIndex{F,S})) - Base.precompile(get, (model, ConstraintPrimal, ConstraintIndex{F,S})) - - Base.precompile( - get, - (model, AbstractConstraintAttribute, ConstraintIndex{F,S}), - ) - Base.precompile( - get, - (model, AbstractConstraintAttribute, Vector{ConstraintIndex{F,S}}), - ) - - Base.precompile(add_constraint, (model, F, S)) - Base.precompile(add_constraints, (model, Vector{F}, Vector{S})) - Base.precompile(delete, (model, ConstraintIndex{F,S})) - Base.precompile(is_valid, (model, ConstraintIndex{F,S})) - Base.precompile(get, (model, ConstraintName, ConstraintIndex{F,S})) - return Base.precompile( - set, - (model, ConstraintName, ConstraintIndex{F,S}, String), - ) + @warn("This function is deprecated. Use PrecompileTools.jl instead") + return end function precompile_variables(model) - Base.precompile(delete, (model, VariableIndex)) - Base.precompile(delete, (model, Vector{VariableIndex})) - Base.precompile(get, (model, AbstractVariableAttribute, VariableIndex)) - Base.precompile( - get, - (model, AbstractVariableAttribute, Vector{VariableIndex}), - ) - Base.precompile(get, (model, VariableName, VariableIndex)) - Base.precompile(set, (model, VariableName, VariableIndex, String)) - Base.precompile(get, (model, VariablePrimalStart, VariableIndex)) - Base.precompile(set, (model, VariablePrimalStart, VariableIndex, Float64)) - Base.precompile(get, (model, VariablePrimalStart, Vector{VariableIndex})) - Base.precompile( - set, - (model, VariablePrimalStart, Vector{VariableIndex}, Vector{Float64}), - ) - Base.precompile(get, (model, VariablePrimal, VariableIndex)) - Base.precompile(get, (model, VariablePrimal, Vector{VariableIndex})) - return Base.precompile(add_constrained_variables, (model, Reals)) + @warn("This function is deprecated. Use PrecompileTools.jl instead") + return end function precompile_model(model, constraints) - Base.precompile(empty!, (model,)) - Base.precompile(is_empty, (model,)) - Base.precompile(get, (model, ListOfConstraintTypesPresent)) - Base.precompile(optimize!, (model,)) - Base.precompile(add_variable, (model,)) - Base.precompile(add_variables, (model, Int)) - for attr in ( - ListOfVariableIndices, - ListOfVariableAttributesSet, - TerminationStatus, - DualStatus, - PrimalStatus, - ObjectiveValue, - Silent, - TimeLimitSec, - NumberOfVariables, - ) - Base.precompile(get, (model, attr)) - end - - precompile_variables(model) - for (F, S) in constraints - precompile_constraint(model, F, S) - end - return Base.precompile(Tuple{typeof(add_constrained_variables),model,Reals}) -end - -function _precompile_() - return Base.precompile( - Tuple{ - Core.kwftype(typeof(instantiate)), - NamedTuple{(:with_bridge_type,),Tuple{DataType}}, - typeof(instantiate), - Type, - }, - ) # time: 0.481656 + @warn("This function is deprecated. Use PrecompileTools.jl instead") + return end diff --git a/test/errors.jl b/test/errors.jl index 45686a7d78..8ba7306cab 100644 --- a/test/errors.jl +++ b/test/errors.jl @@ -396,6 +396,15 @@ function test_isvalid_fallback() return end +function test_logs_precompile() + model = MOI.Utilities.Model{Float64}() + F, S = MOI.VariableIndex, MOI.ZeroOne + @test_logs (:warn,) MOI.precompile_constraint(model, F, S) + @test_logs (:warn,) MOI.precompile_variables(model) + @test_logs (:warn,) MOI.precompile_model(model, [(F, S)]) + return +end + end # module TestErrors.runtests()