Skip to content

Commit 6000ef6

Browse files
committed
FindFirstFunctions
1 parent 7ac6e4d commit 6000ef6

File tree

2 files changed

+3
-67
lines changed

2 files changed

+3
-67
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1818
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1919
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
2020
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
21+
FindFirstFunctions = "64ca27bc-2ba2-4a57-88aa-44e436879224"
2122
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
2223
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
2324
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
@@ -74,6 +75,7 @@ Distributions = "0.23, 0.24, 0.25"
7475
DocStringExtensions = "0.7, 0.8, 0.9"
7576
DomainSets = "0.6"
7677
DynamicQuantities = "0.8, 0.9, 0.10"
78+
FindFirstFunctions = "1"
7779
ForwardDiff = "0.10.3"
7880
FunctionWrappersWrappers = "0.1"
7981
Graphs = "1.5.2"

src/systems/sparsematrixclil.jl

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -129,73 +129,7 @@ end
129129
# build something that works for us here and worry about it later.
130130
nonzerosmap(a::CLILVector) = NonZeros(a)
131131

132-
findfirstequal(vpivot, ivars) = findfirst(isequal(vpivot), ivars)
133-
function findfirstequal(vpivot::Int64, ivars::Vector{Int64})
134-
GC.@preserve ivars begin
135-
ret = Base.llvmcall(("""
136-
declare i8 @llvm.cttz.i8(i8, i1);
137-
define i64 @entry(i64 %0, i64 %1, i64 %2) #0 {
138-
top:
139-
%ivars = inttoptr i64 %1 to i64*
140-
%btmp = insertelement <8 x i64> undef, i64 %0, i64 0
141-
%var = shufflevector <8 x i64> %btmp, <8 x i64> undef, <8 x i32> zeroinitializer
142-
%lenm7 = add nsw i64 %2, -7
143-
%dosimditer = icmp ugt i64 %2, 7
144-
br i1 %dosimditer, label %L9.lr.ph, label %L32
145-
146-
L9.lr.ph:
147-
%len8 = and i64 %2, 9223372036854775800
148-
br label %L9
149-
150-
L9:
151-
%i = phi i64 [ 0, %L9.lr.ph ], [ %vinc, %L30 ]
152-
%ivarsi = getelementptr inbounds i64, i64* %ivars, i64 %i
153-
%vpvi = bitcast i64* %ivarsi to <8 x i64>*
154-
%v = load <8 x i64>, <8 x i64>* %vpvi, align 8
155-
%m = icmp eq <8 x i64> %v, %var
156-
%mu = bitcast <8 x i1> %m to i8
157-
%matchnotfound = icmp eq i8 %mu, 0
158-
br i1 %matchnotfound, label %L30, label %L17
159-
160-
L17:
161-
%tz8 = call i8 @llvm.cttz.i8(i8 %mu, i1 true)
162-
%tz64 = zext i8 %tz8 to i64
163-
%vis = add nuw i64 %i, %tz64
164-
br label %common.ret
165-
166-
common.ret:
167-
%retval = phi i64 [ %vis, %L17 ], [ -1, %L32 ], [ %si, %L51 ], [ -1, %L67 ]
168-
ret i64 %retval
169-
170-
L30:
171-
%vinc = add nuw nsw i64 %i, 8
172-
%continue = icmp slt i64 %vinc, %lenm7
173-
br i1 %continue, label %L9, label %L32
174-
175-
L32:
176-
%cumi = phi i64 [ 0, %top ], [ %len8, %L30 ]
177-
%done = icmp eq i64 %cumi, %2
178-
br i1 %done, label %common.ret, label %L51
179-
180-
L51:
181-
%si = phi i64 [ %inc, %L67 ], [ %cumi, %L32 ]
182-
%spi = getelementptr inbounds i64, i64* %ivars, i64 %si
183-
%svi = load i64, i64* %spi, align 8
184-
%match = icmp eq i64 %svi, %0
185-
br i1 %match, label %common.ret, label %L67
186-
187-
L67:
188-
%inc = add i64 %si, 1
189-
%dobreak = icmp eq i64 %inc, %2
190-
br i1 %dobreak, label %common.ret, label %L51
191-
192-
}
193-
attributes #0 = { alwaysinline }
194-
""", "entry"), Int64, Tuple{Int64, Ptr{Int64}, Int64}, vpivot, pointer(ivars),
195-
length(ivars))
196-
end
197-
ret < 0 ? nothing : ret + 1
198-
end
132+
using FindFirstFunctions: findfirstequal
199133

200134
function bareiss_update_virtual_colswap_mtk!(zero!, M::SparseMatrixCLIL, k, swapto, pivot,
201135
last_pivot; pivot_equal_optimization = true)

0 commit comments

Comments
 (0)