- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have used the MKL library to run the FFT algorithm on the CPU. How should I run it on the GPU? I have tried many times and failed. Can you give me an example of running the FFT algorithm on a GPU using the MKL library? Thanks! I use DPC++.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please provide us with an update on your issue?
Thanks & Regards,
Varsha
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for posting in Intel Communities.
Could you please let us know the OS details, and Intel MKL version you are using?
Could you please let us know and provide us with the sample reproducer code you are trying to run the FFT algorithm on the CPU?
When we tried sample example codes(/dpcpp/dft/source/1dp_complex_1d.cpp) of MKL on a Linux machine, we are able to run the code on CPU as well as GPU, please find the below screenshot and commands for more details:
Compilation: icpx -fsycl -DMKL_ILP64 -DSYCL_DEVICES_gpu -I"${MKLROOT}/include" -I"/home/u 119712/varsha/mkl/dpcpp/common" dp_complex_1d.cpp -fsycl -fsycl-device-code-split=per_kernel ${MKLROOT}/lib/intel64/libmkl_s ycl.a -Wl,-export-dynamic -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequentia l.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lsycl -lOpenCL -lpthread -lm -ldl
Running: ./a.out
You can also use Intel Link Line Advisor for exact compiling and linking the code. Please find the below link for more details:
https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OS:Windows 11
MKL version: OneMKL 2023
My Sample on CPU:
#include <iostream>
#include <vector>
#include <chrono>
#include <mkl.h>
#include <CL/sycl.hpp>
#include <oneapi/mkl/dfti.hpp>
using namespace cl::sycl;
void runFFTOnCPU(const std::vector<std::complex<float>>& input, std::vector<std::complex<float>>& output) {
// Perform FFT on CPU using MKL
DFTI_DESCRIPTOR_HANDLE descriptor;
DftiCreateDescriptor(&descriptor, DFTI_SINGLE, DFTI_COMPLEX, 1, input.size());
DftiSetValue(descriptor, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
DftiCommitDescriptor(descriptor);
const float* input_real = reinterpret_cast<const float*>(input.data()); // Use const_cast instead of reinterpret_cast
float* output_real = reinterpret_cast<float*>(output.data());
DftiComputeForward(descriptor, const_cast<float*>(input_real), output_real);
DftiFreeDescriptor(&descriptor);
}
int main() {
const int size = 8192; // Adjust the size as needed
std::vector<std::complex<float>> input(size, { 1.0f, 0.0f });
std::vector<std::complex<float>> output(size);
// Measure CPU execution time
auto start_cpu = std::chrono::high_resolution_clock::now();
runFFTOnCPU(input, output);
auto end_cpu = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> cpu_duration = end_cpu - start_cpu;
std::cout << "CPU FFT Time: " << cpu_duration.count() << " seconds" << std::endl;
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to run this sample on Visual Studio, but failed! The failure situation is as shown below! Could you please help me see how to modify it?
This is my include directory and library directory.
Can this sample only be run on Visual Studio Code?
OS:Windows 11
MKL version:2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please provide us with an update on your issue?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please provide us with an update on your issue?
Thanks & Regards,
Varsha
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page