Computes crossprod(X, Y) (i.e. t(X) %*% Y) using:
shared/mmap-backed inputs (one copy),
block views (no slice materialization),
BLAS-3 dgemm in each tile,
an explicit shared output buffer (no gather/bind spikes).
Arguments
- X, Y
Double matrices with the same number of rows.
- workers
Number of worker processes.
- block_x, block_y
Tile sizes over
ncol(X)andncol(Y). Use"auto"(default) to autotune on the current machine.- backing
Backing for shared inputs and output buffer (
"mmap"or"shm").- materialize
Whether to return the result as a standard R matrix:
"never"(return buffer handle),"always", or"auto"(materialize if estimated output size is belowmaterialize_max_bytes).- materialize_max_bytes
Threshold for
"auto"materialization.- diagnostics
Whether to collect shard_map diagnostics.
Value
A list with:
buffer: shard_buffer for the result (p x v)value: materialized matrix if requested, otherwise NULLrun: the underlying shard_result from shard_maptile: chosen tile sizes
Details
This is intended as an ergonomic entry point for the "wow" path: users
shouldn't have to manually call share(), view_block(), buffer(),
tiles2d(), and shard_map() for common patterns.
Examples
# \donttest{
X <- matrix(rnorm(2000), 100, 20)
Y <- matrix(rnorm(2000), 100, 20)
res <- shard_crossprod(X, Y, block_x = 50, block_y = 10, workers = 2)
pool_stop()
res$value
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -1.3686403 11.6245224 4.7955204 7.1283816 -2.64882872 -5.3545905
#> [2,] 0.1546488 0.9778290 4.6762949 -2.8564779 -1.51918642 1.9341979
#> [3,] -7.6370654 5.7880589 -0.3060874 -11.8970171 -9.85842888 1.0848512
#> [4,] -4.6735150 -6.5932015 -0.3012830 10.5393539 -0.90103145 -0.7938288
#> [5,] 1.9258820 -12.8248932 2.8412259 24.3434260 -2.15935099 7.0521752
#> [6,] 1.4774307 12.7617873 -23.5206973 -5.7655328 11.88842250 -2.6190347
#> [7,] 19.5485081 4.6037809 -24.0273287 5.8668418 -6.50301401 9.9524224
#> [8,] -16.3661146 2.4156342 9.1155626 17.7253017 -6.51898245 9.6633877
#> [9,] 1.6674789 9.1332862 5.0616798 5.0710075 -4.63826366 -12.9314963
#> [10,] 9.3383711 4.7766553 -14.0588615 -15.7294385 1.48185233 13.8920459
#> [11,] 8.6103106 5.5375756 12.4320633 -11.4110112 -4.28718087 16.0037970
#> [12,] -5.4294278 -0.5095499 -7.1249354 -11.1825428 3.25260127 -1.1212338
#> [13,] -6.7518119 -2.4138926 -0.3591915 -16.3267593 -13.21374819 7.8462535
#> [14,] 3.5299136 10.5744088 -5.6057437 8.9790985 0.05333078 -5.1306843
#> [15,] -1.6170209 9.0205214 17.2553509 6.4839894 17.04723843 -9.6461930
#> [16,] 2.5065416 -0.3512517 -3.3511995 -6.8067658 -5.95990469 -7.8714514
#> [17,] -4.4996708 10.5903186 16.6130705 6.2430936 13.04424099 -3.6650099
#> [18,] -2.3189753 -12.2639570 -8.4203341 2.7091136 -3.59149487 6.3937851
#> [19,] 1.1852582 -3.9541999 -0.7198415 4.3248701 -5.69129722 -10.2281253
#> [20,] -4.7788743 6.5715136 4.4459396 0.9596115 -4.42228711 8.0792522
#> [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] -5.0604448 -6.6511586 10.2503447 -4.6272635 -14.9299014 -5.41299803
#> [2,] -12.9202927 1.7928533 -0.0837892 -7.3685631 9.6717203 -6.29907867
#> [3,] 3.3366160 -14.9400737 8.7829952 12.5343208 -0.9472883 9.70369517
#> [4,] 4.8837745 1.5892606 -5.3205636 4.3717070 1.9756062 1.18849620
#> [5,] -4.5104024 -7.2501277 -11.9493137 7.2552831 -6.6241636 -5.04799062
#> [6,] 5.0000775 -17.2346716 -1.1330076 -0.1256765 -0.8322429 -0.05771539
#> [7,] -8.1819931 1.3738501 12.1118006 -7.5424863 -8.9962363 4.42775090
#> [8,] 1.0057580 -7.1129539 15.9393069 -14.3878705 9.9792752 2.31808417
#> [9,] 5.9986612 -17.5537489 15.9926838 -5.3528815 -10.7608347 -4.51706984
#> [10,] 4.2886667 -12.1259926 6.5671993 -6.1922627 -7.9214320 12.57377020
#> [11,] 6.4359851 -4.7088857 -4.6306561 -16.3653900 10.6513621 0.39764364
#> [12,] -1.8730896 2.7005984 15.6269062 8.7334314 -6.3823762 -10.89846621
#> [13,] 2.3995928 2.9009587 -2.1412998 0.3534441 3.3272669 -5.96380298
#> [14,] -10.2100689 -4.7174528 -7.6346253 10.4270317 -3.1078191 -2.38194724
#> [15,] -5.2267618 -20.6198270 0.6061065 5.6461650 -4.4338916 -19.76162568
#> [16,] -0.4829792 -4.2230846 -5.0060648 -6.4668330 0.2629746 2.32787759
#> [17,] -11.0195020 12.1035658 0.8894658 7.8564488 15.6290245 10.72192970
#> [18,] 2.8720039 -0.6351889 -5.1303033 -8.4862315 7.8508370 -4.14784483
#> [19,] 8.6164868 -5.7956302 -5.6553650 -12.7262433 10.2487963 -7.95751824
#> [20,] -1.3898687 -15.3740891 5.4413445 16.4705158 15.6195530 -10.95961801
#> [,13] [,14] [,15] [,16] [,17] [,18]
#> [1,] 3.3247221 13.079752 -4.0837009 4.654236 21.8302355 -4.3739675
#> [2,] 6.9979604 -18.330409 21.9926335 14.143746 -9.8814097 0.3085915
#> [3,] -5.5452648 -16.799320 -2.1484018 -16.948553 -3.2117013 -11.3416949
#> [4,] 5.8678415 -9.489158 -4.3643412 5.144655 -7.1476484 -0.8050530
#> [5,] 11.1925737 11.196071 0.5464675 -10.749325 -9.3644275 9.1837961
#> [6,] 0.1375887 25.924118 -14.7609782 -2.805648 4.0580068 -7.8501072
#> [7,] -13.8066150 7.131762 -10.4991349 17.772212 2.6479611 1.8406969
#> [8,] 29.4709883 -7.446176 1.2150137 -5.994460 5.4476078 -3.8674318
#> [9,] 16.3213575 14.415509 6.7462141 -2.920741 13.3559861 2.5238741
#> [10,] -19.4130325 5.588580 -5.4869570 19.558084 -2.7232308 7.9068362
#> [11,] 3.2193908 -10.776587 10.5898605 3.081575 -4.9806121 22.0934140
#> [12,] 14.5757696 13.831140 -0.5377003 11.240371 -0.2831355 -10.8329560
#> [13,] 3.8426324 -12.803396 11.8693211 9.769744 6.3849334 19.0816156
#> [14,] -0.8089552 15.540014 -4.6889445 -6.370470 -23.1691864 -13.8089596
#> [15,] 5.8031298 -18.666772 0.6208490 9.793940 -3.8374377 7.3094057
#> [16,] -8.5587750 5.676805 -11.5969053 -7.572591 -5.7630821 -6.5331101
#> [17,] -2.6355288 -16.808724 7.8766377 -15.146247 -13.4568627 2.1896759
#> [18,] 15.8518543 -10.575549 -8.1816225 -2.626155 -1.7510746 4.7440580
#> [19,] 2.0455190 9.565280 -4.8818732 -13.272060 0.9502097 15.1325515
#> [20,] -3.6650930 7.221429 7.8864484 -6.095039 -3.9242029 10.5604539
#> [,19] [,20]
#> [1,] -5.98033194 16.198997
#> [2,] 8.79075785 4.416501
#> [3,] 0.08598499 -2.876440
#> [4,] -2.71517644 -3.253880
#> [5,] 8.23931967 -15.135884
#> [6,] -1.75977865 6.440088
#> [7,] 5.98596146 5.656671
#> [8,] -24.40778570 -8.611733
#> [9,] -10.53962438 13.066121
#> [10,] 21.74307492 1.344543
#> [11,] -2.55140580 -12.771519
#> [12,] 4.21261650 -9.705036
#> [13,] 12.10056793 14.033008
#> [14,] 8.98007692 -16.606318
#> [15,] -23.46646556 -4.338834
#> [16,] 8.95461015 1.334113
#> [17,] 1.52645655 -9.299937
#> [18,] 2.51677826 -15.902126
#> [19,] -4.11872678 -9.094267
#> [20,] 2.58190481 -4.438687
# }