Skip to content

Commit

Permalink
Added compressed plot size texts (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaMineJP authored Aug 9, 2023
1 parent 4f0e8c8 commit 8f43234
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
17 changes: 11 additions & 6 deletions packages/gui/src/components/plot/add/PlotAddChooseSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import styled from 'styled-components';

import PlotterName from '../../../constants/PlotterName';
import { getPlotSizeOptions } from '../../../constants/plotSizes';
import Plotter from '../../../types/Plotter';

Expand All @@ -25,25 +26,29 @@ export default function PlotAddChooseSize(props: Props) {
const openDialog = useOpenDialog();

const op = plotter.options;
const isBladebit3OrNewer =
plotter.defaults.plotterName.startsWith('bladebit') && plotter.version && +plotter.version.split('.')[0] >= 3;

const plotterName = watch('plotterName');
const plotSize = watch('plotSize');
const overrideK = watch('overrideK');
const compressionLevelStr = watch('bladebitCompressionLevel');
const compressionLevel = compressionLevelStr ? +compressionLevelStr : undefined;
const isKLow = plotSize < MIN_MAINNET_K_SIZE;

const compressionAvailable = op.haveBladebitCompressionLevel && isBladebit3OrNewer;
const compressionAvailable =
op.haveBladebitCompressionLevel &&
(plotterName === PlotterName.BLADEBIT_CUDA || plotterName === PlotterName.BLADEBIT_RAM);

const [allowedPlotSizes, setAllowedPlotSizes] = useState(
getPlotSizeOptions(plotterName).filter((option) => plotter.options.kSizes.includes(option.value))
getPlotSizeOptions(plotterName, compressionLevel).filter((option) => plotter.options.kSizes.includes(option.value))
);

useEffect(() => {
setAllowedPlotSizes(
getPlotSizeOptions(plotterName).filter((option) => plotter.options.kSizes.includes(option.value))
getPlotSizeOptions(plotterName, compressionLevel).filter((option) =>
plotter.options.kSizes.includes(option.value)
)
);
}, [plotter.options.kSizes, plotterName]);
}, [plotter.options.kSizes, plotterName, compressionLevel]);

useEffect(() => {
async function getConfirmation() {
Expand Down
36 changes: 31 additions & 5 deletions packages/gui/src/constants/plotSizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ type PlotSize = {
defaultRam: number;
};

export const compressedSizes: Record<number, Record<number, string>> = {
0: { 32: '101.4GiB', 33: '208.8GiB', 34: '429.9GiB', 35: '884.1GiB' },
1: { 32: '87.5GiB', 33: '179.6GiB', 34: '368.2GiB', 35: '754.3GiB' },
2: { 32: '86.0GiB', 33: '176.6GiB', 34: '362.1GiB', 35: '742.2GiB' },
3: { 32: '84.5GiB', 33: '173.4GiB', 34: '355.9GiB', 35: '729.7GiB' },
4: { 32: '82.9GiB', 33: '170.2GiB', 34: '349.4GiB', 35: '716.8GiB' },
5: { 32: '81.3GiB', 33: '167.0GiB', 34: '343.0GiB', 35: '704.0GiB' },
6: { 32: '79.6GiB', 33: '163.8GiB', 34: '336.6GiB', 35: '691.1GiB' },
7: { 32: '78.0GiB', 33: '160.6GiB', 34: '330.2GiB', 35: '678.3GiB' },
9: { 32: '75.2GiB', 33: '154.1GiB', 34: '315.5GiB', 35: '645.8GiB' },
};

export function getEffectivePlotSize(kSize: 25 | 32 | 33 | 34 | 35) {
const sizeInBytes = (2 * kSize + 1) * 2 ** (kSize - 1);
if (kSize < 32) {
Expand Down Expand Up @@ -43,9 +55,23 @@ export const plottingInfo: Record<PlotterName, PlotSize[]> = {
],
};

export function getPlotSizeOptions(plotterName: PlotterName) {
return plottingInfo[plotterName].map((item) => ({
value: item.value,
label: `k=${item.value} (Effective plot size: ${item.effectivePlotSize}, Temporary space: ${item.workspace})`,
}));
export function getPlotSizeOptions(plotterName: PlotterName, compressionLevel?: number) {
return plottingInfo[plotterName].map((item) => {
const kSize = item.value;
if (
typeof compressionLevel !== 'number' ||
!compressedSizes[compressionLevel] ||
!compressedSizes[compressionLevel][kSize]
) {
return {
value: kSize,
label: `k=${kSize} (Effective plot size: ${item.effectivePlotSize}, Temporary space: ${item.workspace})`,
};
}
const compressedSize = compressedSizes[compressionLevel][kSize];
return {
value: kSize,
label: `k=${kSize} (Effective plot size: ${item.effectivePlotSize}, Compressed plot size: ${compressedSize})`,
};
});
}

0 comments on commit 8f43234

Please sign in to comment.