Skip to content

Commit

Permalink
slightly improved (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjkkkjjj committed Feb 6, 2021
1 parent b1d339c commit 988d546
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
57 changes: 57 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/ReleaseTest.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,63 @@
BlueprintName = "MatftTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "CollectionTests">
</Test>
<Test
Identifier = "ConversionTests">
</Test>
<Test
Identifier = "CreationTests">
</Test>
<Test
Identifier = "FileTests">
</Test>
<Test
Identifier = "InterpolationTests">
</Test>
<Test
Identifier = "LinAlgTests">
</Test>
<Test
Identifier = "MatMulTests">
</Test>
<Test
Identifier = "MatftTests">
</Test>
<Test
Identifier = "MathTests">
</Test>
<Test
Identifier = "PreOpTests">
</Test>
<Test
Identifier = "PrintTests">
</Test>
<Test
Identifier = "ProductTests">
</Test>
<Test
Identifier = "ReduceTests">
</Test>
<Test
Identifier = "StackTests">
</Test>
<Test
Identifier = "StatsTests">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PerformanceTests"
BuildableName = "PerformanceTests"
BlueprintName = "PerformanceTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
Expand Down
15 changes: 10 additions & 5 deletions Sources/Matft/util/library/vDSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ internal func boolget_by_vDSP<T: MfStorable>(_ mfarray: MfArray, _ indices: MfAr
let indicesT: MfArray
switch mfarray.storedType {
case .Float:
indicesT = check_contiguous(indices.astype(.Float), .Row)
indicesT = indices // indices must have float raw values
case .Double:
indicesT = check_contiguous(indices.astype(.Double), .Row)
indicesT = indices.astype(.Double)
}
let mfarray = check_contiguous(mfarray, .Row)
//let mfarray = check_contiguous(mfarray, .Row)


let lastShape = Array(mfarray.shape.suffix(mfarray.ndim - orig_ind_dim))
Expand All @@ -436,11 +436,16 @@ internal func boolget_by_vDSP<T: MfStorable>(_ mfarray: MfArray, _ indices: MfAr
let dstptrT = dstptr.bindMemory(to: T.self, capacity: retSize)

indicesT.withDataUnsafeMBPtrT(datatype: T.self){
[unowned indicesT](indptr) in
//[unowned indicesT](indptr) in
indptr in
// note that indices and mfarray is row contiguous
mfarray.withDataUnsafeMBPtrT(datatype: T.self){
srcptr in
vDSP_func(srcptr.baseAddress!, vDSP_Stride(1), indptr.baseAddress!, vDSP_Stride(1), dstptrT, vDSP_Stride(1), vDSP_Length(indicesT.size))

for vDSPPrams in OptOffsetParams_mfarray(bigger_mfarray: indicesT, smaller_mfarray: mfarray){
vDSP_func(srcptr.baseAddress! + vDSPPrams.s_offset, vDSP_Stride(vDSPPrams.s_stride), indptr.baseAddress! + vDSPPrams.b_offset, vDSP_Stride(vDSPPrams.b_stride), dstptrT + vDSPPrams.b_offset, vDSP_Stride(vDSPPrams.b_stride), vDSP_Length(vDSPPrams.blocksize))
}
//vDSP_func(srcptr.baseAddress!, vDSP_Stride(1), indptr.baseAddress!, vDSP_Stride(1), dstptrT, vDSP_Stride(1), vDSP_Length(indicesT.size))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/PerformanceTests/IndexingPefTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ final class IndexingPefTests: XCTestCase {
let _ = a[a>0]
}
/*
'-[PerformanceTests.IndexingPefTests testPeformanceBooleanIndexing1]' measured [Time, seconds] average: 0.007, relative standard deviation: 17.050%, values: [0.010224, 0.007128, 0.006454, 0.007535, 0.006929, 0.006481, 0.006221, 0.006312, 0.006142, 0.006018]
7ms
'-[PerformanceTests.IndexingPefTests testPeformanceBooleanIndexing1]' measured [Time, seconds] average: 0.005, relative standard deviation: 37.720%, values: [0.010294, 0.004666, 0.004402, 0.004150, 0.004102, 0.004048, 0.004186, 0.004013, 0.004319, 0.004240]
4.84ms
*/
}
}
Expand Down

0 comments on commit 988d546

Please sign in to comment.