Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi thread support #9

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include <fstream>
#include <map>
#include <string>
#ifndef WASI
#include <thread>
#endif
#include <vector>
#include <regex>
#include <random>
Expand Down Expand Up @@ -2581,23 +2579,19 @@ static bool log_mel_spectrogram(


{
#ifndef WASI
std::vector<std::thread> workers(n_threads - 1);
for (int iw = 0; iw < n_threads - 1; ++iw) {
workers[iw] = std::thread(
log_mel_spectrogram_worker_thread, iw + 1, std::cref(hann), samples_padded,
n_samples + stage_2_pad, frame_size, frame_step, n_threads,
std::cref(filters), std::ref(mel));
}
#endif

// main thread
log_mel_spectrogram_worker_thread(0, hann, samples_padded, n_samples + stage_2_pad, frame_size, frame_step, n_threads, filters, mel);
#ifndef WASI
for (int iw = 0; iw < n_threads - 1; ++iw) {
workers[iw].join();
}
#endif
}

// clamping and normalization
Expand Down Expand Up @@ -4845,10 +4839,7 @@ int whisper_full_parallel(
if (n_processors == 1) {
return whisper_full(ctx, params, samples, n_samples);
}
#ifdef WASI
return whisper_full(ctx, params, samples, n_samples);
#endif
#ifndef WASI

int ret = 0;

// prepare separate states for each thread
Expand Down Expand Up @@ -4945,7 +4936,6 @@ int whisper_full_parallel(
log("%s: the transcription quality may be degraded near these boundaries\n", __func__);

return ret;
#endif
}

int whisper_full_n_segments_from_state(struct whisper_state * state) {
Expand Down