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

Call external function with llvm bitcode #2879

Open
squarefk opened this issue Sep 6, 2021 · 1 comment
Open

Call external function with llvm bitcode #2879

squarefk opened this issue Sep 6, 2021 · 1 comment
Assignees
Labels
feature request Suggest an idea on this project

Comments

@squarefk
Copy link
Contributor

squarefk commented Sep 6, 2021

We would like to support more functions from third-party libraries to make taichi more powerful in practice. To achieve this goal, we are trying to include common math libraries like LAPACK, BLAS, Eigen,...

@squarefk squarefk added the feature request Suggest an idea on this project label Sep 6, 2021
@squarefk squarefk self-assigned this Sep 6, 2021
@squarefk
Copy link
Contributor Author

squarefk commented Sep 7, 2021

import ctypes
import os

import taichi as ti

ti.init(dynamic_index=True)

source = '''
void foo(int* a, int b[2][2]) {
    a[0] = 11;
    b[0][0] = 10;
}
'''

ces = ti.CompileExternalSource(source)

@ti.kernel
def call_ext():
    b = 0
    a = ti.Vector([[0, 0], [0, 0]], ti.i32)
    print(a, b)
    ti.call_cpp(ces, "foo", b, a)
    print(a, b)


call_ext()

@squarefk squarefk changed the title Call external function with llvm bitcode and ctypes Call external function with llvm bitcode Sep 16, 2021
ailzhang added a commit that referenced this issue May 17, 2023
Issue: #

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 96d400f</samp>

Comment out redundant code that copies C API library in
`cmake/TaichiCAPI.cmake`. This fixes the Windows issue of finding the
library by the Python wrapper.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 96d400f</samp>

* Remove unnecessary copy command for C API library
([link](https://github.com/taichi-dev/taichi/pull/8014/files?diff=unified&w=0#diff-10352bff7efe48325ce87e625e5f5a62bb33011655bbf87c25c7fafb7e9077deL98-R112)).
This fixes the issue #2879 where the C API library was not found by the
Python wrapper on Windows. The `install` command already copies the
library to the output directory, so the extra copy command was redundant
and caused conflicts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project
Projects
None yet
Development

No branches or pull requests

1 participant