Skip to content

Commit

Permalink
adjust gpu presets levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Misieq01 committed Nov 19, 2024
1 parent c4faed6 commit fff7a9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions src-tauri/src/gpu_miner_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use async_trait::async_trait;
use log::{info, warn};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::ops::Div;
use std::ops::Mul;
use std::path::PathBuf;
use std::time::Instant;
use tari_common::configuration::Network;
Expand All @@ -22,9 +24,6 @@ use crate::{

const LOG_TARGET: &str = "tari::universe::gpu_miner_adapter";

pub const ECO_MODE_GPU_GRID_SIZE: u32 = 2;
pub const LUDICROUS_MODE_GPU_GRID_SIZE: u32 = 900; // TODO: In future will allow user to configure this, but for now let's not burn the gpu too much

pub enum GpuNodeSource {
BaseNode { port: u16 },
P2Pool { port: u16 },
Expand Down Expand Up @@ -64,19 +63,20 @@ impl GpuMinerAdapter {
self.gpu_grid_size = self
.gpu_devices
.iter()
.map(|x| GpuThreads {
gpu_name: x.device_name.clone(),
max_gpu_threads: ECO_MODE_GPU_GRID_SIZE,
.map(|device| GpuThreads {
gpu_name: device.device_name.clone(),
max_gpu_threads: device.max_grid_size.mul(100).div(333),
})
.collect()
}
MiningMode::Ludicrous => {
self.gpu_grid_size = self
.gpu_devices
.iter()
.map(|x| GpuThreads {
gpu_name: x.device_name.clone(),
max_gpu_threads: LUDICROUS_MODE_GPU_GRID_SIZE,
.map(|device| GpuThreads {
gpu_name: device.device_name.clone(),
// get 90% of max grid size
max_gpu_threads: device.max_grid_size.mul(100).div(111),
})
.collect()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import { Controller, useFieldArray, useForm } from 'react-hook-form';
import { modeType } from '@app/store/types.ts';
import { Button } from '@app/components/elements/buttons/Button.tsx';

// took from gpu_miner_adapter.rs
const ECO_MODE_GPU_GRID_SIZE = 2;
const LUDICROUS_MODE_GPU_GRID_SIZE = 900;

enum FormFields {
CPU = 'cpu',
GPUS = 'gpus',
Expand All @@ -33,12 +29,16 @@ interface FormValues {
[FormFields.GPUS]: GpuThreads[];
}

const resolveCpuInitialThreads = (configCpuLevels: number | undefined, mode: modeType | undefined) => {
const resolveCpuInitialThreads = (
configCpuLevels: number | undefined,
mode: modeType | undefined,
maxAvailableThreads: MaxConsumptionLevels
) => {
switch (mode) {
case 'Eco':
return configCpuLevels || ECO_MODE_GPU_GRID_SIZE;
return configCpuLevels || Math.round(maxAvailableThreads.max_cpu_threads * 0.3);
case 'Ludicrous':
return configCpuLevels || LUDICROUS_MODE_GPU_GRID_SIZE;
return configCpuLevels || Math.round(maxAvailableThreads.max_cpu_threads * 0.9);
default:
return 0;
}
Expand All @@ -56,12 +56,12 @@ const resolveGpuInitialThreads = (
case 'Eco':
return maxAvailableThreads.max_gpus_threads.map((gpu) => ({
gpu_name: gpu.gpu_name,
max_gpu_threads: ECO_MODE_GPU_GRID_SIZE,
max_gpu_threads: Math.round(gpu.max_gpu_threads * 0.3),
}));
case 'Ludicrous':
return maxAvailableThreads.max_gpus_threads.map((gpu) => ({
gpu_name: gpu.gpu_name,
max_gpu_threads: LUDICROUS_MODE_GPU_GRID_SIZE,
max_gpu_threads: Math.round(gpu.max_gpu_threads * 0.9),
}));
default:
return [];
Expand All @@ -88,7 +88,7 @@ export function CustomPowerLevelsDialog({

const { control, handleSubmit, setValue, getValues } = useForm<FormValues>({

Check warning on line 89 in src/containers/main/SideBar/Miner/components/CustomPowerLevels/CustomPowerLevelsDialog.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'getValues' is assigned a value but never used. Allowed unused vars must match /^_/u
defaultValues: {
[FormFields.CPU]: resolveCpuInitialThreads(configCpuLevels, mode),
[FormFields.CPU]: resolveCpuInitialThreads(configCpuLevels, mode, maxAvailableThreads),
[FormFields.GPUS]: resolveGpuInitialThreads(configGpuLevels, mode, maxAvailableThreads),
},
});
Expand Down

0 comments on commit fff7a9e

Please sign in to comment.