-
Notifications
You must be signed in to change notification settings - Fork 203
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
Update complex interface #488
Draft
jdemel
wants to merge
17
commits into
gnuradio:main
Choose a base branch
from
jdemel:update-complex-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
44e706a
api: Start to fix complex types
jdemel 56358a4
c++: Make things compile
jdemel 40c109f
wip: Add example files
jdemel 59b58a3
complex: Add example interface for C++
jdemel 165e103
qa: Update QA code to new interface
jdemel 18e2ebe
ci: Fix formatting in kernel_tests.h
jdemel 20566d8
ci: Fix formatting in main.c (temp file)
jdemel 54f34b2
ci: Add ppc64le and s390x tests to TravisCI
jdemel 32b4552
api: Develop C++ wrapper API
jdemel ae7e103
interface: Declare extern C lib
jdemel f74b580
interface: Declare more extern C
jdemel fa675d5
interface: Add review feedback
jdemel 1fdf913
interface: Add feedback for temp files
jdemel 36292bc
interface: Incorporate feedback for MacOS
jdemel f74d94b
interface: Start MSVC fixes
jdemel 5111d6b
msvc: Check for _MSC_VER
jdemel 9011ff8
complex: Add more references
jdemel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gcc -std=c17 -I/home/johannes/src/volk/include -I/home/johannes/src/volk/build/include -L/home/johannes/src/volk/build/lib -x c main.c -o mainvolkgnuc -lm -lvolk | ||
clang -std=c17 -I/home/johannes/src/volk/include -I/home/johannes/src/volk/build/include -L/home/johannes/src/volk/build/lib -x c main.c -o mainvolkclangc -lm -lvolk | ||
g++ -std=c++17 -I/home/johannes/src/volk/include -I/home/johannes/src/volk/build/include -L/home/johannes/src/volk/build/lib -x c++ main.cc -o mainvolkcpp -lm -lfmt -lvolk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
#include <math.h> | ||
#include <stdio.h> | ||
#include <volk/volk.h> | ||
|
||
void function_test(int num_points) | ||
{ | ||
unsigned int alignment = volk_get_alignment(); | ||
lv_32fc_t* in0 = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t) * num_points, alignment); | ||
lv_32fc_t* in1 = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t) * num_points, alignment); | ||
lv_32fc_t* out = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t) * num_points, alignment); | ||
|
||
for (unsigned int ii = 0; ii < num_points; ++ii) { | ||
// Generate two tones | ||
float real_1 = cosf(0.3f * (float)ii); | ||
float imag_1 = sinf(0.3f * (float)ii); | ||
in0[ii] = lv_cmake(real_1, imag_1); | ||
float real_2 = cosf(0.1f * (float)ii); | ||
float imag_2 = sinf(0.1f * (float)ii); | ||
in1[ii] = lv_cmake(real_2, imag_2); | ||
} | ||
|
||
volk_32fc_x2_multiply_32fc(out, in0, in1, num_points); | ||
|
||
for (unsigned int ii = 0; ii < num_points; ++ii) { | ||
lv_32fc_t v0 = in0[ii]; | ||
lv_32fc_t v1 = in1[ii]; | ||
lv_32fc_t o = out[ii]; | ||
printf("in0=(%+.1f%+.1fj), in1=(%+.1f%+.1fj), out=(%+.1f%+.1fj)\n", | ||
creal(v0), | ||
cimag(v0), | ||
creal(v1), | ||
cimag(v1), | ||
creal(o), | ||
cimag(o)); | ||
} | ||
|
||
volk_free(in0); | ||
volk_free(in1); | ||
volk_free(out); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
function_test(32); | ||
|
||
lv_32fc_t fc_cpl[4]; | ||
printf("float=%lu, complex float=%lu, complex float array[4]=%lu\n", | ||
sizeof(float), | ||
sizeof(lv_32fc_t), | ||
sizeof(fc_cpl)); | ||
|
||
for (int i = 0; i < 4; i++) { | ||
fc_cpl[i] = (i + 3) + I * (i + 8); | ||
|
||
fc_cpl[i] = lv_cmake(i + 3, i + 8); | ||
} | ||
for (int i = 0; i < 4; i++) { | ||
lv_32fc_t val = fc_cpl[i]; | ||
lv_32fc_t cval = conj(val); | ||
lv_32fc_t gval = ~val; | ||
lv_32fc_t mult = val * val; | ||
printf("val = %+.1f%+.1fj\n", creal(val), cimag(val)); | ||
printf("conj(val)= %+.1f%+.1fj\n", creal(cval), cimag(cval)); | ||
printf("gcc: ~val= %+.1f%+.1fj\n", creal(gval), cimag(gval)); | ||
printf("val*val = %+.1f%+.1fj\n", creal(mult), cimag(mult)); | ||
} | ||
|
||
lv_8sc_t sc_cpl[4]; | ||
printf("\n\nchar=%lu, complex char=%lu, complex char array[4]=%lu\n", | ||
sizeof(char), | ||
sizeof(lv_8sc_t), | ||
sizeof(sc_cpl)); | ||
|
||
for (int i = 0; i < 4; i++) { | ||
// lv_8sc_t value = (i + 3) + I * (i + 8); | ||
// printf("value=%+hhi%+hhij\n", creal(value), cimag(value)); | ||
// sc_cpl[i] = (i + 3) + I * (i + 8); | ||
sc_cpl[i] = lv_cmake(i + 3, i + 8); | ||
// printf("%i + j %i\n", creal(sc_cpl[i]), cimag(sc_cpl[i])); | ||
} | ||
for (int i = 0; i < 4; i++) { | ||
lv_8sc_t val = sc_cpl[i]; | ||
lv_8sc_t cval = conj(val); | ||
// lv_8sc_t cval = lv_cmake(creal(val), -cimag(val)); | ||
lv_8sc_t gval = ~val; | ||
lv_8sc_t mult = val * val; | ||
printf("val = %+hhi%+hhij\n", __real__ val, __imag__ val); | ||
printf("conj(val)= %+hhi%+hhij\n", __real__ cval, __imag__ cval); | ||
printf("gcc: ~val= %+hhi%+hhij\n", __real__ gval, __imag__ gval); | ||
printf("val*val = %+hhi%+hhij\n", __real__ mult, __imag__ mult); | ||
} | ||
|
||
// char* values = (char*) sc_cpl; | ||
// for (int i = 0; i < 8; i++) { | ||
// printf("%hhi\n", values[i]); | ||
// } | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing you didn't mean to include this file ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ... guessing you're using this &
main.c
andmain.cc
as part of the draft for testing purposes, and you'll remove these once the PR is out of draft ... yes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is a temporary file I intend to remove as soon as I figured out all the details of how to update the interface.