Skip to content

Instantly share code, notes, and snippets.

@sklam
Created December 12, 2016 14:31
Show Gist options
  • Save sklam/a689af4b0d73ae65fdb4c2921f797901 to your computer and use it in GitHub Desktop.
Save sklam/a689af4b0d73ae65fdb4c2921f797901 to your computer and use it in GitHub Desktop.
rocfft error
(gdb) run
Starting program: /home/amd_user/rocFFT/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff403d700 (LWP 23714)]
*******************************************************************************
Work buffer size: 0
Work buffer ratio: 0
dimension: 1
batch: 1
length: 16
iStrides: 1, 16
oStrides: 1, 16
inplace complex interleaved -> complex interleaved
scheme: CS_KERNEL_STOCKHAM
TTD: 0
large1D: 0
B -> B
===============================================================================
16, -16
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
0, 0
*******************************************************************************
Program received signal SIGSEGV, Segmentation fault.
std::vector<unsigned long, std::allocator<unsigned long> >::size (this=0x10)
at /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:646
646 { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
(gdb) bt
#0 std::vector<unsigned long, std::allocator<unsigned long> >::size (this=0x10)
at /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:646
#1 0x00000000004bc43f in PrintNode (execPlan=...) at /home/amd_user/rocFFT/library/src/plan.cpp:1957
#2 0x00000000004c9ef9 in rocfft_execute (plan=0xea5c90, in_buffer=0x7fffffffe518, out_buffer=0x0,
info=0x0) at /home/amd_user/rocFFT/library/src/transform.cpp:50
#3 0x00000000006c1be3 in work() ()
#4 0x00000000006c1e58 in main ()
#include <iostream>
#include <vector>
#include "hip/hip_runtime_api.h"
#include "hip/hip_vector_types.h"
#include "rocfft.h"
int work()
{
// rocFFT gpu compute
// ========================================
size_t N = 16;
size_t Nbytes = N * sizeof(float2);
// Create HIP device buffer
float2 *x;
hipMalloc(&x, Nbytes);
// Initialize data
std::vector<float2> cx(N);
for (size_t i = 0; i < N; i++)
{
cx[i].x = 1;
cx[i].y = -1;
}
// Copy data to device
hipMemcpy(x, &cx[0], Nbytes, hipMemcpyHostToDevice);
// Create rocFFT plan
rocfft_plan plan = NULL;
size_t length = N;
rocfft_plan_create(&plan, rocfft_placement_inplace, rocfft_transform_type_complex_forward, rocfft_precision_single, 1, &length, 1, NULL);
// Execute plan
rocfft_execute(plan, (void**) &x, NULL, NULL);
// Wait for execution to finish
hipDeviceSynchronize();
// Destroy plan
rocfft_plan_destroy(plan);
// Copy result back to host
std::vector<float2> y(N);
hipMemcpy(&y[0], x, Nbytes, hipMemcpyDeviceToHost);
// Print results
for (size_t i = 0; i < N; i++)
{
std::cout << y[i].x << ", " << y[i].y << std::endl;
}
return 0;
}
int main() {
for (int i=0; i<20; ++i) {
work();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment